Skip to content

Commit

Permalink
chore: Migrate to ESLint flat config (#7636)
Browse files Browse the repository at this point in the history
* chore: Migrate to ESLint flat config

* Migrate more packages

* angular and solid

* svelte packages

* Hopefully more fixes

* react packages

* vue packages

* Fix typescript errors

* Update Nx config
  • Loading branch information
lachlancollins authored Jun 27, 2024
1 parent 8d75aaa commit e6a0fdd
Show file tree
Hide file tree
Showing 98 changed files with 1,210 additions and 835 deletions.
142 changes: 0 additions & 142 deletions .eslintrc.cjs

This file was deleted.

42 changes: 42 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// @ts-check

// @ts-ignore
import { rootConfig } from '@tanstack/config/eslint'
// @ts-ignore
import cspellConfigs from '@cspell/eslint-plugin/configs'

export default [
...rootConfig,
cspellConfigs.recommended,
{
name: 'tanstack/temp',
rules: {
'@cspell/spellchecker': [
'error',
{
cspell: {
words: [
'codemod', // We support our codemod
'extralight', // Our public interface
'jscodeshift',
'Promisable', // Our public interface
'retryer', // Our public interface
'solidjs', // Our target framework
'tabular-nums', // https://developer.mozilla.org/en-US/docs/Web/CSS/font-variant-numeric
'tanstack', // Our package scope
'todos', // Too general word to be caught as error
'TSES', // @typescript-eslint package's interface
'tsqd', // Our public interface (TanStack Query Devtools shorthand)
'tsup', // We use tsup as builder
'typecheck', // Field of vite.config.ts
'vue-demi', // dependency of @tanstack/vue-query
],
},
},
],
'@typescript-eslint/no-empty-function': 'off',
'no-case-declarations': 'off',
'no-prototype-builtins': 'off',
},
},
]
5 changes: 2 additions & 3 deletions nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"parallel": 5,
"namedInputs": {
"sharedGlobals": [
"{workspaceRoot}/.eslintrc.cjs",
"{workspaceRoot}/.nvmrc",
"{workspaceRoot}/eslint.config.js",
"{workspaceRoot}/package.json",
"{workspaceRoot}/scripts/getTsupConfig.js",
"{workspaceRoot}/tsconfig.json"
Expand All @@ -21,8 +21,7 @@
"default",
"{projectRoot}/build",
"{projectRoot}/dist",
"!{projectRoot}/.eslintrc.cjs",
"!{projectRoot}/tsconfig.eslint.json"
"!{projectRoot}/eslint.config.js"
]
},
"targetDefaults": {
Expand Down
17 changes: 5 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,24 +44,18 @@
"devDependencies": {
"@arethetypeswrong/cli": "^0.15.3",
"@cspell/eslint-plugin": "^8.9.1",
"@eslint-react/eslint-plugin": "^1.5.16",
"@solidjs/testing-library": "^0.8.8",
"@tanstack/config": "^0.7.11",
"@tanstack/config": "^0.8.1",
"@testing-library/jest-dom": "^6.4.5",
"@testing-library/react": "^15.0.7",
"@types/eslint": "^8.56.10",
"@types/node": "^20.12.12",
"@types/react": "npm:types-react@rc",
"@types/react-dom": "npm:types-react-dom@rc",
"@typescript-eslint/eslint-plugin": "^7.13.1",
"@typescript-eslint/parser": "^7.13.1",
"@vitest/coverage-istanbul": "^1.6.0",
"cpy-cli": "^5.0.0",
"esbuild-plugin-file-path-extensions": "^2.1.0",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"eslint-import-resolver-typescript": "^3.6.1",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-react": "^7.34.3",
"eslint-plugin-react-hooks": "^4.6.2",
"husky": "^9.0.11",
"jsdom": "^24.0.0",
Expand All @@ -78,6 +72,7 @@
"solid-js": "^1.8.17",
"tsup": "^8.0.2",
"typescript": "5.3.3",
"typescript-eslint": "^7.14.1",
"typescript47": "npm:[email protected]",
"typescript48": "npm:[email protected]",
"typescript49": "npm:[email protected]",
Expand All @@ -89,11 +84,9 @@
},
"pnpm": {
"overrides": {
"@typescript-eslint/eslint-plugin": "$@typescript-eslint/eslint-plugin",
"@typescript-eslint/parser": "$@typescript-eslint/parser",
"eslint": "$eslint",
"@types/react": "npm:types-react@rc",
"@types/react-dom": "npm:types-react-dom@rc"
"@types/react-dom": "npm:types-react-dom@rc",
"eslint": "$eslint"
}
}
}
15 changes: 0 additions & 15 deletions packages/angular-query-devtools-experimental/.eslintrc.cjs

This file was deleted.

17 changes: 17 additions & 0 deletions packages/angular-query-devtools-experimental/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// @ts-check

import pluginJsdoc from 'eslint-plugin-jsdoc'
import rootConfig from '../../eslint.config.js'

export default [
...rootConfig,
pluginJsdoc.configs['flat/recommended-typescript'],
{
rules: {
'jsdoc/require-hyphen-before-param-description': 1,
'jsdoc/sort-tags': 1,
'jsdoc/require-throws': 1,
'jsdoc/check-tag-names': ['warn'],
},
},
]
2 changes: 1 addition & 1 deletion packages/angular-query-devtools-experimental/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
],
"scripts": {
"clean": "rimraf ./build && rimraf ./coverage",
"test:eslint": "eslint --ext .ts,.tsx ./src",
"test:eslint": "eslint ./src",
"test:types": "pnpm run \"/^test:types:ts[0-9]{2}$/\"",
"test:types:ts51": "node ../../node_modules/typescript51/lib/tsc.js",
"test:types:ts52": "node ../../node_modules/typescript52/lib/tsc.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/angular-query-devtools-experimental/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@
"useDefineForClassFields": false,
"target": "ES2022"
},
"include": ["src", ".eslintrc.cjs", "vite.config.ts"]
"include": ["src", "eslint.config.js", "vite.config.ts"]
}
21 changes: 0 additions & 21 deletions packages/angular-query-experimental/.eslintrc.cjs

This file was deleted.

23 changes: 23 additions & 0 deletions packages/angular-query-experimental/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// @ts-check

import pluginJsdoc from 'eslint-plugin-jsdoc'
import rootConfig from '../../eslint.config.js'

export default [
...rootConfig,
pluginJsdoc.configs['flat/recommended-typescript'],
{
rules: {
'jsdoc/require-hyphen-before-param-description': 1,
'jsdoc/sort-tags': 1,
'jsdoc/require-throws': 1,
'jsdoc/check-tag-names': [
'warn',
{
// Not compatible with Api Extractor @public
typed: false,
},
],
},
},
]
2 changes: 1 addition & 1 deletion packages/angular-query-experimental/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
],
"scripts": {
"clean": "rimraf ./build && rimraf ./coverage",
"test:eslint": "eslint --ext .ts,.tsx ./src",
"test:eslint": "eslint ./src",
"test:types": "pnpm run \"/^test:types:ts[0-9]{2}$/\"",
"test:types:ts50": "node ../../node_modules/typescript50/lib/tsc.js",
"test:types:ts51": "node ../../node_modules/typescript51/lib/tsc.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/angular-query-experimental/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
"target": "ES2022",
"types": ["vitest/globals"]
},
"include": ["src", ".eslintrc.cjs", "vite.config.ts"]
"include": ["src", "eslint.config.js", "vite.config.ts"]
}
6 changes: 0 additions & 6 deletions packages/eslint-plugin-query/.eslintrc.cjs

This file was deleted.

5 changes: 5 additions & 0 deletions packages/eslint-plugin-query/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// @ts-check

import rootConfig from '../../eslint.config.js'

export default [...rootConfig]
2 changes: 1 addition & 1 deletion packages/eslint-plugin-query/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
},
"scripts": {
"clean": "rimraf ./dist && rimraf ./coverage",
"test:eslint": "eslint --ext .ts,.tsx ./src",
"test:eslint": "eslint ./src",
"test:types": "pnpm run \"/^test:types:ts[0-9]{2}$/\"",
"test:types:ts50": "node ../../node_modules/typescript50/lib/tsc.js",
"test:types:ts51": "node ../../node_modules/typescript51/lib/tsc.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin-query/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
"compilerOptions": {
"moduleResolution": "Bundler"
},
"include": ["src", ".eslintrc.cjs", "vite.config.ts"]
"include": ["src", "eslint.config.js", "vite.config.ts"]
}
Loading

0 comments on commit e6a0fdd

Please sign in to comment.