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.

Can't overwrite "strict" rule

See original GitHub issue

I have the following files:

// foo.js
function foo() {
  return 42;
}

foo();

---
extends: airbnb/base
rules:
  strict: [2, "global"]

Running eslint foo.js returns successfully, even though foo.js has no "use strict"; directive. If I change to extends: eslint:recommended, it complains because of the lack of "use strict"; (as expected).

I tried to overwrite another rule, so I changed the files to:

// foo.js
function foo() {
  return 42;
}

// Remove the call to foo();
// foo();

---
extends: airbnb/base
rules:
  no-unused-vars: 0

And it worked. I was able to overwrite no-unused-vars.

I’m running eslint@1.10.3 and eslint-config-airbnb@5.0.0 with Node v5.5.0 and npm v3.6.0.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:7

github_iconTop GitHub Comments

6reactions
Starefossencommented, Jun 7, 2016

Sorry for this way to late reply 😦

The problem I had was to force the use of "use strict"; using the "strict": [2, "global"] rule. This did not have any effect and ESLint said that "use strict"; was not necessary when using ES6 modules.

However this was in a Node.js project and my models are not ES6 modules and I wanted them all to have strict mode enabled and I was able to force it by setting "sourceType": "script" in parserOptions like this:

{                                                                    
    "extends": "airbnb-base",                                        
    "env": {                                                         
      "node": true                                                   
    },                                                               
    "parserOptions": {                                               
      "ecmaVersion": 6,                                              
      "sourceType": "script",                                        
      "ecmaFeatures": {                                              
        "modules": false                                             
      }                                                              
    },                                                               
    "rules": {                                                       
      "strict": [2, "global"]
    }                                                                
}                                                                    
0reactions
blakedietzcommented, Dec 11, 2016

@Starefossen you’re solution works. I had the exact same use case for linting an AWS Lambda project. Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Turning off Strict Mode in Angular? - Stack Overflow
Following Angular doc, the strict mode can be disabled turning off these flags on tsconfig.json file:
Read more >
12 Rules of Overriding in Java You Should Know
Rule #1:Only inherited methods can be overridden. Because overriding happens when a subclass re-implements a method inherited from a superclass, ...
Read more >
Strict mode - JavaScript - MDN Web Docs
Strict mode makes several changes to normal JavaScript semantics: Eliminates some JavaScript silent errors by changing them to throw errors.
Read more >
Preset security policies - Office 365 - Microsoft Learn
Rules : Separate rules for the Standard preset security policy, the Strict preset security policy, and the Built-in protection preset security ...
Read more >
How to Deal With Strict Parents as a Teenager
Discover the six effective ways for teenagers to deal with overly strict parents. The best way to stop harsh parents from ruining your...
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