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

chore: migrate eslint to flat config #2212

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 0 additions & 39 deletions .eslintrc.js

This file was deleted.

59 changes: 59 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// @ts-check
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any chance the config can be written in TypeScript?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can indeed. Although only through an unstable_ flag in eslint. see here

Pull in the unstable flag (and jiti dev dependency) or leave as js?


import eslint from '@eslint/js'
import tseslint from 'typescript-eslint'
import eslintConfigPrettier from 'eslint-config-prettier'
import eslintPluginPrettier from 'eslint-plugin-prettier/recommended'

export default tseslint.config(
eslint.configs.recommended,
eslintConfigPrettier,
...tseslint.configs.recommended,
{
languageOptions: {
parserOptions: { ecmaVersion: 2020, sourceType: 'module' },
},
rules: {
'no-console': [
'error',
{
allow: [
'log',
'warn',
'error',
'group',
'groupCollapsed',
'groupEnd',
],
},
],
'@typescript-eslint/prefer-ts-expect-error': 'error',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/no-namespace': [
'error',
{
allowDeclarations: true,
},
],
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/no-unused-vars': [
'error',
{
varsIgnorePattern: '^_',
argsIgnorePattern: '^_',
},
],
},
},
// Unused variables are useful in test files, and type test files
{
files: ['**/*.test.ts', '**/*.test-d.ts'],
rules: {
'@typescript-eslint/no-unused-vars': 'off',
},
},
// @ts-expect-error tseslint adds strict typing to this configuration, eslint-plugin-prettier has an incompatible type
eslintPluginPrettier,
)
10 changes: 7 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -154,17 +154,20 @@
"devDependencies": {
"@commitlint/cli": "^18.4.4",
"@commitlint/config-conventional": "^18.4.4",
"@eslint/eslintrc": "^3.1.0",
"@eslint/js": "^9.7.0",
"@open-draft/test-server": "^0.4.2",
"@ossjs/release": "^0.8.1",
"@playwright/test": "^1.40.1",
"@swc/core": "^1.3.102",
"@types/eslint__js": "^8.42.3",
"@types/express": "^4.17.21",
"@types/fs-extra": "^11.0.4",
"@types/glob": "^8.1.0",
"@types/json-bigint": "^1.0.4",
"@types/node": "18.x",
"@typescript-eslint/eslint-plugin": "^7.2.0",
"@typescript-eslint/parser": "^7.2.0",
"@typescript-eslint/eslint-plugin": "^7.16.1",
"@typescript-eslint/parser": "^7.16.1",
"@web/dev-server": "^0.1.38",
"axios": "^1.6.5",
"babel-minify": "^0.5.1",
Expand All @@ -176,7 +179,7 @@
"esbuild-loader": "^4.0.2",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-prettier": "^5.2.1",
"express": "^4.18.2",
"fs-extra": "^11.2.0",
"fs-teardown": "^0.3.0",
Expand All @@ -192,6 +195,7 @@
"ts-node": "^10.9.2",
"tsup": "^8.0.1",
"typescript": "^5.5.2",
"typescript-eslint": "^7.16.1",
"undici": "^5.20.0",
"url-loader": "^4.1.1",
"vitest": "^1.2.2",
Expand Down
Loading
Loading