Skip to content

Commit 8cb669b

Browse files
authored
ci: migrate e2e to eslint v9 flat config (#6699)
## What's the problem this PR addresses? - supersedes #6690 The workflow [.github/workflows/e2e-eslint-workflow.yml](https://github.com/yarnpkg/berry/blob/master/.github/workflows/e2e-eslint-workflow.yml) fails with ```text Oops! Something went wrong! :( ESLint: 9.20.1 ESLint couldn't find an eslint.config.(js|mjs|cjs) file. ``` It was last successful 11 months ago on Apr 5, 2024 coinciding with the release of [ESLint 9.0.0](https://eslint.org/blog/2024/04/eslint-v9.0.0-released/) which changed the default config to flat. The workflow installs `eslint` with no version specified, therefore `eslint@latest` is used (currently `[email protected]`). ## How did you fix it? In the workflow [.github/workflows/e2e-eslint-workflow.yml](https://github.com/yarnpkg/berry/blob/master/.github/workflows/e2e-eslint-workflow.yml) each `.estlintrc` is changed to `eslint.config.mjs` ### Validating ESLint The ESLint rule [semi](https://eslint.org/docs/latest/rules/semi) was [deprecated](https://eslint.org/blog/2023/10/deprecating-formatting-rules/) in [ESLint v8.53.0](https://eslint.org/blog/2023/11/eslint-v8.53.0-released/) and moved instead to [@stylistic/eslint-plugin-js](https://eslint.style/packages/js). Following the [ESLint Stylistic Migration Guide](https://eslint.style/guide/migration) and using the recommended approach of one single plugin, additionally install [@stylistic/eslint-plugin](https://www.npmjs.com/package/@stylistic/eslint-plugin). Use the rule [@stylistic/semi](https://eslint.style/rules/default/semi). ### Running the TypeScript integration test [typescript-eslint v7](https://typescript-eslint.io/blog/announcing-typescript-eslint-v7/) allows [switching](https://typescript-eslint.io/blog/announcing-typescript-eslint-v7/#switching-to-typescript-eslint) from [@typescript-eslint/parser](https://www.npmjs.com/package/@typescript-eslint/parser) and [@typescript-eslint/eslint-plugin](https://www.npmjs.com/package/@typescript-eslint/eslint-plugin) to [typescript-eslint](https://www.npmjs.com/package/typescript-eslint). ## Checklist - [X] I have read the [Contributing Guide](https://yarnpkg.com/advanced/contributing). - [X] I have set the packages that need to be released for my changes to be effective. (none) - [x] I will check that all automated PR checks pass before the PR gets reviewed.
1 parent 83b7a26 commit 8cb669b

File tree

1 file changed

+28
-4
lines changed

1 file changed

+28
-4
lines changed

.github/workflows/e2e-eslint-workflow.yml

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,22 @@ jobs:
2626
source scripts/e2e-setup-ci.sh
2727
2828
yarn init -p
29-
yarn add eslint
29+
yarn add eslint @stylistic/eslint-plugin
3030
31-
echo '{"rules": {"semi": ["error", "always"]}}' > .eslintrc
31+
cat > eslint.config.mjs <<EOT
32+
import stylistic from '@stylistic/eslint-plugin'
33+
34+
export default [
35+
{
36+
plugins: {
37+
'@stylistic': stylistic
38+
},
39+
rules: {
40+
'@stylistic/semi': 'error',
41+
}
42+
}
43+
]
44+
EOT
3245
3346
echo '42;' | tee ok.js
3447
yarn eslint ok.js
@@ -41,9 +54,20 @@ jobs:
4154
source scripts/e2e-setup-ci.sh
4255
4356
yarn init -p
44-
yarn add eslint typescript @typescript-eslint/parser @typescript-eslint/eslint-plugin
57+
yarn add eslint typescript typescript-eslint
58+
59+
cat > eslint.config.mjs <<EOT
60+
import tseslint from 'typescript-eslint';
4561
46-
echo '{"parser": "@typescript-eslint/parser", "plugins": ["@typescript-eslint"], "rules": {"@typescript-eslint/explicit-function-return-type": "error"}}' > .eslintrc
62+
export default tseslint.config(
63+
tseslint.configs.recommended,
64+
{
65+
rules: {
66+
'@typescript-eslint/explicit-function-return-type': 'error',
67+
'@typescript-eslint/no-unused-vars': 'off',
68+
},
69+
});
70+
EOT
4771
4872
echo 'const f = (): number => 42;' | tee ok.ts
4973
yarn eslint ok.ts

0 commit comments

Comments
 (0)