Consolidating `strict` rule definition between airbnb and airbnb-base
See original GitHub issueHi!
I’ve spotted some inconsistency/duplication with the strict
rule and wondered if this was intentional?
Currently:
- There’s the eslint-config-airbnb-base/rules/strict file that declares
strict: ['error', 'never']
. - That file is only used in
eslint-config-airbnb
and noteslint-config-airbnb-base
. - Instead
eslint-config-airbnb-base
setsstrict: 'error'
manually in its rules directive (which results in the ESLint default ofstrict: ['error', 'safe']
). - However both
eslint-config-airbnb-base
andeslint-config-airbnb
setsourceType: 'module'
, which causes the ESLint strict rule to “disallow[s] strict mode directives, no matter which option is specified” regardless of those options - ie:strict: ['error', 'never']
(docs).
Issues:
- It was my understanding that for the most part, the generic (ie non react, non-AirBnb-as-as-company specific) rules/configuration belong in
eslint-config-airbnb-base
rather thaneslint-config-airbnb
, but yet theeslint-config-airbnb-base/rules/strict
extends
is contrary to that, and confusing to the end user if it actually resulted in different strict mode behaviour. - However unless people override
sourceType: 'module'
, botheslint-config-airbnb-base
andeslint-config-airbnb
actually result in the same strict mode behaviour (ie: equivalent ofstrict: ['error', 'never']
) anyway, so in most cases the rule being listed twice is just duplication rather than having any effect.
I think this situation might just be an accidental leftover from the split to the airbnb-base package (see here) and then #637.
As such, to increase consistency I would like to propose:
- Moving
eslint-config-airbnb-base/rules/strict
fromeslint-config-airbnb
’sextends
toeslint-config-airbnb-base
’s (this won’t affect legacy). - Deleting the manual
strict
rule definition fromeslint-config-airbnb-base
’srules
. - Probably bumping the
eslint-config-airbnb-base
major version in case there’s anyone using it who setssourceType: 'script'
manually rather than using legacy, since they would see a difference in behaviour.
If this sounds acceptable, I’m happy to open a PR 😃
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:6 (3 by maintainers)
Top Results From Across the Web
airbnb react/function-component-definition
I'm trying to use eslint . I get the above error ⬆️ and it states that: Value ["function-declaration","function-expression"] should be equal to one...
Read more >Terms of Service - Airbnb Help Center
It is your responsibility to read and understand these rules, standards, policies, and requirements prior to booking a Listing.Be aware that some Hosts...
Read more >How to use the eslint-config-airbnb-base/rules/style. ...
To help you get started, we've selected a few eslint-config-airbnb-base examples, ... Ensure the replacement rules use the options set by airbnb rather...
Read more >Adopt airbnb javascript style guide v14.1 as new baseline ...
Their rules are more strict than ours, it's a good move for our ... The patch adopts the standards wholesale, which means no...
Read more >Linting
You can write your own rules to ensure code consistency across your team or ... eslint-plugin-import is a peer dependency of eslint-config-airbnb-base, ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Sorry for the delay; have opened airbnb/javascript#1962 😃
@ljharb said
Which is true. I use the base config and was surprised to see
"use strict";
was no longer allowed after updating to the latest major version.But this made me realize that the airbnb style guide
So I get the idea it shouldn’t really be used for Node.js and am thus going to switch to something else for that.
Posting here so you guys are aware of this part of your user base 😄