Skip to content

Commit

Permalink
[wip] feat: add whitelist of rules directives can be used to disable
Browse files Browse the repository at this point in the history
WIP: This is not yet a complete list. If you routinely need to disable
rules for valid reasons, add your rules here along with a justification!

This changeset adds a whitelist of list of rules that can be disabled by
eslint directives (e.g. `/* eslint-disable rule-name-here */`). As a
starting point, no rules can be disabled via directives. A few
exceptions have been added to the list. We should aim to keep this list
as short as possible.

Developers can still disable rules by modifying their project's ESLint
configuration, which is much easier to catch in review because new
features and bugfixes generally shouldn't require lint configuration
changes. (A nice side effect that can fall out of this is that
restricting where we can make lint configuration changes will allow us
to do things like set up `policy-bot` rules that require additional
approvals when a PR modifies a lint configuration to help us make sure
we upstream lint configuration changes into the common lint config.)
  • Loading branch information
ndhoule committed Nov 18, 2019
1 parent b752c6f commit a3cc67b
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/config/recommended.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,28 @@ export default {
// to allow whole-file `eslint-disable`s, but in practice we do it frequently for somtimes-
// legitimate reasons.
'eslint-comments/disable-enable-pair': ['error', {allowWholeFile: true}],
// A list of ESLint rules that developers are permitted to disable using eslint directives.
'eslint-comments/no-restricted-disable': [
'error',
// Don't allow any lint rules to be disabled.
'*',
// Unfortunately, ts-ignore directives are sometimes a necessary evil to work around bugs in
// type definitions, missing typedefs, as the most reasonable path toward gradually adopting
// TypeScript, etc.
'!@typescript-eslint/ban-ts-ignore',
// A bug in `eslint-plugin-import` results in false errors in TypeScript files.
// https://github.com/benmosher/eslint-plugin-import/issues/1282
'!import/named',
// We have a habit of permitting console statements in scripts, frontend code, etc. Until we
// establish solid conventions around when console methods are permitted and when they are
// not, permit developers to disable this lint rule inline.
'!no-console',
// Sometimes you need to use non-camelcase casing; this happens most commonly when dealing
// with third-party APIs, where inbound data includes properties in snake case, or outbound
// data is expected in snake case.
'@typescript-eslint/camelcase',
'camelcase',
],
// Restrict the use of eslint directives in files. ESLint rules should be specified in the
// ESLint configuration as much as possible; this prevents, for example, users from changing
// rules for a specific file (e.g. `/* eslint no-undef: warn */`), but allows users to disable
Expand Down

0 comments on commit a3cc67b

Please sign in to comment.