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(eslint): migrate to flat config and simplify #2912

Merged
merged 41 commits into from
Dec 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
2be510b
chore(package.json): update related eslint library, update script for…
sukvvon Dec 18, 2024
7c7d3f1
chore(pnpm-lock.yaml): reflect changes in package.json
sukvvon Dec 18, 2024
e11e20d
chore(eslint): migrate eslint configuration .eslintrc.json to eslint.…
sukvvon Dec 18, 2024
a3ab23e
chore(examples/demo/package.json): update related eslint library, upd…
sukvvon Dec 18, 2024
437a2fa
chore(examples/demo/pnpm-lock.yaml): reflect changes in package.json
sukvvon Dec 18, 2024
e9f53b7
chore(examples/demo/eslint): migrate eslint configuration .eslintrc.c…
sukvvon Dec 18, 2024
d1631be
style(examples/demo/utils/copy-to-clipboard.js): add global comment f…
sukvvon Dec 18, 2024
2d06cbe
Merge branch 'main' into chore/migrate-eslintrc-to-eslint-config
sukvvon Dec 19, 2024
69bac4f
Merge branch 'main' into chore/migrate-eslintrc-to-eslint-config
sukvvon Dec 20, 2024
b95e8c6
chore(eslint): change file extension 'js' to 'mjs'
sukvvon Dec 23, 2024
195023e
chore(package.json): consise 'lint' scripts
sukvvon Dec 23, 2024
89343ed
chore(examples/demo): remove eslint.config.js
sukvvon Dec 23, 2024
9921569
chore(examples/demo/package.json): remove libraries associated wiht e…
sukvvon Dec 23, 2024
6417fbf
chore(examples/demo/pnpm-lock.yaml): reflect changes in package.json
sukvvon Dec 23, 2024
fdae5d6
chore(examples/demo): reflect 'eslint . --fix' changes based on main …
sukvvon Dec 23, 2024
0157470
chore(examples/demo/package.json): add libraries associated wiht esli…
sukvvon Dec 23, 2024
3a5fe71
chore(examples/demo/pnpm-lock.yaml): reflect changes in package.json
sukvvon Dec 23, 2024
b30ccf4
chore(examples/demo): add eslint.config.js
sukvvon Dec 23, 2024
c2371f8
chore(package.json): add mjs in 'eslint', 'test:lint' script
sukvvon Dec 23, 2024
51962a3
Update eslint.config.mjs
sukvvon Dec 23, 2024
989ec56
Update examples/demo/eslint.config.js
sukvvon Dec 23, 2024
f8cef86
chore(eslint): remove eslint configuration related to prettier
sukvvon Dec 23, 2024
c1bdb30
chore(package.json): remove eslint-{config,plugin}-prettier
sukvvon Dec 23, 2024
6dfa097
chore(package.json): add tslib in devDependencies
sukvvon Dec 23, 2024
ad8bae0
chore(eslint): remove duplicate shared-node-browser from globals
sukvvon Dec 24, 2024
a2355a5
chore(eslint): change 'eslint-import-resolver-alias' to 'eslint-impor…
sukvvon Dec 24, 2024
5e6610e
chore(eslint): add 'import/no-named-as-default-member' off
sukvvon Dec 24, 2024
bb02a1b
chore(eslint): remove duplicate rules, rearrange sequentially within …
sukvvon Dec 25, 2024
82662b8
chore(eslint): remove the ‘off’ settings in ‘eslint-plugin-import’ to…
sukvvon Dec 25, 2024
0011e52
chore(eslint): remove 'no-console' in rules
sukvvon Dec 25, 2024
637ee55
chore(eslint): simplify settings 'import/resolver'
sukvvon Dec 26, 2024
9198ed5
chore(eslint): remove 'globals' config
sukvvon Dec 26, 2024
a6c3ab8
chore(rollup): add 'eslint-disable no-undef'
sukvvon Dec 26, 2024
d04d615
chore(package.json): remove 'globals' library
sukvvon Dec 26, 2024
848740c
chore(pnpm-lock.yaml): reflect changes in package.json
sukvvon Dec 26, 2024
11bc794
chore(eslint): add 'importPlugin.flatConfigs.recommended'
sukvvon Dec 27, 2024
17e30f8
chore(eslint): remove duplicate 'languageOptions'
sukvvon Dec 27, 2024
0091498
chore(eslint): remove 'import/extensions', 'import/parsers' to simplify
sukvvon Dec 29, 2024
4232740
Merge branch 'main' into chore/migrate-eslintrc-to-eslint-config
sukvvon Dec 29, 2024
7662607
chore(eslint): add 'examples/**' in 'ignores'
sukvvon Dec 29, 2024
eb925c7
chore(package.json): simplify 'lint' scripts
sukvvon Dec 29, 2024
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
122 changes: 0 additions & 122 deletions .eslintrc.json

This file was deleted.

103 changes: 103 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
import eslint from '@eslint/js'
import vitest from '@vitest/eslint-plugin'
import importPlugin from 'eslint-plugin-import'
import jestDom from 'eslint-plugin-jest-dom'
import react from 'eslint-plugin-react'
import reactCompiler from 'eslint-plugin-react-compiler'
import reactHooks from 'eslint-plugin-react-hooks'
import testingLibrary from 'eslint-plugin-testing-library'
import tseslint from 'typescript-eslint'

export default tseslint.config(
{
ignores: ['**/dist/', 'examples/**'],
},
eslint.configs.recommended,
importPlugin.flatConfigs.recommended,
tseslint.configs.recommended,
react.configs.flat.recommended,
react.configs.flat['jsx-runtime'],
sukvvon marked this conversation as resolved.
Show resolved Hide resolved
{
plugins: {
'react-compiler': reactCompiler,
'react-hooks': reactHooks,
},
settings: {
react: {
version: 'detect',
},
'import/resolver': {
typescript: true,
},
},
rules: {
eqeqeq: 'error',
sukvvon marked this conversation as resolved.
Show resolved Hide resolved
curly: ['warn', 'multi-line', 'consistent'],
'sort-imports': [
'error',
{
ignoreDeclarationSort: true,
},
],
'import/no-unresolved': ['error', { commonjs: true, amd: true }],
'import/named': 'off',
'import/namespace': 'off',
'import/no-named-as-default-member': 'off',
'import/no-duplicates': 'error',
'import/extensions': ['error', 'always'],
'import/order': [
'error',
{
alphabetize: { order: 'asc', caseInsensitive: true },
groups: [
'builtin',
'external',
'internal',
'parent',
'sibling',
'index',
'object',
],
'newlines-between': 'never',
pathGroups: [
{
pattern: 'react',
group: 'builtin',
position: 'before',
},
],
pathGroupsExcludedImportTypes: ['builtin'],
},
],
'@typescript-eslint/no-unused-vars': [
'warn',
{ argsIgnorePattern: '^_', varsIgnorePattern: '^_' },
],
'@typescript-eslint/no-explicit-any': 'off',
...reactHooks.configs.recommended.rules,
'react-compiler/react-compiler': 'warn',
},
},
{
files: ['tests/**/*.{ts,tsx}'],
...testingLibrary.configs['flat/react'],
...jestDom.configs['flat/recommended'],
...vitest.configs.recommended,
rules: {
'import/extensions': ['error', 'never'],
'testing-library/no-node-access': 'off',
'vitest/expect-expect': 'off',
'vitest/consistent-test-it': [
'error',
{ fn: 'it', withinDescribe: 'it' },
],
'@typescript-eslint/no-unused-vars': 'off',
},
},
{
files: ['*.js'],
rules: {
'@typescript-eslint/no-require-imports': 'off',
},
},
)
16 changes: 0 additions & 16 deletions examples/demo/.eslintrc.cjs

This file was deleted.

44 changes: 44 additions & 0 deletions examples/demo/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import eslint from '@eslint/js'
import react from 'eslint-plugin-react'
import reactHooks from 'eslint-plugin-react-hooks'
import reactRefresh from 'eslint-plugin-react-refresh'
import globals from 'globals'

export default [
{
ignores: ['dist'],
},
Comment on lines +8 to +10
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Add ignores

eslint.configs.recommended,
react.configs.flat.recommended,
react.configs.flat['jsx-runtime'],
{
languageOptions: {
globals: {
...globals.browser,
...globals.es2020,
},
Comment on lines +16 to +19
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Add globals, it's related .eslintrc.cjs that is removed

parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
},
},
plugins: {
'react-hooks': reactHooks,
'react-refresh': reactRefresh,
},
settings: {
react: {
version: 'detect',
},
},
rules: {
...reactHooks.configs.recommended.rules,
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
'react/prop-types': 'off',
'react/no-unknown-property': ['off'],
},
},
]
12 changes: 7 additions & 5 deletions examples/demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"scripts": {
"dev": "vite",
"build": "vite build",
"lint": "eslint src --ext js,jsx --report-unused-disable-directives --max-warnings 0",
"lint": "eslint .",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Concise eslint script

"preview": "vite preview"
},
"prettier": {
Expand All @@ -29,13 +29,15 @@
"zustand": "^4.3.9"
},
"devDependencies": {
"@eslint/js": "^9.17.0",
"@types/react": "^18.2.14",
"@types/react-dom": "^18.2.6",
"@vitejs/plugin-react-swc": "^3.3.2",
"eslint": "^8.44.0",
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.1",
"eslint": "^9.17.0",
"eslint-plugin-react": "^7.37.2",
"eslint-plugin-react-hooks": "^5.1.0",
"eslint-plugin-react-refresh": "^0.4.16",
"globals": "^15.14.0",
"vite": "^4.4.0"
}
}
Loading
Loading