@dvukovic/style-guide 0.3.97 → 0.3.98
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +93 -159
- package/package.json +16 -16
- package/src/cspell/base.txt +12 -0
- package/src/eslint/configs/core.js +42 -30
- package/src/eslint/configs/core.test.js +4 -4
- package/src/eslint/configs/jest.js +26 -3
- package/src/eslint/configs/jest.test.js +3 -3
- package/src/eslint/configs/mobx.js +15 -3
- package/src/eslint/configs/mobx.test.js +3 -3
- package/src/eslint/configs/next.js +15 -3
- package/src/eslint/configs/next.test.js +3 -3
- package/src/eslint/configs/node.js +16 -4
- package/src/eslint/configs/node.test.js +3 -3
- package/src/eslint/configs/playwright.js +26 -3
- package/src/eslint/configs/playwright.test.js +3 -3
- package/src/eslint/configs/react.js +16 -4
- package/src/eslint/configs/react.test.js +3 -3
- package/src/eslint/configs/storybook.js +15 -3
- package/src/eslint/configs/storybook.test.js +3 -3
- package/src/eslint/configs/typescript-strict.js +14 -2
- package/src/eslint/configs/typescript-strict.test.js +6 -4
- package/src/eslint/configs/typescript.js +37 -4
- package/src/eslint/configs/typescript.test.js +6 -4
- package/src/eslint/configs/vitest.js +26 -3
- package/src/eslint/configs/vitest.test.js +3 -3
- package/src/eslint/index.js +25 -0
- package/src/eslint/plugins/dvukovic.js +15 -0
- package/src/eslint/plugins/es-x.js +7 -6
- package/src/eslint/plugins/eslint-comments.js +4 -5
- package/src/eslint/plugins/eslint.js +9 -3
- package/src/eslint/plugins/eslint.test.js +42 -0
- package/src/eslint/plugins/import-x.js +4 -5
- package/src/eslint/plugins/jest.js +4 -5
- package/src/eslint/plugins/mobx.js +4 -5
- package/src/eslint/plugins/n.js +4 -5
- package/src/eslint/plugins/next.js +4 -5
- package/src/eslint/plugins/playwright.js +4 -5
- package/src/eslint/plugins/promise.js +4 -5
- package/src/eslint/plugins/react-hooks.js +4 -5
- package/src/eslint/plugins/react.js +4 -5
- package/src/eslint/plugins/rimac.js +4 -5
- package/src/eslint/plugins/security-node.js +4 -5
- package/src/eslint/plugins/simple-import-sort.js +4 -5
- package/src/eslint/plugins/sonarjs.js +261 -37
- package/src/eslint/plugins/sort-destructure-keys.js +4 -5
- package/src/eslint/plugins/sort-keys-fix.js +4 -5
- package/src/eslint/plugins/storybook.js +4 -5
- package/src/eslint/plugins/stylistic.js +4 -5
- package/src/eslint/plugins/typescript-eslint.js +4 -5
- package/src/eslint/plugins/typescript-sort-keys.js +4 -5
- package/src/eslint/plugins/unicorn.js +4 -5
- package/src/eslint/plugins/unused-imports.js +4 -5
- package/src/eslint/plugins/vitest.js +4 -5
- package/src/eslint/rules/no-commented-out-code/no-commented-out-code.js +80 -0
- package/src/eslint/rules/no-commented-out-code/no-commented-out-code.test.js +89 -0
- package/src/eslint/rules/no-commented-out-code/no-commented-out-code.utils.js +119 -0
- package/src/eslint/types.js +19 -0
- package/src/eslint/plugins/etc.js +0 -3
package/README.md
CHANGED
|
@@ -1,187 +1,121 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @dvukovic/style-guide
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Personal style guide with ESLint, Prettier, and other code quality tools.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
yarn add -D @dvukovic/style-guide eslint prettier cspell stylelint
|
|
8
|
+
yarn add -D @dvukovic/style-guide eslint prettier cspell stylelint
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
##
|
|
12
|
-
|
|
13
|
-
Add these scripts to your `package.json`:
|
|
14
|
-
|
|
15
|
-
```json
|
|
16
|
-
{
|
|
17
|
-
"scripts": {
|
|
18
|
-
"lint": "yarn lint:eslint && yarn lint:prettier && yarn lint:stylelint && yarn lint:spell && yarn lint:package-json",
|
|
19
|
-
"lint:eslint": "eslint . --cache --concurrency=auto",
|
|
20
|
-
"lint:fix": "yarn lint:eslint --fix && yarn lint:prettier --write && yarn lint:stylelint --fix",
|
|
21
|
-
"lint:package-json": "npmPkgJsonLint --configFile ./.packagerc.js .",
|
|
22
|
-
"lint:prettier": "prettier --check --cache '**/*.{json,yaml,yml,md,css,html}'",
|
|
23
|
-
"lint:spell": "cspell --config ./.cspellrc.js --no-progress --no-summary --unique '**'",
|
|
24
|
-
"lint:stylelint": "stylelint ./**/*.css --cache"
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
```
|
|
11
|
+
## ESLint Configuration
|
|
28
12
|
|
|
29
|
-
|
|
13
|
+
### Basic Usage
|
|
30
14
|
|
|
31
|
-
|
|
32
|
-
.eslintcache
|
|
33
|
-
.stylelintcache
|
|
34
|
-
```
|
|
15
|
+
Create an `eslint.config.js` file in your project root:
|
|
35
16
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
Prettier is integrated into ESLint via `eslint-plugin-prettier` for JS/TS files. The separate
|
|
41
|
-
`lint:prettier` script handles JSON, YAML, MD, and other files.
|
|
42
|
-
|
|
43
|
-
Create `eslint.config.js`:
|
|
44
|
-
|
|
45
|
-
```javascript
|
|
46
|
-
import tseslint from "typescript-eslint"
|
|
47
|
-
|
|
48
|
-
import core from "@dvukovic/style-guide/src/eslint/configs/core.js"
|
|
49
|
-
import jest from "@dvukovic/style-guide/src/eslint/configs/jest.js"
|
|
50
|
-
import mobx from "@dvukovic/style-guide/src/eslint/configs/mobx.js"
|
|
51
|
-
import next from "@dvukovic/style-guide/src/eslint/configs/next.js"
|
|
52
|
-
import node from "@dvukovic/style-guide/src/eslint/configs/node.js"
|
|
53
|
-
import playwright from "@dvukovic/style-guide/src/eslint/configs/playwright.js"
|
|
54
|
-
import react from "@dvukovic/style-guide/src/eslint/configs/react.js"
|
|
55
|
-
import storybook from "@dvukovic/style-guide/src/eslint/configs/storybook.js"
|
|
56
|
-
import typescript from "@dvukovic/style-guide/src/eslint/configs/typescript.js"
|
|
57
|
-
import typescriptStrict from "@dvukovic/style-guide/src/eslint/configs/typescript-strict.js"
|
|
58
|
-
import vitest from "@dvukovic/style-guide/src/eslint/configs/vitest.js"
|
|
59
|
-
|
|
60
|
-
export default tseslint.config(
|
|
61
|
-
{ ignores: ["node_modules", ".next", "dist", "build"] },
|
|
62
|
-
...core,
|
|
63
|
-
...node,
|
|
64
|
-
...next,
|
|
65
|
-
...mobx,
|
|
66
|
-
...react,
|
|
67
|
-
{
|
|
68
|
-
languageOptions: {
|
|
69
|
-
parser: tseslint.parser,
|
|
70
|
-
parserOptions: {
|
|
71
|
-
project: "./tsconfig.json",
|
|
72
|
-
},
|
|
73
|
-
},
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
files: ["**/*.ts", "**/*.tsx"],
|
|
77
|
-
extends: [...typescript, ...typescriptStrict],
|
|
78
|
-
},
|
|
79
|
-
{
|
|
80
|
-
files: ["**/*.test.ts"],
|
|
81
|
-
extends: [...jest],
|
|
82
|
-
},
|
|
83
|
-
{
|
|
84
|
-
files: ["**/*.test.ts"],
|
|
85
|
-
extends: [...vitest],
|
|
86
|
-
},
|
|
87
|
-
{
|
|
88
|
-
files: ["**/*.ui.test.ts"],
|
|
89
|
-
extends: [...playwright],
|
|
90
|
-
},
|
|
91
|
-
{
|
|
92
|
-
files: ["**/*.stories.ts", "**/*.stories.tsx"],
|
|
93
|
-
extends: [...storybook],
|
|
94
|
-
},
|
|
95
|
-
)
|
|
17
|
+
```js
|
|
18
|
+
import { customDefineConfig, core, typescript } from "@dvukovic/style-guide/eslint"
|
|
19
|
+
|
|
20
|
+
export default customDefineConfig(["dist/**", "build/**"], [core(), typescript()])
|
|
96
21
|
```
|
|
97
22
|
|
|
98
23
|
### Available Configs
|
|
99
24
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
25
|
+
Each config is a factory function that returns ESLint configuration:
|
|
26
|
+
|
|
27
|
+
- `core()` - Essential rules for all JavaScript/TypeScript projects
|
|
28
|
+
- `node()` - Node.js specific rules
|
|
29
|
+
- `react()` - React framework rules
|
|
30
|
+
- `typescript()` - TypeScript parser and rules
|
|
31
|
+
- `typescriptStrict()` - Additional strict TypeScript rules
|
|
32
|
+
- `jest()` - Jest testing framework
|
|
33
|
+
- `vitest()` - Vitest testing framework
|
|
34
|
+
- `playwright()` - Playwright e2e testing
|
|
35
|
+
- `mobx()` - MobX state management
|
|
36
|
+
- `next()` - Next.js framework
|
|
37
|
+
- `storybook()` - Storybook
|
|
38
|
+
|
|
39
|
+
### Customizing Configs
|
|
40
|
+
|
|
41
|
+
Each factory function accepts a `config` parameter to extend or override settings:
|
|
42
|
+
|
|
43
|
+
```js
|
|
44
|
+
import { customDefineConfig, core, typescript } from "@dvukovic/style-guide/eslint"
|
|
45
|
+
|
|
46
|
+
export default customDefineConfig(
|
|
47
|
+
[],
|
|
48
|
+
[
|
|
49
|
+
core(),
|
|
50
|
+
typescript({
|
|
51
|
+
rules: {
|
|
52
|
+
"@typescript-eslint/no-unused-vars": "warn",
|
|
53
|
+
},
|
|
54
|
+
}),
|
|
55
|
+
],
|
|
56
|
+
)
|
|
127
57
|
```
|
|
128
58
|
|
|
129
|
-
|
|
59
|
+
### Complete Example
|
|
60
|
+
|
|
61
|
+
A full-featured project (this is the actual config used by this package):
|
|
62
|
+
|
|
63
|
+
```js
|
|
64
|
+
import {
|
|
65
|
+
customDefineConfig,
|
|
66
|
+
core,
|
|
67
|
+
node,
|
|
68
|
+
mobx,
|
|
69
|
+
react,
|
|
70
|
+
next,
|
|
71
|
+
typescript,
|
|
72
|
+
typescriptStrict,
|
|
73
|
+
jest,
|
|
74
|
+
vitest,
|
|
75
|
+
playwright,
|
|
76
|
+
} from "@dvukovic/style-guide/eslint"
|
|
77
|
+
|
|
78
|
+
export default customDefineConfig(
|
|
79
|
+
["node_modules"],
|
|
80
|
+
[
|
|
81
|
+
core(),
|
|
82
|
+
node(),
|
|
83
|
+
mobx(),
|
|
84
|
+
react(),
|
|
85
|
+
next(),
|
|
86
|
+
typescript(),
|
|
87
|
+
typescriptStrict(),
|
|
88
|
+
jest(),
|
|
89
|
+
vitest(),
|
|
90
|
+
playwright(),
|
|
91
|
+
],
|
|
92
|
+
)
|
|
93
|
+
```
|
|
130
94
|
|
|
131
|
-
##
|
|
95
|
+
## Prettier Configuration
|
|
132
96
|
|
|
133
|
-
|
|
97
|
+
```js
|
|
98
|
+
import { prettier } from "@dvukovic/style-guide/prettier"
|
|
134
99
|
|
|
135
|
-
|
|
136
|
-
/** @type {import("stylelint").Config} */
|
|
137
|
-
export default {
|
|
138
|
-
extends: "@dvukovic/style-guide/src/stylelint/configs/core.js",
|
|
139
|
-
}
|
|
100
|
+
export default prettier
|
|
140
101
|
```
|
|
141
102
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
Create `.cspellrc.js`:
|
|
147
|
-
|
|
148
|
-
```javascript
|
|
149
|
-
/** @type {import("cspell").FileSettings} */
|
|
150
|
-
export default {
|
|
151
|
-
cache: {
|
|
152
|
-
cacheLocation: "./node_modules/.cache/cspell",
|
|
153
|
-
useCache: true,
|
|
154
|
-
},
|
|
155
|
-
caseSensitive: false,
|
|
156
|
-
dictionaries: ["shared"],
|
|
157
|
-
dictionaryDefinitions: [
|
|
158
|
-
{
|
|
159
|
-
name: "shared",
|
|
160
|
-
path: "./node_modules/@dvukovic/style-guide/src/cspell/base.txt",
|
|
161
|
-
},
|
|
162
|
-
],
|
|
163
|
-
useGitignore: true,
|
|
164
|
-
}
|
|
165
|
-
```
|
|
103
|
+
## Stylelint Configuration
|
|
104
|
+
|
|
105
|
+
```js
|
|
106
|
+
import { stylelint } from "@dvukovic/style-guide/stylelint"
|
|
166
107
|
|
|
167
|
-
|
|
108
|
+
export default stylelint
|
|
109
|
+
```
|
|
168
110
|
|
|
169
|
-
## Package
|
|
111
|
+
## Package.json Configuration
|
|
170
112
|
|
|
171
|
-
|
|
113
|
+
```js
|
|
114
|
+
import { packageJson } from "@dvukovic/style-guide/package-json"
|
|
172
115
|
|
|
173
|
-
|
|
174
|
-
/** @type {import("npm-package-json-lint").NpmPackageJsonLint} */
|
|
175
|
-
export default {
|
|
176
|
-
extends: "@dvukovic/style-guide/src/package-json/configs/core.js",
|
|
177
|
-
}
|
|
116
|
+
export default packageJson
|
|
178
117
|
```
|
|
179
118
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
## Requirements
|
|
119
|
+
## License
|
|
183
120
|
|
|
184
|
-
|
|
185
|
-
- ESLint 9+
|
|
186
|
-
- Prettier 3+
|
|
187
|
-
- Stylelint 16+
|
|
121
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dvukovic/style-guide",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.98",
|
|
4
4
|
"description": "My own style guide",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
"scripts": {
|
|
22
22
|
"lint": "yarn lint:eslint && yarn lint:prettier && yarn lint:stylelint && yarn lint:spell",
|
|
23
23
|
"lint:eslint": "eslint . --cache --concurrency=auto",
|
|
24
|
-
"lint:fix": "yarn lint:eslint --fix && yarn lint:prettier --write && yarn lint:stylelint --fix",
|
|
25
|
-
"lint:prettier": "prettier --check --cache
|
|
24
|
+
"lint:fix": "yarn lint:eslint --fix && yarn lint:prettier --write && yarn lint:stylelint --fix && yarn lint:spell",
|
|
25
|
+
"lint:prettier": "prettier --check --cache .",
|
|
26
26
|
"lint:spell": "cspell --config ./.cspellrc.js --no-progress --no-summary --unique '**'",
|
|
27
27
|
"lint:stylelint": "stylelint ./**/*.css --cache",
|
|
28
28
|
"release": "release-it",
|
|
@@ -30,14 +30,14 @@
|
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@eslint-community/eslint-plugin-eslint-comments": "4.5.0",
|
|
33
|
-
"@
|
|
33
|
+
"@eslint/compat": "^2.0.0",
|
|
34
|
+
"@next/eslint-plugin-next": "16.0.7",
|
|
34
35
|
"@prettier/plugin-xml": "3.4.2",
|
|
35
36
|
"@rimac-technology/eslint-plugin": "1.5.0",
|
|
36
37
|
"@stylistic/eslint-plugin": "5.6.1",
|
|
37
|
-
"@typescript-eslint/parser": "8.48.
|
|
38
|
+
"@typescript-eslint/parser": "8.48.1",
|
|
38
39
|
"@vitest/eslint-plugin": "1.5.1",
|
|
39
|
-
"eslint-plugin-es-x": "9.
|
|
40
|
-
"eslint-plugin-etc": "2.0.3",
|
|
40
|
+
"eslint-plugin-es-x": "9.3.0",
|
|
41
41
|
"eslint-plugin-import-x": "4.16.1",
|
|
42
42
|
"eslint-plugin-jest": "29.2.1",
|
|
43
43
|
"eslint-plugin-mobx": "0.0.13",
|
|
@@ -51,13 +51,13 @@
|
|
|
51
51
|
"eslint-plugin-sonarjs": "3.0.5",
|
|
52
52
|
"eslint-plugin-sort-destructure-keys": "2.0.0",
|
|
53
53
|
"eslint-plugin-sort-keys-fix": "1.1.2",
|
|
54
|
-
"eslint-plugin-storybook": "10.1.
|
|
54
|
+
"eslint-plugin-storybook": "10.1.4",
|
|
55
55
|
"eslint-plugin-typescript-sort-keys": "3.3.0",
|
|
56
56
|
"eslint-plugin-unicorn": "62.0.0",
|
|
57
57
|
"eslint-plugin-unused-imports": "4.3.0",
|
|
58
58
|
"globals": "16.5.0",
|
|
59
59
|
"prettier-plugin-embed": "0.5.0",
|
|
60
|
-
"prettier-plugin-jsdoc": "1.
|
|
60
|
+
"prettier-plugin-jsdoc": "1.8.0",
|
|
61
61
|
"prettier-plugin-packagejson": "2.5.20",
|
|
62
62
|
"prettier-plugin-prisma": "5.0.0",
|
|
63
63
|
"prettier-plugin-sh": "0.18.0",
|
|
@@ -66,25 +66,25 @@
|
|
|
66
66
|
"prettier-plugin-toml": "2.0.6",
|
|
67
67
|
"stylelint-no-unused-selectors": "1.0.40",
|
|
68
68
|
"stylelint-order": "7.0.0",
|
|
69
|
-
"typescript-eslint": "8.48.
|
|
69
|
+
"typescript-eslint": "8.48.1"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
|
-
"@storybook/react": "10.1.
|
|
72
|
+
"@storybook/react": "10.1.4",
|
|
73
73
|
"@types/eslint": "9.6.1",
|
|
74
74
|
"@types/jest": "30.0.0",
|
|
75
75
|
"@types/node": "24.10.1",
|
|
76
76
|
"@types/react": "19.2.7",
|
|
77
|
-
"cspell": "9.
|
|
77
|
+
"cspell": "9.4.0",
|
|
78
78
|
"eslint": "9.39.1",
|
|
79
79
|
"jest": "30.2.0",
|
|
80
80
|
"npm-package-json-lint": "9.0.0",
|
|
81
|
-
"prettier": "3.7.
|
|
82
|
-
"react": "19.2.
|
|
81
|
+
"prettier": "3.7.4",
|
|
82
|
+
"react": "19.2.1",
|
|
83
83
|
"release-it": "19.0.6",
|
|
84
|
-
"storybook": "^10.1.
|
|
84
|
+
"storybook": "^10.1.4",
|
|
85
85
|
"stylelint": "16.26.1",
|
|
86
86
|
"typescript": "5.9.3",
|
|
87
|
-
"vitest": "^4.0.
|
|
87
|
+
"vitest": "^4.0.15"
|
|
88
88
|
},
|
|
89
89
|
"peerDependencies": {
|
|
90
90
|
"cspell": "9",
|
package/src/cspell/base.txt
CHANGED
|
@@ -1,33 +1,45 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
1
|
+
import { dvukovic } from "../plugins/dvukovic.js"
|
|
2
|
+
import { esX } from "../plugins/es-x.js"
|
|
3
|
+
import { eslint } from "../plugins/eslint.js"
|
|
4
|
+
import { eslintComments } from "../plugins/eslint-comments.js"
|
|
5
|
+
import { importX } from "../plugins/import-x.js"
|
|
6
|
+
import { promise } from "../plugins/promise.js"
|
|
7
|
+
import { rimac } from "../plugins/rimac.js"
|
|
8
|
+
import { simpleImportSort } from "../plugins/simple-import-sort.js"
|
|
9
|
+
import { sonarjs } from "../plugins/sonarjs.js"
|
|
10
|
+
import { sortDestructureKeys } from "../plugins/sort-destructure-keys.js"
|
|
11
|
+
import { sortKeysFix } from "../plugins/sort-keys-fix.js"
|
|
12
|
+
import { stylistic } from "../plugins/stylistic.js"
|
|
13
|
+
import { unicorn } from "../plugins/unicorn.js"
|
|
14
|
+
import { unusedImports } from "../plugins/unused-imports.js"
|
|
15
15
|
|
|
16
|
-
const coreConfig = [
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
16
|
+
export const coreConfig = [
|
|
17
|
+
esX,
|
|
18
|
+
eslint,
|
|
19
|
+
eslintComments,
|
|
20
|
+
importX,
|
|
21
|
+
promise,
|
|
22
|
+
rimac,
|
|
23
|
+
simpleImportSort,
|
|
24
|
+
sonarjs,
|
|
25
|
+
sortDestructureKeys,
|
|
26
|
+
sortKeysFix,
|
|
27
|
+
stylistic,
|
|
28
|
+
unicorn,
|
|
29
|
+
unusedImports,
|
|
30
|
+
dvukovic,
|
|
31
31
|
]
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
/**
|
|
34
|
+
* Core ESLint configuration with essential rules and plugins
|
|
35
|
+
*
|
|
36
|
+
* @param {import("@eslint/config-helpers").ConfigWithExtends} [config] - Additional config
|
|
37
|
+
* @returns {import("@eslint/config-helpers").ConfigWithExtends} ESLint config
|
|
38
|
+
*/
|
|
39
|
+
export function core(config) {
|
|
40
|
+
return {
|
|
41
|
+
extends: [...coreConfig, ...(config?.extends ?? [])],
|
|
42
|
+
files: ["**/*.js", "**/*.cjs", "**/*.mjs", "**/*.ts", "**/*.tsx"],
|
|
43
|
+
...config,
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { ESLint } from "eslint"
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import { coreConfig } from "./core.js"
|
|
4
4
|
|
|
5
5
|
const eslint = new ESLint({
|
|
6
|
-
overrideConfig:
|
|
6
|
+
overrideConfig: coreConfig,
|
|
7
7
|
overrideConfigFile: true,
|
|
8
8
|
})
|
|
9
9
|
|
|
@@ -12,12 +12,12 @@ describe("core", () => {
|
|
|
12
12
|
const results = await eslint.lintText("const x = 1\n", { filePath: "test.js" })
|
|
13
13
|
|
|
14
14
|
expect(results).toBeDefined()
|
|
15
|
-
expect(results[0]
|
|
15
|
+
expect(results[0]?.fatalErrorCount).toBe(0)
|
|
16
16
|
})
|
|
17
17
|
|
|
18
18
|
test("detects violations", async () => {
|
|
19
19
|
const results = await eslint.lintText("var x = 1\n", { filePath: "test.js" })
|
|
20
20
|
|
|
21
|
-
expect(results[0]
|
|
21
|
+
expect(results[0]?.errorCount).toBeGreaterThan(0)
|
|
22
22
|
})
|
|
23
23
|
})
|
|
@@ -1,5 +1,28 @@
|
|
|
1
|
-
import jestPlugin from "../plugins/jest.js"
|
|
1
|
+
import { jest as jestPlugin } from "../plugins/jest.js"
|
|
2
2
|
|
|
3
|
-
const jestConfig = [jestPlugin]
|
|
3
|
+
export const jestConfig = [jestPlugin]
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Jest testing framework configuration
|
|
7
|
+
*
|
|
8
|
+
* @param {import("@eslint/config-helpers").ConfigWithExtends} [config] - Additional config
|
|
9
|
+
* @returns {import("@eslint/config-helpers").ConfigWithExtends} ESLint config
|
|
10
|
+
*/
|
|
11
|
+
export function jest(config) {
|
|
12
|
+
return {
|
|
13
|
+
extends: [...jestConfig, ...(config?.extends ?? [])],
|
|
14
|
+
files: [
|
|
15
|
+
"**/*.test.js",
|
|
16
|
+
"**/*.test.ts",
|
|
17
|
+
"**/*.spec.js",
|
|
18
|
+
"**/*.spec.ts",
|
|
19
|
+
"**/*.unit.test.js",
|
|
20
|
+
"**/*.unit.test.ts",
|
|
21
|
+
"**/*.int.test.js",
|
|
22
|
+
"**/*.int.test.ts",
|
|
23
|
+
"**/*.integration.test.js",
|
|
24
|
+
"**/*.integration.test.ts",
|
|
25
|
+
],
|
|
26
|
+
...config,
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { ESLint } from "eslint"
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import { jestConfig } from "./jest.js"
|
|
4
4
|
|
|
5
5
|
const eslint = new ESLint({
|
|
6
|
-
overrideConfig:
|
|
6
|
+
overrideConfig: jestConfig,
|
|
7
7
|
overrideConfigFile: true,
|
|
8
8
|
})
|
|
9
9
|
|
|
@@ -12,6 +12,6 @@ describe("jest", () => {
|
|
|
12
12
|
const results = await eslint.lintText("const x = 1\n", { filePath: "test.test.js" })
|
|
13
13
|
|
|
14
14
|
expect(results).toBeDefined()
|
|
15
|
-
expect(results[0]
|
|
15
|
+
expect(results[0]?.fatalErrorCount).toBe(0)
|
|
16
16
|
})
|
|
17
17
|
})
|
|
@@ -1,5 +1,17 @@
|
|
|
1
|
-
import mobxPlugin from "../plugins/mobx.js"
|
|
1
|
+
import { mobx as mobxPlugin } from "../plugins/mobx.js"
|
|
2
2
|
|
|
3
|
-
const mobxConfig = [mobxPlugin]
|
|
3
|
+
export const mobxConfig = [mobxPlugin]
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* MobX state management configuration
|
|
7
|
+
*
|
|
8
|
+
* @param {import("@eslint/config-helpers").ConfigWithExtends} [config] - Additional config
|
|
9
|
+
* @returns {import("@eslint/config-helpers").ConfigWithExtends} ESLint config
|
|
10
|
+
*/
|
|
11
|
+
export function mobx(config) {
|
|
12
|
+
return {
|
|
13
|
+
extends: [...mobxConfig, ...(config?.extends ?? [])],
|
|
14
|
+
files: ["**/*.js", "**/*.ts", "**/*.jsx", "**/*.tsx"],
|
|
15
|
+
...config,
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { ESLint } from "eslint"
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import { mobxConfig } from "./mobx.js"
|
|
4
4
|
|
|
5
5
|
const eslint = new ESLint({
|
|
6
|
-
overrideConfig:
|
|
6
|
+
overrideConfig: mobxConfig,
|
|
7
7
|
overrideConfigFile: true,
|
|
8
8
|
})
|
|
9
9
|
|
|
@@ -12,6 +12,6 @@ describe("mobx", () => {
|
|
|
12
12
|
const results = await eslint.lintText("const x = 1\n", { filePath: "test.js" })
|
|
13
13
|
|
|
14
14
|
expect(results).toBeDefined()
|
|
15
|
-
expect(results[0]
|
|
15
|
+
expect(results[0]?.fatalErrorCount).toBe(0)
|
|
16
16
|
})
|
|
17
17
|
})
|
|
@@ -1,5 +1,17 @@
|
|
|
1
|
-
import nextPlugin from "../plugins/next.js"
|
|
1
|
+
import { next as nextPlugin } from "../plugins/next.js"
|
|
2
2
|
|
|
3
|
-
const nextConfig = [nextPlugin]
|
|
3
|
+
export const nextConfig = [nextPlugin]
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Next.js framework configuration
|
|
7
|
+
*
|
|
8
|
+
* @param {import("@eslint/config-helpers").ConfigWithExtends} [config] - Additional config
|
|
9
|
+
* @returns {import("@eslint/config-helpers").ConfigWithExtends} ESLint config
|
|
10
|
+
*/
|
|
11
|
+
export function next(config) {
|
|
12
|
+
return {
|
|
13
|
+
extends: [...nextConfig, ...(config?.extends ?? [])],
|
|
14
|
+
files: ["**/*.js", "**/*.ts", "**/*.jsx", "**/*.tsx"],
|
|
15
|
+
...config,
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { ESLint } from "eslint"
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import { nextConfig } from "./next.js"
|
|
4
4
|
|
|
5
5
|
const eslint = new ESLint({
|
|
6
|
-
overrideConfig:
|
|
6
|
+
overrideConfig: nextConfig,
|
|
7
7
|
overrideConfigFile: true,
|
|
8
8
|
})
|
|
9
9
|
|
|
@@ -12,6 +12,6 @@ describe("next", () => {
|
|
|
12
12
|
const results = await eslint.lintText("const x = 1\n", { filePath: "test.tsx" })
|
|
13
13
|
|
|
14
14
|
expect(results).toBeDefined()
|
|
15
|
-
expect(results[0]
|
|
15
|
+
expect(results[0]?.fatalErrorCount).toBe(0)
|
|
16
16
|
})
|
|
17
17
|
})
|
|
@@ -1,6 +1,18 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { nodeN } from "../plugins/n.js"
|
|
2
|
+
import { securityNode } from "../plugins/security-node.js"
|
|
3
3
|
|
|
4
|
-
const nodeConfig = [
|
|
4
|
+
export const nodeConfig = [nodeN, securityNode]
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Node.js ESLint configuration
|
|
8
|
+
*
|
|
9
|
+
* @param {import("@eslint/config-helpers").ConfigWithExtends} [config] - Additional config
|
|
10
|
+
* @returns {import("@eslint/config-helpers").ConfigWithExtends} ESLint config
|
|
11
|
+
*/
|
|
12
|
+
export function node(config) {
|
|
13
|
+
return {
|
|
14
|
+
extends: [...nodeConfig, ...(config?.extends ?? [])],
|
|
15
|
+
files: ["**/*.js", "**/*.cjs", "**/*.mjs", "**/*.ts", "**/*.cts", "**/*.mts"],
|
|
16
|
+
...config,
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { ESLint } from "eslint"
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import { nodeConfig } from "./node.js"
|
|
4
4
|
|
|
5
5
|
const eslint = new ESLint({
|
|
6
|
-
overrideConfig:
|
|
6
|
+
overrideConfig: nodeConfig,
|
|
7
7
|
overrideConfigFile: true,
|
|
8
8
|
})
|
|
9
9
|
|
|
@@ -12,6 +12,6 @@ describe("node", () => {
|
|
|
12
12
|
const results = await eslint.lintText("const x = 1\n", { filePath: "test.js" })
|
|
13
13
|
|
|
14
14
|
expect(results).toBeDefined()
|
|
15
|
-
expect(results[0]
|
|
15
|
+
expect(results[0]?.fatalErrorCount).toBe(0)
|
|
16
16
|
})
|
|
17
17
|
})
|