Skip to content

Commit d6b1edd

Browse files
committed
Reconfigure linters for ESM
1 parent 7c73dd1 commit d6b1edd

14 files changed

+158
-139
lines changed

.eslintignore

-4
This file was deleted.

.github/linters/.eslintrc.yml

-64
This file was deleted.

.github/linters/tsconfig.json

-9
This file was deleted.

.github/workflows/linter.yml

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ jobs:
4343
DEFAULT_BRANCH: main
4444
FILTER_REGEX_EXCLUDE: dist/**/*
4545
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
46+
LINTER_RULES_PATH: ${{ github.workspace }}
4647
VALIDATE_ALL_CODEBASE: true
4748
VALIDATE_JAVASCRIPT_STANDARD: false
4849
VALIDATE_JSCPD: false

.github/linters/.markdown-lint.yml renamed to .markdown-lint.yml

+6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
1+
# See: https://github.com/DavidAnson/markdownlint
2+
13
# Unordered list style
24
MD004:
35
style: dash
46

7+
# Disable line length for tables
8+
MD013:
9+
tables: false
10+
511
# Ordered list item prefix
612
MD029:
713
style: one

.prettierignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
.DS_Store
12
dist/
23
node_modules/
34
coverage/

.prettierrc.json

-16
This file was deleted.

.prettierrc.yml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# See: https://prettier.io/docs/en/configuration
2+
3+
printWidth: 80
4+
tabWidth: 2
5+
useTabs: false
6+
semi: false
7+
singleQuote: true
8+
quoteProps: as-needed
9+
jsxSingleQuote: false
10+
trailingComma: none
11+
bracketSpacing: true
12+
bracketSameLine: true
13+
arrowParens: always
14+
proseWrap: always
15+
htmlWhitespaceSensitivity: css
16+
endOfLine: lf

.github/linters/.yaml-lint.yml renamed to .yaml-lint.yml

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# See: https://yamllint.readthedocs.io/en/stable/
2+
13
rules:
24
document-end: disable
35
document-start:

eslint.config.mjs

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
// See: https://eslint.org/docs/latest/use/configure/configuration-files
2+
3+
import { fixupPluginRules } from '@eslint/compat'
4+
import { FlatCompat } from '@eslint/eslintrc'
5+
import js from '@eslint/js'
6+
import typescriptEslint from '@typescript-eslint/eslint-plugin'
7+
import tsParser from '@typescript-eslint/parser'
8+
import _import from 'eslint-plugin-import'
9+
import jest from 'eslint-plugin-jest'
10+
import prettier from 'eslint-plugin-prettier'
11+
import globals from 'globals'
12+
import path from 'node:path'
13+
import { fileURLToPath } from 'node:url'
14+
15+
const __filename = fileURLToPath(import.meta.url)
16+
const __dirname = path.dirname(__filename)
17+
const compat = new FlatCompat({
18+
baseDirectory: __dirname,
19+
recommendedConfig: js.configs.recommended,
20+
allConfig: js.configs.all
21+
})
22+
23+
export default [
24+
{
25+
ignores: ['**/coverage', '**/dist', '**/linter', '**/node_modules']
26+
},
27+
...compat.extends(
28+
'eslint:recommended',
29+
'plugin:@typescript-eslint/eslint-recommended',
30+
'plugin:@typescript-eslint/recommended',
31+
'plugin:jest/recommended',
32+
'plugin:prettier/recommended'
33+
),
34+
{
35+
plugins: {
36+
import: fixupPluginRules(_import),
37+
jest,
38+
prettier,
39+
'@typescript-eslint': typescriptEslint
40+
},
41+
42+
languageOptions: {
43+
globals: {
44+
...globals.node,
45+
...globals.jest,
46+
Atomics: 'readonly',
47+
SharedArrayBuffer: 'readonly'
48+
},
49+
50+
parser: tsParser,
51+
ecmaVersion: 2023,
52+
sourceType: 'module',
53+
54+
parserOptions: {
55+
project: ['tsconfig.eslint.json'],
56+
tsconfigRootDir: '.'
57+
}
58+
},
59+
60+
settings: {
61+
'import/resolver': {
62+
typescript: {
63+
alwaysTryTypes: true,
64+
project: 'tsconfig.eslint.json'
65+
}
66+
}
67+
},
68+
69+
rules: {
70+
camelcase: 'off',
71+
'eslint-comments/no-use': 'off',
72+
'eslint-comments/no-unused-disable': 'off',
73+
'i18n-text/no-en': 'off',
74+
'import/no-namespace': 'off',
75+
'no-console': 'off',
76+
'no-shadow': 'off',
77+
'no-unused-vars': 'off',
78+
'prettier/prettier': 'error'
79+
}
80+
}
81+
]

