Skip to content

Commit

Permalink
Upgrade ESLint from v8 to v9 (#431)
Browse files Browse the repository at this point in the history
* build: upgrade `eslint` to 9.16.0

* build: upgrade `eslint-plugin-ember` to 12.3.3

* build: upgrade `eslint-plugin-n` to 17.14.0

* build: upgrade `eslint-plugin-qunit` to 8.1.2

* chore: run `npx @eslint/migrate-config`

Command executed:

```
npx @eslint/migrate-config .eslintrc.js
```

* build: add `globals@15.12.0`

* build: add `@eslint/js@9.16.0`

* build: add `@eslint/eslintrc@3.2.0`

* build: add `typescript-eslint@8.16.0`

https://typescript-eslint.io/packages/typescript-eslint/

* build: deduplicate lockfile

Commands executed:
1. `npx yarn-deduplicate`
2. `yarn`

* refactor: run lint auto-fix

* refactor: rename imported symbols

* chore: delete legacy files from ESLint before v9

* chore: fix relative file paths

Looks like a bug:
eslint/eslint#18757

* chore: add `.mjs` files to Prettier

* refactor: make use of helper `tseslint.config()`

https://typescript-eslint.io/packages/typescript-eslint/#config

* refactor: use flat configs of plugins applied globally

* refactor: merge configs for `eslint-plugin-n`

* refactor: use flat config of `eslint-plugin-n`

* refactor: use flat config of `eslint-plugin-qunit`

* refactor: merge configs for `@typescript-eslint`

* refactor: restore comment for rules `@typescript-eslint`

* refactor: use flat config of `@typescript-eslint`

* refactor: remove unused `FlatCompat`
  • Loading branch information
MrChocolatine authored Dec 3, 2024
2 parents bd089c3 + 39b068c commit a4b389f
Show file tree
Hide file tree
Showing 7 changed files with 446 additions and 632 deletions.
17 changes: 0 additions & 17 deletions .eslintignore

This file was deleted.

99 changes: 0 additions & 99 deletions .eslintrc.js

This file was deleted.

2 changes: 0 additions & 2 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
/.ember-cli
/.env*
/.eslintcache
/.eslintignore
/.eslintrc.js
/.git/
/.github/
/.gitignore
Expand Down
2 changes: 1 addition & 1 deletion .prettierrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module.exports = {
overrides: [
{
files: '*.{js,ts}',
files: '*.{js,mjs,ts}',
options: {
semi: false,
singleQuote: true,
Expand Down
127 changes: 127 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
import globals from 'globals'
import tseslint from 'typescript-eslint'

import pluginEmber from 'eslint-plugin-ember'
import pluginEmberRecommended from 'eslint-plugin-ember/configs/recommended'
import pluginEslintJs from '@eslint/js'
import pluginNode from 'eslint-plugin-n'
import pluginPrettierRecommended from 'eslint-plugin-prettier/recommended'
import pluginQunitRecommended from 'eslint-plugin-qunit/configs/recommended'

export default tseslint.config(
pluginEslintJs.configs.recommended,
// @ts-expect-error: See https://github.com/ember-tooling/ember-eslint-parser/issues/113
...pluginEmberRecommended,
pluginPrettierRecommended,

{
ignores: [
// Unconventional js
'blueprints/*/files/',

// Compiled output
'dist/',

// Misc
'coverage/',
'!**/.*',
'**/.*/',

// ember -try
'.node_modules.ember-try/',
'npm-shrinkwrap.json.ember-try',
'package.json.ember-try',
'package-lock.json.ember-try',
'yarn.lock.ember-try',
],
},
{
plugins: {
ember: pluginEmber,
'@typescript-eslint': tseslint.plugin,
},

languageOptions: {
globals: {
...globals.browser,
},

parser: tseslint.parser,
ecmaVersion: 'latest',
sourceType: 'script',
},

rules: {
'@typescript-eslint/ban-ts-comment': [
'error',
{
'ts-check': 'allow-with-description',
'ts-expect-error': 'allow-with-description',
'ts-ignore': 'allow-with-description',
'ts-nocheck': 'allow-with-description',
/**
* Count 2 characters for `: ` when giving a description.
*
* @ts-nocheck: a
* ^^^--- Description of 3 characters
*
* @ts-nocheck: abc
* ^^^^^--- Description of 5 characters
*/
minimumDescriptionLength: 7, // minimum of 2 + 5
},
],

// This rule is overriden and configured in the `overrides` Array below
'@typescript-eslint/explicit-module-boundary-types': 'off',

'no-empty-function': 'off',
'@typescript-eslint/no-empty-function': ['error'],
},
},
{
// Config for Typescript files

extends: [tseslint.configs.recommended],

files: ['**/*.ts'],

rules: {
'@typescript-eslint/explicit-module-boundary-types': ['error'],
'@typescript-eslint/no-unused-vars': 'off',
'no-undef': 'off',
'no-unused-vars': 'off',
},
},
{
// Config for Node files

...pluginNode.configs['flat/recommended-script'],

files: [
'.prettierrc.js',
'.stylelintrc.js',
'.template-lintrc.js',
'ember-cli-build.js',
'eslint.config.mjs',
'index.js',
'testem.js',
'blueprints/*/index.js',
'config/**/*.js',
'tests/dummy/config/**/*.js',
],

languageOptions: {
globals: {
...Object.fromEntries(Object.entries(globals.browser).map(([key]) => [key, 'off'])),
...globals.node,
},
},
},
{
// Config for test files

...pluginQunitRecommended,
files: ['tests/**/*-test.{js,ts}'],
},
)
14 changes: 8 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@
"@ember/optional-features": "^2.0.0",
"@ember/test-helpers": "^4.0.2",
"@embroider/test-setup": "^4.0.0",
"@eslint/eslintrc": "^3.2.0",
"@eslint/js": "^9.16.0",
"@glint/environment-ember-loose": "^1.2.1",
"@glint/template": "^1.2.1",
"@tsconfig/ember": "^3.0.2",
Expand All @@ -100,8 +102,6 @@
"@types/ember__utils": "^4.0.5",
"@types/qunit": "^2.19.7",
"@types/rsvp": "^4.0.6",
"@typescript-eslint/eslint-plugin": "^7.0.0",
"@typescript-eslint/parser": "^6.9.1",
"broccoli-asset-rev": "^3.0.0",
"concurrently": "^9.0.1",
"ember-auto-import": "^2.6.3",
Expand All @@ -116,18 +116,20 @@
"ember-source": "~5.11.0",
"ember-source-channel-url": "^3.0.0",
"ember-try": "^3.0.0",
"eslint": "^8.52.0",
"eslint": "^9.16.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-ember": "^12.0.0",
"eslint-plugin-n": "^17.4.0",
"eslint-plugin-ember": "^12.3.3",
"eslint-plugin-n": "^17.14.0",
"eslint-plugin-prettier": "^5.0.1",
"eslint-plugin-qunit": "^8.0.1",
"eslint-plugin-qunit": "^8.1.2",
"globals": "^15.12.0",
"loader.js": "^4.7.0",
"prettier": "^3.0.3",
"qunit": "^2.20.0",
"qunit-dom": "^3.0.0",
"rimraf": "^5.0.1",
"typescript": "^5.2.2",
"typescript-eslint": "^8.16.0",
"webpack": "^5.89.0"
},
"peerDependencies": {
Expand Down
Loading

0 comments on commit a4b389f

Please sign in to comment.