@dvukovic/style-guide 0.3.97 → 0.3.99
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 +104 -152
- 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,139 @@
|
|
|
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
|
-
##
|
|
11
|
+
## ESLint Configuration
|
|
12
|
+
|
|
13
|
+
### Basic Usage
|
|
14
|
+
|
|
15
|
+
Create an `eslint.config.js` file in your project root:
|
|
16
|
+
|
|
17
|
+
```js
|
|
18
|
+
import { customDefineConfig, core, typescript } from "@dvukovic/style-guide/eslint"
|
|
19
|
+
|
|
20
|
+
export default customDefineConfig(["dist/**", "build/**"], [core(), typescript()])
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### Available Configs
|
|
24
|
+
|
|
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
|
+
)
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Scripts
|
|
12
60
|
|
|
13
61
|
Add these scripts to your `package.json`:
|
|
14
62
|
|
|
15
63
|
```json
|
|
16
64
|
{
|
|
17
65
|
"scripts": {
|
|
18
|
-
"lint": "yarn lint:eslint && yarn lint:prettier && yarn lint:stylelint && yarn lint:spell
|
|
66
|
+
"lint": "yarn lint:eslint && yarn lint:prettier && yarn lint:stylelint && yarn lint:spell",
|
|
19
67
|
"lint:eslint": "eslint . --cache --concurrency=auto",
|
|
20
|
-
"lint:fix": "yarn lint:eslint --fix && yarn lint:prettier --write && yarn lint:stylelint --fix",
|
|
21
|
-
"lint:
|
|
22
|
-
"lint:prettier": "prettier --check --cache '**/*.{json,yaml,yml,md,css,html}'",
|
|
68
|
+
"lint:fix": "yarn lint:eslint --fix && yarn lint:prettier --write && yarn lint:stylelint --fix && yarn lint:spell",
|
|
69
|
+
"lint:prettier": "prettier --check --cache .",
|
|
23
70
|
"lint:spell": "cspell --config ./.cspellrc.js --no-progress --no-summary --unique '**'",
|
|
24
|
-
"lint:stylelint": "stylelint ./**/*.css --cache"
|
|
71
|
+
"lint:stylelint": "stylelint ./**/*.css --cache",
|
|
72
|
+
"test": "vitest run"
|
|
25
73
|
}
|
|
26
74
|
}
|
|
27
75
|
```
|
|
28
76
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
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
|
-
},
|
|
77
|
+
### Complete Example
|
|
78
|
+
|
|
79
|
+
A full-featured project (this is the actual config used by this package):
|
|
80
|
+
|
|
81
|
+
```js
|
|
82
|
+
import {
|
|
83
|
+
customDefineConfig,
|
|
84
|
+
core,
|
|
85
|
+
node,
|
|
86
|
+
mobx,
|
|
87
|
+
react,
|
|
88
|
+
next,
|
|
89
|
+
typescript,
|
|
90
|
+
typescriptStrict,
|
|
91
|
+
jest,
|
|
92
|
+
vitest,
|
|
93
|
+
playwright,
|
|
94
|
+
} from "@dvukovic/style-guide/eslint"
|
|
95
|
+
|
|
96
|
+
export default customDefineConfig(
|
|
97
|
+
["node_modules"],
|
|
98
|
+
[
|
|
99
|
+
core(),
|
|
100
|
+
node(),
|
|
101
|
+
mobx(),
|
|
102
|
+
react(),
|
|
103
|
+
next(),
|
|
104
|
+
typescript(),
|
|
105
|
+
typescriptStrict(),
|
|
106
|
+
jest(),
|
|
107
|
+
vitest(),
|
|
108
|
+
playwright(),
|
|
109
|
+
],
|
|
95
110
|
)
|
|
96
111
|
```
|
|
97
112
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
| Config | Description |
|
|
101
|
-
| ------------------- | -------------------------------- |
|
|
102
|
-
| `core` | Base JavaScript rules + Prettier |
|
|
103
|
-
| `node` | Node.js specific rules |
|
|
104
|
-
| `react` | React and JSX rules |
|
|
105
|
-
| `next` | Next.js specific rules |
|
|
106
|
-
| `mobx` | MobX state management rules |
|
|
107
|
-
| `typescript` | TypeScript rules |
|
|
108
|
-
| `typescript-strict` | Strict TypeScript rules |
|
|
109
|
-
| `jest` | Jest testing rules |
|
|
110
|
-
| `vitest` | Vitest testing rules |
|
|
111
|
-
| `playwright` | Playwright E2E testing rules |
|
|
112
|
-
| `storybook` | Storybook rules |
|
|
113
|
-
|
|
114
|
-
---
|
|
113
|
+
## Prettier Configuration
|
|
115
114
|
|
|
116
|
-
|
|
115
|
+
```js
|
|
116
|
+
import { prettier } from "@dvukovic/style-guide/prettier"
|
|
117
117
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
```javascript
|
|
121
|
-
import prettierConfig from "@dvukovic/style-guide/src/prettier/configs/core.js"
|
|
122
|
-
|
|
123
|
-
/** @type {import("prettier").Config} */
|
|
124
|
-
export default {
|
|
125
|
-
...prettierConfig,
|
|
126
|
-
}
|
|
118
|
+
export default prettier
|
|
127
119
|
```
|
|
128
120
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
## Stylelint
|
|
121
|
+
## Stylelint Configuration
|
|
132
122
|
|
|
133
|
-
|
|
123
|
+
```js
|
|
124
|
+
import { stylelint } from "@dvukovic/style-guide/stylelint"
|
|
134
125
|
|
|
135
|
-
|
|
136
|
-
/** @type {import("stylelint").Config} */
|
|
137
|
-
export default {
|
|
138
|
-
extends: "@dvukovic/style-guide/src/stylelint/configs/core.js",
|
|
139
|
-
}
|
|
140
|
-
```
|
|
141
|
-
|
|
142
|
-
---
|
|
143
|
-
|
|
144
|
-
## CSpell
|
|
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
|
-
}
|
|
126
|
+
export default stylelint
|
|
165
127
|
```
|
|
166
128
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
## Package JSON Lint
|
|
129
|
+
## Package.json Configuration
|
|
170
130
|
|
|
171
|
-
|
|
131
|
+
```js
|
|
132
|
+
import { packageJson } from "@dvukovic/style-guide/package-json"
|
|
172
133
|
|
|
173
|
-
|
|
174
|
-
/** @type {import("npm-package-json-lint").NpmPackageJsonLint} */
|
|
175
|
-
export default {
|
|
176
|
-
extends: "@dvukovic/style-guide/src/package-json/configs/core.js",
|
|
177
|
-
}
|
|
134
|
+
export default packageJson
|
|
178
135
|
```
|
|
179
136
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
## Requirements
|
|
137
|
+
## License
|
|
183
138
|
|
|
184
|
-
|
|
185
|
-
- ESLint 9+
|
|
186
|
-
- Prettier 3+
|
|
187
|
-
- Stylelint 16+
|
|
139
|
+
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.99",
|
|
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
|
+
}
|