Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eslint: switch from custom rules to eslint-config-wikimedia #1976

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

NovemLinguae
Copy link
Member

@NovemLinguae NovemLinguae commented Jun 22, 2024

https://github.com/wikimedia/eslint-config-wikimedia

Why switch?

  • it's standard for wikimedia projects
  • it has some cool features such as jquery deprecation warnings, and enforcing a specific version of JavaScript
  • I believe it has many more rules than our previous configuration, which will help with identifying areas of the code to modernize

What this patch does

  • delete all old linter rules, except for these rules I carried over:
    • no-nested-ternary
    • no-restricted-syntax for .done() and .fail()
  • upgrade eslint a couple minor versions
  • add eslint-config-wikimedia and its default rules
  • disable controversial rules such as
    • whitespace in parentheses (space-in-parens, space-before-function-paren, array-bracket-spacing, computed-property-spacing, object-curly-spacing)
    • max line length 100 (max-len)
  • disable some rules
    • indent because it would involve touching almost every line, messing up git blame (although I may autofix this in the future and set a .git-blame-ignore-revs to reduce git blame spam)
    • wrap-iife to reduce VS Code yellow underline spam (will autofix this in a future patch)
    • couple others that I don't like and have disabled in my other projects
  • set it to ES6 since wikimedia "modern layer" support is now on ES6
  • warn/error for syntax or internal functions higher than ES6 (this is more thorough than the old >ES6 detection we were using)
  • set all remaining detected violations to "warn" for now, so that CI passes
  • will apply autofixes for all the rules that "warn" in a future patch

The rules are in two groups, with an extra line break in the middle separating them.

  • The top group are rules that should not be fixed
  • The bottom group are rules that should be fixed over time via autofixes and manual fixing. Once everything for that rule is fixed, that rule can be deleted, so that the linter starts enforcing it in CI.

Over time, rules will be fixed and removed from the config, and the code will be incrementally modernized, until it arrives at the Wikimedia standard.

Why switch?
- it's standard for wikimedia projects
- it has some cool features such as jquery deprecation warnings, and enforcing a specific version of JavaScript
- I believe it has many more rules than our previous configuration, which will help with identifying areas of the code to modernize

What this patch does
- delete all old linter rules, except for these rules I carried over:
	- `no-nested-ternary`
	- `no-restricted-syntax` for `.done()` and `.fail()`
- upgrade eslint a couple minor versions
- add eslint-config-wikimedia and its default rules
- disable controversial rules such as
	- whitespace in parentheses (`space-in-parens`, `space-before-function-paren`, `array-bracket-spacing`, `computed-property-spacing`, `object-curly-spacing`)
	- max line length 100 (`max-len`)
- disable some rules
	- `indent` because it would involve touching almost every line, messing up git blame (although I may autofix this in the future and set a .git-blame-ignore-revs to reduce git blame spam)
	- `wrap-iife` to reduce VS Code yellow underline spam (will autofix this in a future patch)
	- couple others that I don't like and have disabled in my other projects
- set it to ES6 since wikimedia "modern layer" support is now on ES6
- warn/error for syntax or internal functions higher than ES6 (this is more thorough than the old >ES6 detection we were using)
- set all remaining detected violations to "warn" for now, so that CI passes
- will apply autofixes for all the rules that "warn" in a future patch

The rules are in two groups, with an extra line break in the middle separating them.
- The top group are rules that should not be fixed
- The bottom group are rules that should be fixed over time via autofixes and manual fixing. Once everything for that rule is fixed, that rule can be deleted, so that the linter starts enforcing it in CI.

Over time, rules will be fixed and removed from the config, and the code will be incrementally modernized, until it arrives at the Wikimedia standard.
@github-actions github-actions bot added the dependencies Pull requests that update a dependency file, likely through dependabot label Jun 22, 2024
@NovemLinguae NovemLinguae changed the title https://github.com/wikimedia/eslint-config-wikimedia eslint: switch from custom rules to eslint-config-wikimedia Jun 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file, likely through dependabot
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant