question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

'no-undef' not working with a specific variable name.

See original GitHub issue

In my project, the ‘no-undef’ rule has worked fine for months, yesterday I noticed that this rule doesn’t work for the variable ‘Request’ which I use often in my project. screenshot_467 As you can see, eslint detects that someOtherVariable is not declared, while ignoring Request. I checked on eslint-cli, atom linter, same thing. This is my config, am I doing something wrong?

module.exports = {
  'parserOptions': {
    'ecmaVersion': 8
  },
  rules: {
    camelcase: 0,
    'comma-dangle': [2, 'never'],
    'comma-spacing': [2, {
      before: false,
      after: true
    }],
    'arrow-spacing': [2, { before: true, after: true }],
    'array-bracket-spacing': 1,
    'consistent-return': 0,
    curly: 0,
    'default-case': 0,
    eqeqeq: [2, 'smart'],
    'func-names': 0,
    'guard-for-in': 2,
    indent: [2, 2, {
      SwitchCase: 1
    }],
    'key-spacing': [2, {
      beforeColon: false,
      afterColon: true
    }],
    'keyword-spacing': [2, {
      before: true,
      after: true
    }],
    'max-len': 0,
    'new-cap': [2, {
      newIsCapExceptions: ['acl.memoryBackend', 'acl', 'mongoose', 'mongoose.Schema', 'mongoose.Types.ObjectId', 'mongodbBackend'],
      capIsNewExceptions: ['Schema', 'mongoose.Schema', 'ValidateSecretKey', 'mongoose.Types.ObjectId', 'Server', 'MongooseHistoryPlugin', 'MongodbMixin', 'ExcelWriterMixin']
    }],
    'no-bitwise': 0,
    'no-caller': 2,
    'no-console': 0,
    'no-else-return': 0,
    'no-empty-class': 0,
    'no-multi-spaces': 2,
    'no-param-reassign': 0,
    'no-shadow': 0,
    'no-spaced-func': 2,
    'no-throw-literal': 2,
    'no-trailing-spaces': 2,
    'no-undef': 2,
    'no-unneeded-ternary': 2,
    'no-unreachable': 2,
    'no-underscore-dangle': 0,
    'no-unused-expressions': 0,
    'no-unused-vars': 0,
    'no-use-before-define': [1, 'nofunc'],
    'no-var': 0,
    'object-curly-spacing': [2, 'always'],
    'one-var': [0, 'never'],
    'one-var-declaration-per-line': [2, 'always'],
    'padded-blocks': 0,
    'space-before-blocks': 1,
    'space-before-function-paren': 1,
    'space-infix-ops': 2,
    'space-in-parens': [2, 'never'],
    'spaced-comment': [2, 'always'],
    strict: 0,
    'quote-props': 0,
    quotes: [1, 'single'],
    'wrap-iife': [2, 'outside'],
    'vars-on-top': 0
  },
  env: {
    node: true,
    browser: true,
    jasmine: true,
    mocha: true,
    jquery: true
  },
  globals: {
    $: true,
    ga: true,
    angular: true,
    by: true,
    browser: true,
    element: true,
    inject: true,
    io: true,
    moment: true,
    Modernizr: true,
    Promise: true,
    __TESTING__: true,
    _: false,
    ApplicationConfiguration: true
  }
};

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
galvarez421commented, Feb 4, 2018

Is this because you have browser environment enabled and Request is a browser global? https://developer.mozilla.org/en-US/docs/Web/API/Request

0reactions
jeron-dioviscommented, Jul 27, 2018

Yes, it helps indeed. Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

ESLint's "no-undef" rule is calling my use of Underscore an ...
Any reference to an undeclared variable causes a warning, unless the variable is explicitly mentioned in a /*global ...*/ comment, or specified ......
Read more >
no-undef - ESLint - Pluggable JavaScript Linter
This rule can help you locate potential ReferenceErrors resulting from misspellings of variable and parameter names, or accidental implicit globals (for ...
Read more >
1782491 - Enable "no-undef" ESLint rule for self-hosted code
Misspelled variable names in self-hosted code currently lead to assertion errors, but only when the relevant code is actually executed.
Read more >
Disallow Use of undefined Variable (no-undefined) - ESLint
The undefined variable in JavaScript is actually a property of the global ... (This is not the case for null , which is...
Read more >
Rule no-undef - ESLint中文文档
This rule can help you locate potential ReferenceErrors resulting from misspellings of variable and parameter names, or accidental implicit globals (for ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found