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

Use @stylistic/eslint-plugin-js for max-len rule #989

Merged
merged 4 commits into from
May 8, 2024

Conversation

Cruikshanks
Copy link
Member

@Cruikshanks Cruikshanks commented May 8, 2024

DEFRA/water-abstraction-team#115

In Add linting using eslint with standard as the base we switched from using standard directly for linting to using ESlint.

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 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 in @stylistic/eslint-plugin-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.

This change switches to using the plugin to lint max-len.

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 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 are 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.style/packages/js).

This change switches to using the plugin to lint `max-len`. It also updates the config to exclude strings and template literals from the rule.
@Cruikshanks Cruikshanks added the housekeeping Refactoring, tidying up or other work which supports the project label May 8, 2024
@Cruikshanks Cruikshanks self-assigned this May 8, 2024
@Cruikshanks Cruikshanks force-pushed the use-eslint-stylistic-plugin-for-mac-len branch from 423b3f6 to a5b21ba Compare May 8, 2024 08:49
@Cruikshanks Cruikshanks marked this pull request as ready for review May 8, 2024 08:51
@Cruikshanks Cruikshanks merged commit 9405ea6 into main May 8, 2024
6 checks passed
@Cruikshanks Cruikshanks deleted the use-eslint-stylistic-plugin-for-mac-len branch May 8, 2024 10:06
Cruikshanks added a commit that referenced this pull request May 8, 2024
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! 😁

We then went to make a config change but saw that we were using a deprecated core rule and instead needed to [use @stylistic/eslint-plugin-js for max-len rule](#989). So, we fixed that! 💪

But then we clocked ESLint was telling us our `.eslintrc.js` [config file format is deprecated](https://eslint.org/docs/latest/use/configure/configuration-files-deprecated)! 😩 We instead should be using the `eslint.config.js` [flat file config](https://eslint.org/docs/latest/use/configure/configuration-files).

So, before we start making changes to our config this change gets us using the latest supported format.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
housekeeping Refactoring, tidying up or other work which supports the project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants