Skip to content

Commit

Permalink
Use @stylistic/eslint-plugin-js for max-len rule (#989)
Browse files Browse the repository at this point in the history
DEFRA/water-abstraction-team#115

In [Add linting using eslint with standard as the base](#948) we switched from using [standard](https://www.npmjs.com/package/standard) directly for linting to using [ESlint](https://eslint.org/).

This is all part of the work we are doing to start codifying our conventions rather than writing them up for no one to read! 😁

As a start, we enabled the rule [max-len](https://eslint.org/docs/latest/rules/max-len) which **standard** doesn't have. That flagged some long text strings we have, and we don't want to break them up just for the sake of the linter.

So, we went to check what options there were for the rule and found this

> This rule was **deprecated** in ESLint v8.53.0. Please use the [corresponding rule](https://eslint.style/rules/js/max-len) in [@stylistic/eslint-plugin-js](https://eslint.style/packages/js).

But it looks like ESLint has moved on a bit since we last used it and has chosen to [move some of its core stylistic-based rules to a plugin](https://eslint.org/blog/2023/10/deprecating-formatting-rules/).

This change switches to using the plugin to lint `max-len`.
  • Loading branch information
Cruikshanks authored May 8, 2024
1 parent b5f4a3b commit 9405ea6
Show file tree
Hide file tree
Showing 3 changed files with 120 additions and 1 deletion.
5 changes: 4 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
module.exports = {
extends: 'standard', // Maintain Standard.js rules
plugins: [
'@stylistic/js'
],
rules: {
'max-len': ['error', {
'@stylistic/js/max-len': ['error', {
code: 120
}]
}
Expand Down
115 changes: 115 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
"@hapi/code": "^9.0.3",
"@hapi/hoek": "^11.0.2",
"@hapi/lab": "^25.1.3",
"@stylistic/eslint-plugin-js": "^1.8.1",
"eslint": "^8.57.0",
"mock-fs": "^5.2.0",
"nock": "^13.3.2",
Expand Down

0 comments on commit 9405ea6

Please sign in to comment.