Skip to content

Commit

Permalink
chore: Use typescript-eslint v6 features (#594)
Browse files Browse the repository at this point in the history
* chore: Use typescript-eslint v6 features

* Remove unnecessary parserOptions

* Delete stray prettierrc
  • Loading branch information
lachlancollins authored Feb 3, 2024
1 parent 70e4fdb commit e633c67
Show file tree
Hide file tree
Showing 21 changed files with 163 additions and 118 deletions.
14 changes: 11 additions & 3 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@
/** @type {import('eslint').Linter.Config} */
const config = {
root: true,
reportUnusedDisableDirectives: true,
ignorePatterns: ['**/build', '**/coverage', '**/dist'],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint', 'import'],
extends: [
'plugin:@typescript-eslint/eslint-recommended',
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/stylistic',
'plugin:import/recommended',
'plugin:import/typescript',
'prettier',
Expand All @@ -18,7 +21,7 @@ const config = {
},
parserOptions: {
tsconfigRootDir: __dirname,
project: './tsconfig.json',
project: true,
sourceType: 'module',
ecmaVersion: 2020,
},
Expand All @@ -34,14 +37,17 @@ const config = {
},
},
rules: {
'@typescript-eslint/array-type': 'off',
'@typescript-eslint/ban-types': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/consistent-type-definitions': 'off',
'@typescript-eslint/consistent-type-imports': 'error',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-empty-interface': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-unnecessary-condition': 'error',
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/no-inferrable-types': [
'error',
{
Expand All @@ -52,8 +58,10 @@ const config = {
'import/no-cycle': 'error',
'import/no-unresolved': ['error', { ignore: ['^@tanstack/'] }],
'import/no-unused-modules': ['off', { unusedExports: true }],
'no-async-promise-executor': 'off',
'no-empty': 'off',
'no-redeclare': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'no-undef': 'off',
},
overrides: [
{
Expand Down
4 changes: 0 additions & 4 deletions examples/react/next-server-actions/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
module.exports = {
extends: 'next/core-web-vitals',
parserOptions: {
tsconfigRootDir: __dirname,
project: ['./tsconfig.json'],
},
}
4 changes: 0 additions & 4 deletions examples/react/simple/.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: './tsconfig.json',
},
rules: {
'react/no-children-prop': 'off',
},
Expand Down
9 changes: 1 addition & 8 deletions examples/react/ui-libraries/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,7 @@

/** @type {import('eslint').Linter.Config} */
const config = {
env: { browser: true, es2020: true },
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:react-hooks/recommended',
],
parser: '@typescript-eslint/parser',
parserOptions: { ecmaVersion: 'latest', sourceType: 'module' },
extends: ['plugin:react-hooks/recommended'],
plugins: ['react-refresh'],
rules: {
'react-refresh/only-export-components': 'warn',
Expand Down
4 changes: 0 additions & 4 deletions examples/react/valibot/.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: './tsconfig.json',
},
rules: {
'react/no-children-prop': 'off',
},
Expand Down
4 changes: 0 additions & 4 deletions examples/react/yup/.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: './tsconfig.json',
},
rules: {
'react/no-children-prop': 'off',
},
Expand Down
4 changes: 0 additions & 4 deletions examples/react/zod/.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: './tsconfig.json',
},
rules: {
'react/no-children-prop': 'off',
},
Expand Down
1 change: 0 additions & 1 deletion examples/react/zod/.prettierrc

This file was deleted.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
"@types/node": "^18.19.3",
"@types/react": "^18.2.45",
"@types/react-dom": "^18.0.5",
"@typescript-eslint/eslint-plugin": "^6.4.1",
"@typescript-eslint/parser": "^6.4.1",
"@typescript-eslint/eslint-plugin": "^6.20.0",
"@typescript-eslint/parser": "^6.20.0",
"@vitest/coverage-istanbul": "^1.2.2",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
Expand Down
7 changes: 1 addition & 6 deletions packages/form-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: './tsconfig.json',
},
}
const config = {}

module.exports = config
2 changes: 0 additions & 2 deletions packages/form-core/src/FieldApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,6 @@ export class FieldApi<
this.store = new Store<FieldState<TData>>(
{
value: this.getValue(),
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
meta: this._getMeta() ?? {
isValidating: false,
isTouched: false,
Expand Down Expand Up @@ -424,7 +423,6 @@ export class FieldApi<
>,
) => {
// Default Value
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (this.state.value === undefined) {
const formDefault =
opts.form.options.defaultValues?.[opts.name as keyof TParentData]
Expand Down
2 changes: 0 additions & 2 deletions packages/form-core/src/FormApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,9 +314,7 @@ export class FormApi<
Object.assign(
{},
this.state as any,
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
shouldUpdateState ? options.defaultState : {},
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
shouldUpdateValues
? {
values: options.defaultValues,
Expand Down
4 changes: 0 additions & 4 deletions packages/react-form/.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: './tsconfig.json',
},
rules: {
'react/jsx-key': ['error', { checkFragmentShorthand: true }],
'react-hooks/exhaustive-deps': 'error',
Expand Down
7 changes: 1 addition & 6 deletions packages/solid-form/.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: './tsconfig.json',
},
}
const config = {}

module.exports = config
9 changes: 7 additions & 2 deletions packages/solid-form/src/createField.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FieldApi, type Validator } from '@tanstack/form-core'
import { FieldApi } from '@tanstack/form-core'
import {
createComponent,
createComputed,
Expand All @@ -9,7 +9,12 @@ import {
} from 'solid-js'
import { formContext, useFormContext } from './formContext'

import type { DeepKeys, DeepValue, Narrow } from '@tanstack/form-core'
import type {
DeepKeys,
DeepValue,
Narrow,
Validator,
} from '@tanstack/form-core'
import type { JSXElement } from 'solid-js'
import type { CreateFieldOptions } from './types'

Expand Down
7 changes: 1 addition & 6 deletions packages/valibot-form-adapter/.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: './tsconfig.json',
},
}
const config = {}

module.exports = config
7 changes: 1 addition & 6 deletions packages/vue-form/.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: './tsconfig.json',
},
}
const config = {}

module.exports = config
11 changes: 8 additions & 3 deletions packages/vue-form/src/useField.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import { FieldApi, type Validator } from '@tanstack/form-core'
import type { DeepKeys, DeepValue, Narrow } from '@tanstack/form-core'
import { FieldApi } from '@tanstack/form-core'
import { useStore } from '@tanstack/vue-store'
import { defineComponent, onMounted, onUnmounted, watch } from 'vue'
import type { SlotsType, SetupContext, Ref } from 'vue'
import { provideFormContext, useFormContext } from './formContext'
import type {
DeepKeys,
DeepValue,
Narrow,
Validator,
} from '@tanstack/form-core'
import type { SlotsType, SetupContext, Ref } from 'vue'
import type { UseFieldOptions } from './types'

declare module '@tanstack/form-core' {
Expand Down
7 changes: 1 addition & 6 deletions packages/yup-form-adapter/.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: './tsconfig.json',
},
}
const config = {}

module.exports = config
7 changes: 1 addition & 6 deletions packages/zod-form-adapter/.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: './tsconfig.json',
},
}
const config = {}

module.exports = config
Loading

0 comments on commit e633c67

Please sign in to comment.