Skip to content

Commit

Permalink
chore: Add recommended eslint rules, dedupe parserOptions (#6865)
Browse files Browse the repository at this point in the history
  • Loading branch information
lachlancollins committed Feb 10, 2024
1 parent 5bdeff7 commit 8cd6441
Show file tree
Hide file tree
Showing 61 changed files with 51 additions and 200 deletions.
1 change: 0 additions & 1 deletion .eslintignore

This file was deleted.

8 changes: 7 additions & 1 deletion .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
/** @type {import('eslint').Linter.Config} */
const config = {
root: true,
reportUnusedDisableDirectives: true,
ignorePatterns: ['**/build', '**/coverage', '**/dist'],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint', 'import'],
extends: [
'eslint:recommended',
'plugin:@cspell/recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'plugin:import/recommended',
'plugin:import/typescript',
Expand Down Expand Up @@ -115,8 +117,12 @@ const config = {
],
},
],
'no-case-declarations': 'off',
'no-empty': 'off',
'no-prototype-builtins': 'off',
'no-redeclare': 'off',
'no-shadow': 'error',
'no-undef': 'off',
'sort-imports': ['error', { ignoreDeclarationSort: true }],
},
overrides: [
Expand Down
7 changes: 1 addition & 6 deletions examples/angular/basic/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
// @ts-check

/** @type {import('eslint').Linter.Config} */
const config = {
parserOptions: {
tsconfigRootDir: __dirname,
project: true,
},
}
const config = {}

module.exports = config
7 changes: 1 addition & 6 deletions examples/angular/default-query-function/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
// @ts-check

/** @type {import('eslint').Linter.Config} */
const config = {
parserOptions: {
tsconfigRootDir: __dirname,
project: true,
},
}
const config = {}

module.exports = config
7 changes: 1 addition & 6 deletions examples/angular/simple/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
// @ts-check

/** @type {import('eslint').Linter.Config} */
const config = {
parserOptions: {
tsconfigRootDir: __dirname,
project: true,
},
}
const config = {}

module.exports = config
5 changes: 0 additions & 5 deletions examples/solid/basic-graphql-request/.eslintrc

This file was deleted.

6 changes: 6 additions & 0 deletions examples/solid/basic-graphql-request/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// @ts-check

/** @type {import('eslint').Linter.Config} */
const config = {}

module.exports = config
5 changes: 0 additions & 5 deletions examples/solid/basic-typescript/.eslintrc

This file was deleted.

6 changes: 6 additions & 0 deletions examples/solid/basic-typescript/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// @ts-check

/** @type {import('eslint').Linter.Config} */
const config = {}

module.exports = config
5 changes: 0 additions & 5 deletions examples/solid/default-query-function/.eslintrc

This file was deleted.

6 changes: 6 additions & 0 deletions examples/solid/default-query-function/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// @ts-check

/** @type {import('eslint').Linter.Config} */
const config = {}

module.exports = config
6 changes: 0 additions & 6 deletions examples/solid/simple/.eslintrc

This file was deleted.

8 changes: 8 additions & 0 deletions examples/solid/simple/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// @ts-check

/** @type {import('eslint').Linter.Config} */
const config = {
extends: ['plugin:@tanstack/eslint-plugin-query/recommended'],
}

module.exports = config
2 changes: 1 addition & 1 deletion examples/solid/simple/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
},
"include": ["src"]
"include": ["src", ".eslintrc.cjs", "vite.config.ts"]
}
4 changes: 0 additions & 4 deletions integrations/react-cra4/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ module.exports = {
'plugin:react/recommended',
'plugin:react-hooks/recommended',
],
parserOptions: {
tsconfigRootDir: __dirname,
project: true,
},
settings: {
react: {
version: 'detect',
Expand Down
4 changes: 0 additions & 4 deletions integrations/react-cra5/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ module.exports = {
'plugin:react/recommended',
'plugin:react-hooks/recommended',
],
parserOptions: {
tsconfigRootDir: __dirname,
project: true,
},
settings: {
react: {
version: 'detect',
Expand Down
4 changes: 0 additions & 4 deletions integrations/react-next/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ module.exports = {
'plugin:react/recommended',
'plugin:react-hooks/recommended',
],
parserOptions: {
tsconfigRootDir: __dirname,
project: true,
},
settings: {
react: {
version: 'detect',
Expand Down
4 changes: 0 additions & 4 deletions integrations/react-vite/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ module.exports = {
'plugin:react/recommended',
'plugin:react-hooks/recommended',
],
parserOptions: {
tsconfigRootDir: __dirname,
project: true,
},
settings: {
react: {
version: 'detect',
Expand Down
7 changes: 1 addition & 6 deletions packages/angular-query-devtools-experimental/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
// @ts-check

/** @type {import('eslint').Linter.Config} */
const config = {
parserOptions: {
tsconfigRootDir: __dirname,
project: true,
},
}
const config = {}

module.exports = config
7 changes: 1 addition & 6 deletions packages/angular-query-experimental/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
// @ts-check

/** @type {import('eslint').Linter.Config} */
const config = {
parserOptions: {
tsconfigRootDir: __dirname,
project: true,
},
}
const config = {}

module.exports = config
1 change: 0 additions & 1 deletion packages/angular-query-experimental/src/inject-mutation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,4 @@ export function injectMutation<
})
}

// eslint-disable-next-line @typescript-eslint/no-empty-function
function noop() {}
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@ export function createNoopInjectionToken<
(options || {}) as CreateProvideFnOptions<() => void, []>,
) as CreateInjectionTokenReturn<TReturn, true>[1],
token,
// eslint-disable-next-line @typescript-eslint/no-empty-function
() => {},
] as CreateInjectionTokenReturn<TReturn, true>
}
4 changes: 0 additions & 4 deletions packages/codemods/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@

/** @type {import('eslint').Linter.Config} */
const config = {
parserOptions: {
tsconfigRootDir: __dirname,
project: true,
},
overrides: [
{
files: ['**/__testfixtures__/*'],
Expand Down
7 changes: 1 addition & 6 deletions packages/eslint-plugin-query/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
// @ts-check

/** @type {import('eslint').Linter.Config} */
const config = {
parserOptions: {
tsconfigRootDir: __dirname,
project: true,
},
}
const config = {}

module.exports = config
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ ruleTester.run('exhaustive-deps', rule, {
},
{
name: 'should pass when deps are passed in template literal',
// eslint-disable-next-line no-template-curly-in-string
code: 'useQuery({ queryKey: [`entity/${id}`], queryFn: () => api.getEntity(id) });',
},
{
Expand Down Expand Up @@ -464,7 +463,6 @@ ruleTester.run('exhaustive-deps', rule, {
suggestions: [
{
messageId: 'fixTo',
// eslint-disable-next-line no-template-curly-in-string
data: { result: '["entity/${id}", id]' },
output: normalizeIndent`
const id = 1;
Expand All @@ -489,7 +487,6 @@ ruleTester.run('exhaustive-deps', rule, {
suggestions: [
{
messageId: 'fixTo',
// eslint-disable-next-line no-template-curly-in-string
data: { result: '[`entity/${a}`, b]' },
output: normalizeIndent`
const a = 1;
Expand Down
7 changes: 1 addition & 6 deletions packages/query-async-storage-persister/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
// @ts-check

/** @type {import('eslint').Linter.Config} */
const config = {
parserOptions: {
tsconfigRootDir: __dirname,
project: true,
},
}
const config = {}

module.exports = config
1 change: 0 additions & 1 deletion packages/query-async-storage-persister/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,5 +100,4 @@ export const createAsyncStoragePersister = ({
}
}

// eslint-disable-next-line @typescript-eslint/no-empty-function
function noop() {}
7 changes: 1 addition & 6 deletions packages/query-broadcast-client-experimental/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
// @ts-check

/** @type {import('eslint').Linter.Config} */
const config = {
parserOptions: {
tsconfigRootDir: __dirname,
project: true,
},
}
const config = {}

module.exports = config
7 changes: 1 addition & 6 deletions packages/query-core/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
// @ts-check

/** @type {import('eslint').Linter.Config} */
const config = {
parserOptions: {
tsconfigRootDir: __dirname,
project: true,
},
}
const config = {}

module.exports = config
1 change: 0 additions & 1 deletion packages/query-core/src/infiniteQueryObserver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ export class InfiniteQueryObserver<
fetchOptions: ObserverFetchOptions,
) => Promise<InfiniteQueryObserverResult<TData, TError>>

// eslint-disable-next-line @typescript-eslint/no-useless-constructor
constructor(
client: QueryClient,
options: InfiniteQueryObserverOptions<
Expand Down
7 changes: 1 addition & 6 deletions packages/query-devtools/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
// @ts-check

/** @type {import('eslint').Linter.Config} */
const config = {
parserOptions: {
tsconfigRootDir: __dirname,
project: true,
},
}
const config = {}

module.exports = config
3 changes: 0 additions & 3 deletions packages/query-devtools/src/Devtools.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1567,7 +1567,6 @@ const QueryDetails = () => {

const handleRefetch = () => {
const promise = activeQuery()?.fetch()
// eslint-disable-next-line @typescript-eslint/no-empty-function
promise?.catch(() => {})
}

Expand All @@ -1581,7 +1580,6 @@ const QueryDetails = () => {
activeQuery()!.setState({
status: 'error',
error,
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
fetchMeta: {
...activeQuery()!.state.fetchMeta,
__previousQueryOptions,
Expand Down Expand Up @@ -1769,7 +1767,6 @@ const QueryDetails = () => {
activeQueryVal.setState({
data: undefined,
status: 'pending',
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
fetchMeta: {
...activeQueryVal.state.fetchMeta,
__previousQueryOptions,
Expand Down
7 changes: 1 addition & 6 deletions packages/query-persist-client-core/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
// @ts-check

/** @type {import('eslint').Linter.Config} */
const config = {
parserOptions: {
tsconfigRootDir: __dirname,
project: true,
},
}
const config = {}

module.exports = config
7 changes: 1 addition & 6 deletions packages/query-sync-storage-persister/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
// @ts-check

/** @type {import('eslint').Linter.Config} */
const config = {
parserOptions: {
tsconfigRootDir: __dirname,
project: true,
},
}
const config = {}

module.exports = config
1 change: 0 additions & 1 deletion packages/query-sync-storage-persister/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,5 +109,4 @@ function throttle<TArgs extends Array<any>>(
}
}

// eslint-disable-next-line @typescript-eslint/no-empty-function
function noop() {}
4 changes: 0 additions & 4 deletions packages/react-query-devtools/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
/** @type {import('eslint').Linter.Config} */
const config = {
extends: ['plugin:react/recommended', 'plugin:react-hooks/recommended'],
parserOptions: {
tsconfigRootDir: __dirname,
project: true,
},
rules: {
'react/jsx-key': ['error', { checkFragmentShorthand: true }],
'react-hooks/exhaustive-deps': 'error',
Expand Down

0 comments on commit 8cd6441

Please sign in to comment.