Skip to content

Commit 48c2ba2

Browse files
authored
chore: upgrade cli eslint to 9 (#32446)
* chore: replace dtslint with eslint-plugin-expect-type * update guide * add lint-staged * rm stale script * modify cli eslint and tsconfigs to support ts migration * separate expect-type files * modifications to tsconfigs to make eslint a little easier * revert workflow.yml * further revision * put tslint config for dtslint back in * ensure false negative case is tested * correct tsconfigs * align dtslint tsconfig with eslint 9 config * consolidate / DRY tsconfigs
1 parent 9da952a commit 48c2ba2

19 files changed

+281
-159
lines changed

cli/.eslintignore

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

cli/.eslintrc.json

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

cli/eslint.config.ts

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import { baseConfig, cliOverrides } from '@packages/eslint-config'
2+
3+
export default [
4+
...baseConfig,
5+
...cliOverrides,
6+
{
7+
languageOptions: {
8+
parserOptions: {
9+
tsconfigRootDir: __dirname,
10+
},
11+
},
12+
},
13+
{
14+
rules: {
15+
'@stylistic/comma-dangle': 'warn',
16+
'@stylistic/comma-spacing': 'warn',
17+
'@stylistic/type-generic-spacing': 'warn',
18+
'@stylistic/quotes': 'warn',
19+
'@stylistic/arrow-parens': 'warn',
20+
'@stylistic/no-multi-spaces': 'warn',
21+
'padding-line-between-statements': 'warn',
22+
'@stylistic/space-unary-ops': 'warn',
23+
'@stylistic/member-delimiter-style': 'warn',
24+
'@stylistic/object-curly-spacing': 'warn',
25+
'@stylistic/semi': 'warn',
26+
'@stylistic/space-in-parens': 'warn',
27+
'@stylistic/space-infix-ops': 'warn',
28+
'@stylistic/template-tag-spacing': 'warn',
29+
'no-var': 'warn',
30+
'@stylistic/space-before-function-paren': ['warn', 'always'],
31+
},
32+
},
33+
{
34+
ignores: [
35+
'**/__snapshots__',
36+
'**/build/**/*',
37+
'package.json',
38+
'**/angular/**/*',
39+
'**/react/**/*',
40+
'**/vue/**/*',
41+
'**/svelte/**/*',
42+
'**/mount-utils/**/*',
43+
'**/types/{bluebird,chai,chai-jquery,jquery,lodash,minimatch,mocha,sinon,sinon-chai}/**/*',
44+
'.mocharc.js',
45+
'**/*.js',
46+
],
47+
},
48+
]

cli/package.json

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
"private": true,
55
"main": "dist/index.js",
66
"scripts": {
7-
"build-cli": "tsc && tsc -p tsconfig.esm.json && tsx ./scripts/build.ts && tsx ./scripts/post-build.ts",
7+
"build-cli": "tsc -p tsconfig.build.json && tsc -p tsconfig.esm.json && tsx ./scripts/build.ts && tsx ./scripts/post-build.ts",
88
"clean": "tsx ./scripts/clean.ts",
99
"dtslint": "dtslint types",
1010
"postinstall": "patch-package && tsx ./scripts/post-install.ts",
11-
"lint": "eslint --ext .ts,.tsx,.json,.vue .",
11+
"lint": "eslint",
1212
"prebuild": "yarn postinstall && tsx ./scripts/start-build.ts",
1313
"size": "t=\"cypress-v0.0.0.tgz\"; yarn pack --filename \"${t}\"; wc -c \"${t}\"; tar tvf \"${t}\"; rm \"${t}\";",
1414
"test": "yarn test-unit",
@@ -70,6 +70,7 @@
7070
"@cypress/sinon-chai": "2.9.1",
7171
"@cypress/svelte": "0.0.0-development",
7272
"@cypress/vue": "0.0.0-development",
73+
"@packages/eslint-config": "0.0.0-development",
7374
"@packages/root": "0.0.0-development",
7475
"@types/bluebird": "3.5.33",
7576
"@types/chai": "4.2.15",
@@ -83,7 +84,9 @@
8384
"cross-env": "7.0.3",
8485
"dependency-check": "4.1.0",
8586
"dtslint": "4.2.1",
87+
"eslint": "^9.31.0",
8688
"execa-wrap": "1.4.0",
89+
"jiti": "^2.4.2",
8790
"mock-fs": "5.4.0",
8891
"nock": "13.2.9",
8992
"resolve-pkg": "2.0.0",
@@ -151,9 +154,13 @@
151154
"workspaces": {
152155
"nohoist": [
153156
"@types/*",
157+
"eslint-plugin-expect-type",
154158
"tsx"
155159
]
156160
},
161+
"lint-staged": {
162+
"**/*.{js,jsx,ts,tsx,json,vue}": "eslint --fix"
163+
},
157164
"nx": {
158165
"targets": {
159166
"build-cli": {

cli/scripts/build.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,9 @@ export default makeUserPackageFile
7474
if (require.main === module) {
7575
makeUserPackageFile(process.env.BRANCH)
7676
.catch((err: any) => {
77-
/* eslint-disable no-console */
7877
console.error('Could not write user package file')
7978
console.error(err)
80-
/* eslint-enable no-console */
79+
8180
process.exit(-1)
8281
})
8382
}

cli/scripts/post-install.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env node
22

33
// @ts-check
4-
/* eslint-disable no-console */
4+
55
import fs from 'fs-extra'
66
import { includeTypes } from './utils'
77
import shell from 'shelljs'

cli/scripts/start-build.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ includeTypes.forEach((folder: string) => {
2323
})
2424

2525
// build the project and copy the build files over to the build directory
26-
shell.exec('tsc -p tsconfig.json')
26+
shell.exec('tsc -p tsconfig.build.json')
2727
shell.exec('tsc -p tsconfig.esm.json')
2828

2929
shell.mkdir('-p', 'build/dist')

cli/scripts/tsconfig.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"compilerOptions": {
3+
"module": "commonjs",
4+
"lib": [
5+
"node",
6+
],
7+
"exactOptionalPropertyTypes": true,
8+
"noImplicitAny": true,
9+
"noImplicitThis": true,
10+
"strictNullChecks": true,
11+
"strictFunctionTypes": true,
12+
"noUnusedLocals": false,
13+
"noUnusedParameters": false,
14+
"types": [],
15+
"noEmit": true,
16+
"forceConsistentCasingInFileNames": true,
17+
"esModuleInterop": true
18+
},
19+
"include": [
20+
"**/*.ts"
21+
]
22+
}

cli/test/.eslintrc.json

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

cli/test/tsconfig.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
"noImplicitAny": false,
66
"types": [
77
"mocha", "chai", "sinon"
8-
]
9-
}
8+
],
9+
},
10+
"include": [
11+
"**/*.ts"
12+
]
1013
}

0 commit comments

Comments
 (0)