Skip to content

ESLint Plugin: Update rules for improved Prettier / TypeScript compatibility#6123

Merged
aduth merged 5 commits intomainfrom
eslint-ts-prettier-compat
Mar 30, 2022
Merged

ESLint Plugin: Update rules for improved Prettier / TypeScript compatibility#6123
aduth merged 5 commits intomainfrom
eslint-ts-prettier-compat

Conversation

@aduth
Copy link
Contributor

@aduth aduth commented Mar 30, 2022

In order to avoid conflicts and redundancy, this pull request updates a number of rules to either (a) disable a stylistic rule which would be redundant with Prettier formatting, and (b) reduce conflicts with TypeScript syntax specifics, where the TypeScript ESLint plugin offers enhancements to the base rule.

In theory, this could also help speed up linting, since it's running fewer rule checks.

Method:

  1. Print effective configuration
    • yarn eslint --print-config .eslintrc
  2. Find base ESLint enforced rules
    • console.log(JSON.stringify(Object.entries(c.rules).filter(([k,v]) => v === 'error' || v[0] === 'error').filter(([k])=> !k.includes('/')).map(([k])=>k).sort(),null,2))
  3. Discover TypeScript rule enhancements
  4. Discover stylistic rules
    • Search "styl" or "spac" in list of enforced rules, and otherwise just manually review list of rules
  5. For TypeScript overrides, retain original rule configuration of rule being overridden (refer to configuration from Step 1)

aduth added 5 commits March 30, 2022 09:43
**Why**: So that TypeScript syntax specifics don't cause conflicts with the base rules that assume JavaScript.
**Why**: Because stylistic enforcement should come through Prettier
Left-over from trying to configure TypeScript "project" parser option
changelog: Internal, Linting, Improve compatibility of ESLint configuration with Prettier and TypeScript
Copy link
Contributor

@zachmargolis zachmargolis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! would it be worth committing scripts those JS blurbs as scripts so we could simplify running them for a future round of these changes?

@aduth
Copy link
Contributor Author

aduth commented Mar 30, 2022

would it be worth committing scripts those JS blurbs as scripts so we could simplify running them for a future round of these changes?

Listing them the way I did might give a false impression that it's more automatable than it actually is, since it did still require a fair bit of manual review, particularly in determining which are "stylistic" rules and which TypeScript plugin rules extend a base rule.

Not to say it couldn't be done, but it's probably more effort and less reliable than the value it might provide.

@aduth aduth merged commit 74961fd into main Mar 30, 2022
@aduth aduth deleted the eslint-ts-prettier-compat branch March 30, 2022 18:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants