Skip to content

Consolidating strict rule definition between airbnb and airbnb-base #1582

Closed
@edmorley

Description

@edmorley

Hi!

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 not eslint-config-airbnb-base.
  • Instead eslint-config-airbnb-base sets strict: 'error' manually in its rules directive (which results in the ESLint default of strict: ['error', 'safe']).
  • However both eslint-config-airbnb-base and eslint-config-airbnb set sourceType: '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 than eslint-config-airbnb, but yet the eslint-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', both eslint-config-airbnb-base and eslint-config-airbnb actually result in the same strict mode behaviour (ie: equivalent of strict: ['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 from eslint-config-airbnb's extends to eslint-config-airbnb-base's (this won't affect legacy).
  • Deleting the manual strict rule definition from eslint-config-airbnb-base's rules.
  • Probably bumping the eslint-config-airbnb-base major version in case there's anyone using it who sets sourceType: '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 :-)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions