Skip to content

Commit 8c695b1

Browse files
committed
Updates to ESLint setup
1 parent 1c54a8c commit 8c695b1

File tree

13 files changed

+59
-64
lines changed

13 files changed

+59
-64
lines changed

config/tsconfig/base.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"lib": ["dom", "es2022"],
1111
"module": "es2022",
1212
"moduleResolution": "node",
13+
"noEmit": true,
1314
"noUnusedLocals": false,
1415
"noUnusedParameters": false,
1516
"preserveWatchOutput": true,

eslint.config.mjs

Lines changed: 20 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {defineConfig, globalIgnores} from 'eslint/config'
1+
import {defineConfig} from 'eslint/config'
22
import globals from 'globals'
33
import jsPlugin from '@eslint/js'
44
import tsPlugin from 'typescript-eslint'
@@ -7,56 +7,43 @@ import prettierPlugin from 'eslint-plugin-prettier/recommended'
77

88
export default defineConfig([
99
{
10-
files: ['**/*.{js,mjs,cjs,ts,jsx,tsx}'],
10+
name: 'global ignores',
11+
ignores: ['**/coverage/**/*', '**/dist/**/*', 'docs/.vitepress/dist/**/*', 'docs/.vitepress/cache/**/*'],
1112
},
1213

13-
globalIgnores(['**/coverage/**/*', '**/dist/**/*', 'docs/.vitepress/dist/**/*', 'docs/.vitepress/cache/**/*']),
14+
{
15+
name: 'js recommended',
16+
...jsPlugin.configs.recommended,
17+
},
1418

15-
jsPlugin.configs.recommended,
19+
...tsPlugin.configs.recommendedTypeChecked,
1620

1721
{
18-
files: ['examples/react/**/*.{ts,tsx}'],
19-
languageOptions: {
20-
parserOptions: {
21-
project: 'examples/react/tsconfig.eslint.json',
22-
tsconfigRootDir: import.meta.dirname,
23-
},
24-
},
22+
name: 'react recommended',
23+
...reactPlugin.configs.flat.recommended,
2524
},
2625

2726
{
28-
files: ['packages/core/**/*.{ts,tsx}'],
29-
languageOptions: {
30-
parserOptions: {
31-
project: 'packages/core/tsconfig.eslint.json',
32-
tsconfigRootDir: import.meta.dirname,
33-
},
34-
},
27+
name: 'react jsx runtime',
28+
...reactPlugin.configs.flat['jsx-runtime'],
3529
},
3630

31+
prettierPlugin,
32+
3733
{
38-
files: ['packages/react/**/*.{ts,tsx}'],
34+
name: 'ts configuration',
35+
files: ['**/*.{ts,tsx}'],
3936
languageOptions: {
4037
parserOptions: {
41-
project: 'packages/react/tsconfig.eslint.json',
38+
projectService: true,
4239
tsconfigRootDir: import.meta.dirname,
4340
},
4441
},
45-
},
46-
47-
...tsPlugin.configs.recommendedTypeChecked.map(config => ({
48-
...config,
49-
files: ['**/*.{ts,tsx}'],
5042
rules: {
5143
'no-unused-vars': 'off',
5244

5345
'@typescript-eslint/consistent-type-imports': 'error',
5446
'@typescript-eslint/consistent-type-exports': 'error',
55-
'@typescript-eslint/no-unsafe-assignment': 'off',
56-
'@typescript-eslint/no-unsafe-return': 'off',
57-
'@typescript-eslint/no-unsafe-member-access': 'off',
58-
'@typescript-eslint/no-unsafe-argument': 'off',
59-
'@typescript-eslint/no-explicit-any': 'off',
6047
'@typescript-eslint/no-unused-vars': [
6148
'error',
6249
{
@@ -66,14 +53,11 @@ export default defineConfig([
6653
},
6754
],
6855
},
69-
})),
70-
71-
reactPlugin.configs.flat.recommended,
72-
reactPlugin.configs.flat['jsx-runtime'],
73-
74-
prettierPlugin,
56+
},
7557

7658
{
59+
name: 'global configuration',
60+
7761
languageOptions: {
7862
...reactPlugin.configs.flat.recommended.languageOptions,
7963

examples/react/tsconfig.eslint.json

Lines changed: 0 additions & 4 deletions
This file was deleted.

examples/react/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"extends": "@formulier/tsconfig/base",
3-
"include": ["src/**/*"],
3+
"include": ["src/**/*", "vite.config.ts"],
44
"compilerOptions": {
55
"jsx": "react-jsx"
66
}

packages/core/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@
3434
"types": "./dist/index.d.ts"
3535
},
3636
"scripts": {
37-
"build": "tsc",
38-
"dev": "tsup --watch",
39-
"typecheck": "tsc --noEmit",
37+
"build": "tsc --project tsconfig.build.json",
38+
"dev": "tsup --project tsconfig.build.json --watch",
39+
"typecheck": "tsc",
4040
"test": "vitest run",
4141
"coverage": "vitest run --coverage"
4242
},

packages/core/src/state-utils.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
import clone from 'shallow-clone'
22
import isEqual from 'lodash.isequal'
33

4+
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
5+
/* eslint-disable @typescript-eslint/no-unsafe-return */
6+
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
7+
/* eslint-disable @typescript-eslint/no-explicit-any */
8+
49
// Originally taken from https://github.com/jaredpalmer/formik/blob/master/packages/formik/src/utils.ts
510
function getPath(source: any, path: string | string[], fallback?: any) {
611
let p = 0
@@ -50,6 +55,11 @@ function setPath(obj: any, path: string, value: any): any {
5055
return res
5156
}
5257

58+
/* eslint-enable @typescript-eslint/no-unsafe-member-access */
59+
/* eslint-enable @typescript-eslint/no-unsafe-return */
60+
/* eslint-enable @typescript-eslint/no-unsafe-assignment */
61+
/* eslint-enable @typescript-eslint/no-explicit-any */
62+
5363
function setKey<T extends Record<string, unknown>>(source: T, key: string, value: unknown): T {
5464
if (isEqual(source[key], value)) {
5565
return source

packages/core/tsconfig.build.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"extends": "@formulier/tsconfig/base",
3+
"include": ["src/**/*"],
4+
"compilerOptions": {
5+
"noEmit": false,
6+
"outDir": "dist"
7+
}
8+
}

packages/core/tsconfig.eslint.json

Lines changed: 0 additions & 4 deletions
This file was deleted.

packages/core/tsconfig.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
{
22
"extends": "@formulier/tsconfig/base",
3-
"include": ["src/**/*"],
3+
"include": ["src/**/*", "tests/**/*", "vitest.config.ts"],
44
"compilerOptions": {
5-
"outDir": "dist",
65
"types": ["vitest/importMeta"]
76
}
87
}

packages/react/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@
4040
"types": "./dist/index.d.ts"
4141
},
4242
"scripts": {
43-
"build": "tsc",
44-
"dev": "tsup --watch",
45-
"typecheck": "tsc --noEmit",
43+
"build": "tsc --project tsconfig.build.json",
44+
"dev": "tsup --project tsconfig.build.json --watch",
45+
"typecheck": "tsc",
4646
"test": "vitest run",
4747
"coverage": "vitest run --coverage",
4848
"e2e": "cypress run --component --browser chrome"

0 commit comments

Comments
 (0)