Skip to content

Commit 39a7a53

Browse files
committed
refactor: rewrite eslint config
1 parent a1ce36c commit 39a7a53

File tree

5 files changed

+31
-103
lines changed

5 files changed

+31
-103
lines changed

__tests__/grumphp.test.ts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,22 @@ import grumphp from '../src/checks/grumphp'
22
import {expect, test} from '@jest/globals'
33

44
test('it returns defaults', () => {
5-
expect(grumphp({}, 'web')).toEqual([
6-
'grumphp',
7-
'run',
8-
'--no-interaction'
9-
])
5+
expect(grumphp({}, 'web')).toEqual(['grumphp', 'run', '--no-interaction'])
106
})
117

128
test('it handles partial inputs', () => {
139
let command
1410
command = grumphp(
1511
{
16-
testsuite: 'linters',
12+
testsuite: 'linters'
1713
},
1814
'web'
1915
)
2016
expect(command).toContain('--testsuite=linters')
2117

2218
command = grumphp(
2319
{
24-
tasks: [
25-
'phpcs',
26-
'phpmd'
27-
]
20+
tasks: ['phpcs', 'phpmd']
2821
},
2922
'docroot'
3023
)

__tests__/phpstan.test.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ import phpstan from '../src/checks/phpstan'
22
import {expect, test} from '@jest/globals'
33

44
test('it returns defaults', () => {
5-
expect(phpstan({}, 'web')).toEqual([
6-
'phpstan'
7-
])
5+
expect(phpstan({}, 'web')).toEqual(['phpstan'])
86
})
97

108
test('it handles configuration', () => {

eslint.config.mjs

Lines changed: 27 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,30 @@
1-
import jest from "eslint-plugin-jest";
2-
import typescriptEslint from "@typescript-eslint/eslint-plugin";
3-
import globals from "globals";
4-
import tsParser from "@typescript-eslint/parser";
5-
import path from "node:path";
6-
import { fileURLToPath } from "node:url";
7-
import js from "@eslint/js";
8-
import { FlatCompat } from "@eslint/eslintrc";
9-
10-
const __filename = fileURLToPath(import.meta.url);
11-
const __dirname = path.dirname(__filename);
12-
const compat = new FlatCompat({
13-
baseDirectory: __dirname,
14-
recommendedConfig: js.configs.recommended,
15-
allConfig: js.configs.all
16-
});
17-
18-
export default [{
19-
ignores: ["**/dist/", "**/lib/", "**/node_modules/", "**/jest.config.js"],
20-
}, ...compat.extends("plugin:github/recommended"), {
21-
plugins: {
22-
jest,
23-
"@typescript-eslint": typescriptEslint,
24-
},
25-
1+
import eslint from '@eslint/js'
2+
import typescriptEslint from '@typescript-eslint/eslint-plugin'
3+
import tseslint from 'typescript-eslint'
4+
import jest from 'eslint-plugin-jest'
5+
import github from 'eslint-plugin-github'
6+
7+
export default [
8+
...tseslint.config(eslint.configs.recommended, tseslint.configs.recommended),
9+
github.getFlatConfigs().recommended,
10+
{
11+
rules: {
12+
'importPlugin/no-unresolved': 'off'
13+
}
14+
},
15+
...github.getFlatConfigs().typescript,
16+
{
17+
files: ['__tests__/**/*.test.ts'],
18+
plugins: {jest: jest},
2619
languageOptions: {
27-
globals: {
28-
...globals.node,
29-
...jest.environments.globals.globals,
30-
},
31-
32-
parser: tsParser,
33-
ecmaVersion: 9,
34-
sourceType: "module",
35-
36-
parserOptions: {
37-
project: "./tsconfig.json",
38-
},
20+
globals: jest.environments.globals.globals
3921
},
40-
4122
rules: {
42-
"i18n-text/no-en": "off",
43-
"eslint-comments/no-use": "off",
44-
"import/no-namespace": "off",
45-
"no-unused-vars": "off",
46-
"@typescript-eslint/no-unused-vars": "error",
47-
48-
"@typescript-eslint/explicit-member-accessibility": ["error", {
49-
accessibility: "no-public",
50-
}],
51-
52-
"@typescript-eslint/no-require-imports": "error",
53-
"@typescript-eslint/array-type": "error",
54-
"@typescript-eslint/await-thenable": "error",
55-
"@typescript-eslint/ban-ts-comment": "error",
56-
camelcase: "off",
57-
"@typescript-eslint/consistent-type-assertions": "error",
58-
59-
"@typescript-eslint/explicit-function-return-type": ["error", {
60-
allowExpressions: true,
61-
}],
62-
63-
"@typescript-eslint/func-call-spacing": ["error", "never"],
64-
"@typescript-eslint/no-array-constructor": "error",
65-
"@typescript-eslint/no-empty-interface": "error",
66-
"@typescript-eslint/no-explicit-any": "error",
67-
"@typescript-eslint/no-extraneous-class": "error",
68-
"@typescript-eslint/no-for-in-array": "error",
69-
"@typescript-eslint/no-inferrable-types": "error",
70-
"@typescript-eslint/no-misused-new": "error",
71-
"@typescript-eslint/no-namespace": "error",
72-
"@typescript-eslint/no-non-null-assertion": "warn",
73-
"@typescript-eslint/no-unnecessary-qualifier": "error",
74-
"@typescript-eslint/no-unnecessary-type-assertion": "error",
75-
"@typescript-eslint/no-useless-constructor": "error",
76-
"@typescript-eslint/no-var-requires": "error",
77-
"@typescript-eslint/prefer-for-of": "warn",
78-
"@typescript-eslint/prefer-function-type": "warn",
79-
"@typescript-eslint/prefer-includes": "error",
80-
"@typescript-eslint/prefer-string-starts-ends-with": "error",
81-
"@typescript-eslint/promise-function-async": "error",
82-
"@typescript-eslint/require-array-sort-compare": "error",
83-
"@typescript-eslint/restrict-plus-operands": "error",
84-
semi: "off",
85-
"@typescript-eslint/semi": ["error", "never"],
86-
"@typescript-eslint/type-annotation-spacing": "error",
87-
"@typescript-eslint/unbound-method": "error",
88-
},
89-
}];
23+
'jest/no-disabled-tests': 'warn',
24+
'jest/no-focused-tests': 'error',
25+
'jest/no-identical-title': 'error',
26+
'jest/prefer-to-have-length': 'warn',
27+
'jest/valid-expect': 'error'
28+
}
29+
}
30+
]

package-lock.json

Lines changed: 0 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
"yaml": "^2.5.0"
3030
},
3131
"devDependencies": {
32-
"@eslint/eslintrc": "^3.2.0",
3332
"@eslint/js": "^9.17.0",
3433
"@types/node": "^20.14.10",
3534
"@typescript-eslint/parser": "^8.18.1",
@@ -38,7 +37,6 @@
3837
"eslint-plugin-github": "^5.1.4",
3938
"eslint-plugin-jest": "^28.10.0",
4039
"eslint-plugin-prettier": "^5.1.3",
41-
"globals": "^15.14.0",
4240
"jest": "^29.7.0",
4341
"js-yaml": "^4.1.0",
4442
"prettier": "3.4.2",

0 commit comments

Comments
 (0)