Skip to content

Commit 3472bd8

Browse files
committed
build: migrate eslint.config.js to typescript
This change migrates the eslint config for the repo to typescript. This is in support of the larger migration to typescript. In order for us to continue to consume the plugin locally, after it's been converted to typescript (without having to build first), we'll need to be loading the config from typescript. Since I needed to update eslint to support, I took the opportunity to all of the other plugins too (except unicorn). I also removed a rule disable that had a note on it about dropping after we dropped support for node 14.
1 parent dd04afa commit 3472bd8

File tree

5 files changed

+25
-8
lines changed

5 files changed

+25
-8
lines changed

eslint.config.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ import path from 'node:path';
22
import { fileURLToPath } from 'node:url';
33
import js from '@eslint/js';
44
import { FlatCompat } from '@eslint/eslintrc';
5+
import { defineConfig } from 'eslint/config';
56
import markdown from 'eslint-plugin-markdown';
67
import pluginN from 'eslint-plugin-n';
8+
// @ts-expect-error - eslint-plugin is not typed yet
79
import eslintPlugin from './lib/index.js';
810

911
const dirname = path.dirname(fileURLToPath(import.meta.url));
@@ -12,7 +14,7 @@ const compat = new FlatCompat({
1214
recommendedConfig: js.configs.recommended,
1315
});
1416

15-
export default [
17+
export default defineConfig([
1618
// Global ignores
1719
{
1820
ignores: ['node_modules', 'coverage'],
@@ -39,7 +41,6 @@ export default [
3941
'unicorn/no-array-reduce': 'off',
4042
'unicorn/no-null': 'off',
4143
'unicorn/prefer-module': 'off',
42-
'unicorn/prefer-node-protocol': 'off', // TODO: enable once we drop support for Node 14.17.
4344
'unicorn/prevent-abbreviations': 'off',
4445
},
4546
},
@@ -82,4 +83,4 @@ export default [
8283
'unicorn/filename-case': 'off',
8384
},
8485
},
85-
];
86+
]);

lib/rules/require-meta-docs-url.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// Requirements
77
// -----------------------------------------------------------------------------
88

9-
import path from 'path';
9+
import path from 'node:path';
1010
import * as utils from '../utils.js';
1111
import { getStaticValue } from '@eslint-community/eslint-utils';
1212

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@
5050
"@eslint/eslintrc": "^3.0.2",
5151
"@eslint/js": "^9.31.0",
5252
"@release-it/conventional-changelog": "^9.0.3",
53+
"@types/eslint-plugin-markdown": "^2.0.2",
5354
"@types/estree": "^1.0.8",
55+
"@types/node": "^20.19.0",
5456
"@typescript-eslint/parser": "^8.34.1",
5557
"@typescript-eslint/utils": "^8.34.1",
5658
"@vitest/coverage-istanbul": "^3.2.4",
@@ -66,6 +68,7 @@
6668
"eslint-scope": "^8.0.1",
6769
"espree": "^10.0.1",
6870
"husky": "^9.1.7",
71+
"jiti": "^2.4.2",
6972
"lodash": "^4.17.21",
7073
"markdownlint-cli": "^0.43.0",
7174
"npm-package-json-lint": "^8.0.0",
@@ -97,6 +100,5 @@
97100
"npm": {
98101
"skipChecks": true
99102
}
100-
},
101-
"packageManager": "[email protected]+sha512.e08cbfa5d0c47e148d9d92965513af3d06a42ff99b6e0e82a7d10512858d0fb680a03c1e6772d369a2305c79306c9257989a3576b7057d6877469c9a1c7563f0"
103+
}
102104
}

tests/lib/rules/no-property-in-node.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { RuleTester } from 'eslint';
2-
import path from 'path';
3-
import { fileURLToPath } from 'url';
2+
import path from 'node:path';
3+
import { fileURLToPath } from 'node:url';
44
import rule from '../../../lib/rules/no-property-in-node.js';
55
import parser from '@typescript-eslint/parser';
66

tsconfig.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"compilerOptions": {
3+
"rootDir": ".",
4+
"declaration": true,
5+
"esModuleInterop": true,
6+
"module": "esnext",
7+
"moduleResolution": "bundler",
8+
"noEmit": true,
9+
"resolveJsonModule": true,
10+
"skipLibCheck": true,
11+
"strict": true,
12+
"target": "ES2022"
13+
}
14+
}

0 commit comments

Comments
 (0)