package.json

+7-34
Original file line numberDiff line numberDiff line change
@@ -37,49 +37,22 @@
3737
"all": "npm run format:write && npm run lint && npm run test && npm run coverage && npm run package"
3838
},
3939
"license": "MIT",
40-
"jest": {
41-
"preset": "ts-jest",
42-
"verbose": true,
43-
"clearMocks": true,
44-
"testEnvironment": "node",
45-
"moduleFileExtensions": [
46-
"js",
47-
"ts"
48-
],
49-
"testMatch": [
50-
"**/*.test.ts"
51-
],
52-
"testPathIgnorePatterns": [
53-
"/node_modules/",
54-
"/dist/"
55-
],
56-
"transform": {
57-
"^.+\\.ts$": "ts-jest"
58-
},
59-
"coverageReporters": [
60-
"json-summary",
61-
"text",
62-
"lcov"
63-
],
64-
"collectCoverage": true,
65-
"collectCoverageFrom": [
66-
"./src/**"
67-
]
68-
},
6940
"dependencies": {
7041
"@actions/core": "^1.11.1"
7142
},
7243
"devDependencies": {
44+
"@eslint/compat": "^1.2.3",
7345
"@github/local-action": "^2.2.0",
7446
"@jest/globals": "^29.7.0",
7547
"@types/jest": "^29.5.14",
7648
"@types/node": "^22.9.0",
77-
"@typescript-eslint/eslint-plugin": "^8.13.0",
78-
"@typescript-eslint/parser": "^8.13.0",
79-
"@vercel/ncc": "^0.38.2",
80-
"eslint": "^8.57.0",
49+
"@typescript-eslint/eslint-plugin": "^8.14.0",
50+
"@typescript-eslint/parser": "^8.14.0",
51+
"eslint": "^9.14.0",
52+
"eslint-config-prettier": "^9.1.0",
53+
"eslint-import-resolver-typescript": "^3.6.3",
54+
"eslint-plugin-import": "^2.31.0",
8155
"eslint-plugin-jest": "^28.9.0",
82-
"eslint-plugin-jsonc": "^2.18.1",
8356
"eslint-plugin-prettier": "^5.2.1",
8457
"jest": "^29.7.0",
8558
"make-coverage-badge": "^1.2.0",

tsconfig.base.json

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"$schema": "https://json.schemastore.org/tsconfig",
3+
"compilerOptions": {
4+
"allowSyntheticDefaultImports": true,
5+
"declaration": true,
6+
"declarationMap": false,
7+
"esModuleInterop": true,
8+
"forceConsistentCasingInFileNames": true,
9+
"lib": ["ES2022"],
10+
"module": "NodeNext",
11+
"moduleResolution": "NodeNext",
12+
"newLine": "lf",
13+
"noImplicitAny": true,
14+
"noUnusedLocals": true,
15+
"noUnusedParameters": false,
16+
"pretty": true,
17+
"resolveJsonModule": true,
18+
"sourceMap": true,
19+
"strict": true,
20+
"strictNullChecks": true,
21+
"target": "ES2022"
22+
}
23+
}

tsconfig.eslint.json

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"$schema": "https://json.schemastore.org/tsconfig",
3+
"extends": "./tsconfig.base.json",
4+
"compilerOptions": {
5+
"allowJs": true,
6+
"noEmit": true
7+
},
8+
"exclude": ["dist", "node_modules"],
9+
"include": [
10+
"__fixtures__",
11+
"__tests__",
12+
"src",
13+
"eslint.config.mjs",
14+
"jest.config.ts",
15+
"rollup.config.ts"
16+
]
17+
}

tsconfig.json

+4-12
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,11 @@
11
{
22
"$schema": "https://json.schemastore.org/tsconfig",
3+
"extends": "./tsconfig.base.json",
34
"compilerOptions": {
4-
"target": "ES2022",
55
"module": "NodeNext",
6-
"rootDir": "./src",
76
"moduleResolution": "NodeNext",
8-
"baseUrl": "./",
9-
"sourceMap": true,
10-
"outDir": "./dist",
11-
"noImplicitAny": true,
12-
"esModuleInterop": true,
13-
"forceConsistentCasingInFileNames": true,
14-
"strict": true,
15-
"skipLibCheck": true,
16-
"newLine": "lf"
7+
"outDir": "./dist"
178
},
18-
"exclude": ["./dist", "./node_modules", "./__tests__", "./coverage"]
9+
"exclude": ["__fixtures__", "__tests__", "coverage", "dist", "node_modules"],
10+
"include": ["src"]
1911
}

0 commit comments

Comments
 (0)