@santi020k/eslint-config-basic 0.7.1 → 0.8.1
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/CHANGELOG.md +35 -0
- package/README.md +25 -305
- package/dist/chunk-2Z6LYTBS.js +67 -0
- package/dist/chunk-CH2MVUQN.js +213 -0
- package/dist/chunk-SSGAWVVA.js +52 -0
- package/dist/chunk-WGZBHVWD.js +71 -0
- package/dist/cli.d.ts +5 -0
- package/dist/cli.js +100 -0
- package/dist/compose.d.ts +13 -0
- package/dist/compose.js +8 -0
- package/dist/index.d.ts +3 -9
- package/dist/index.js +66 -102
- package/dist/optionals.d.ts +13 -0
- package/dist/optionals.js +8 -0
- package/dist/resolvers.d.ts +12 -0
- package/dist/resolvers.js +8 -0
- package/package.json +55 -18
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,40 @@
|
|
|
1
1
|
# @santi020k/eslint-config-basic
|
|
2
2
|
|
|
3
|
+
## 0.8.1
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 13e8e5a: # Release 0.8.0
|
|
8
|
+
|
|
9
|
+
- **Snippet Fixes**: Resolved ESLint parsing errors in virtual TypeScript files within Markdown, Astro, and VitePress code blocks by disabling type-aware rules for those snippets.
|
|
10
|
+
- **Standalone TS Support**: Restored `disableTypeChecked` configuration in the TypeScript package, ensuring it remains fully functional and parsing-error-free when used without the main composer.
|
|
11
|
+
- **Documentation Reorganization**: Significantly expanded and restructured the documentation site, adding new pages for the Inspector, CLI Tooling, Extensions, and better framework-specific guides.
|
|
12
|
+
- **Branding Update**: Updated the author link label from "Website" to "Author" across all documentation files for improved brand identity.
|
|
13
|
+
- **Composition Improvements**: Refactored the configuration composer to be more robust when handling virtual snippets and framework contracts.
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- # CI & Workflow Stabilization
|
|
18
|
+
|
|
19
|
+
- Fixed invalid `actions/setup-node` version from `@v6` to `@v4` in Release and Docs workflows.
|
|
20
|
+
- Improved CLI test performance and reliability by refactoring integration tests into fast in-memory unit tests.
|
|
21
|
+
- Enabled Turborepo caching in GitHub Actions to significantly reduce PR build times.
|
|
22
|
+
|
|
23
|
+
- Updated dependencies
|
|
24
|
+
- Updated dependencies [13e8e5a]
|
|
25
|
+
- @santi020k/eslint-config-...@0.8.1
|
|
26
|
+
- @santi020k/eslint-config-...@0.8.1
|
|
27
|
+
- @santi020k/eslint-config-...@0.8.1
|
|
28
|
+
- @santi020k/eslint-config-...@0.8.1
|
|
29
|
+
- @santi020k/eslint-config-...@0.8.1
|
|
30
|
+
- @santi020k/eslint-config-...@0.8.1
|
|
31
|
+
- @santi020k/eslint-config-...@0.8.1
|
|
32
|
+
- @santi020k/eslint-config-...@0.8.1
|
|
33
|
+
- @santi020k/eslint-config-...@0.8.1
|
|
34
|
+
- @santi020k/eslint-config-...@0.8.1
|
|
35
|
+
- @santi020k/eslint-config-...@0.8.1
|
|
36
|
+
- @santi020k/eslint-config-...@0.8.1
|
|
37
|
+
|
|
3
38
|
## 0.7.1
|
|
4
39
|
|
|
5
40
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -3,329 +3,49 @@
|
|
|
3
3
|
[](https://github.com/santi020k/eslint-config-basic/actions/workflows/build.yml)
|
|
4
4
|
[](https://www.npmjs.com/package/@santi020k/eslint-config-basic)
|
|
5
5
|
[](https://www.npmjs.com/package/@santi020k/eslint-config-basic)
|
|
6
|
-
[](https://santi020k.github.io/eslint-config-basic/)
|
|
7
|
+
[](https://github.com/santi020k/eslint-config-basic/blob/main/LICENSE)
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
Composable ESLint 10+ flat-config tooling for JavaScript and TypeScript projects, with optional framework packages for React, Next.js, Astro, Vue, Svelte, Solid, Angular, NestJS, and Expo.
|
|
10
10
|
|
|
11
|
-
##
|
|
11
|
+
## Canonical Docs
|
|
12
12
|
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
- **Customization:** While it comes with strong opinions, you can tailor it to suit your project's specific needs.
|
|
13
|
+
- Docs site: [santi020k.github.io/eslint-config-basic](https://santi020k.github.io/eslint-config-basic/)
|
|
14
|
+
- Repository: [github.com/santi020k/eslint-config-basic](https://github.com/santi020k/eslint-config-basic)
|
|
15
|
+
- Author: [santi020k](https://santi020k.me)
|
|
17
16
|
|
|
18
|
-
|
|
17
|
+
> [!NOTE]
|
|
18
|
+
> The docs site is built with VitePress. The planned production hostname is `eslint.santi020k.me`.
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
## Quick Start
|
|
21
21
|
|
|
22
22
|
```bash
|
|
23
|
-
npm install eslint
|
|
23
|
+
npm install -D eslint @santi020k/eslint-config-basic
|
|
24
24
|
```
|
|
25
25
|
|
|
26
|
-
Then, install the configuration package. **Important:** I recommend using a fixed version (do not use `^` or `~`), as any new functionality or change may introduce new linter errors that require manual updates.
|
|
27
|
-
|
|
28
|
-
```bash
|
|
29
|
-
npm install @santi020k/eslint-config-basic --save-dev
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
## Usage
|
|
33
|
-
|
|
34
|
-
Create an `eslint.config.js` file (or update your existing one) and extend **@santi020k/eslint-config-basic** based on your project type.
|
|
35
|
-
|
|
36
|
-
### Basic Usage
|
|
37
|
-
|
|
38
|
-
For a basic JavaScript/Node.js project:
|
|
39
|
-
|
|
40
26
|
```js
|
|
41
27
|
import { eslintConfig } from '@santi020k/eslint-config-basic'
|
|
42
28
|
|
|
43
|
-
export default
|
|
44
|
-
...eslintConfig()
|
|
45
|
-
// Your custom config
|
|
46
|
-
]
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
### Advanced Usage
|
|
50
|
-
|
|
51
|
-
For projects that require specific configurations (e.g., TypeScript, React, Next.js, ...Etc), use the appropriate options:
|
|
52
|
-
|
|
53
|
-
```js
|
|
54
|
-
import { ConfigOption, eslintConfig } from '@santi020k/eslint-config-basic'
|
|
55
|
-
|
|
56
|
-
// TypeScript project
|
|
57
|
-
export default [
|
|
58
|
-
...eslintConfig({ config: [ConfigOption.Ts] })
|
|
59
|
-
// Your custom config
|
|
60
|
-
]
|
|
61
|
-
|
|
62
|
-
// React project
|
|
63
|
-
export default [
|
|
64
|
-
...eslintConfig({ config: [ConfigOption.React] })
|
|
65
|
-
// Your custom config
|
|
66
|
-
]
|
|
67
|
-
|
|
68
|
-
// TypeScript and React project
|
|
69
|
-
export default [
|
|
70
|
-
...eslintConfig({ config: [ConfigOption.React, ConfigOption.Ts] })
|
|
71
|
-
// Your custom config
|
|
72
|
-
]
|
|
73
|
-
|
|
74
|
-
// Next.js project
|
|
75
|
-
export default [
|
|
76
|
-
...eslintConfig({ config: [ConfigOption.Next] })
|
|
77
|
-
// Your custom config
|
|
78
|
-
]
|
|
79
|
-
|
|
80
|
-
// Expo project
|
|
81
|
-
export default [
|
|
82
|
-
...eslintConfig({ config: [ConfigOption.Expo] })
|
|
83
|
-
// Your custom config
|
|
84
|
-
]
|
|
85
|
-
|
|
86
|
-
// Astro project (supports Astro with React)
|
|
87
|
-
export default [
|
|
88
|
-
...eslintConfig({ config: [ConfigOption.Astro] })
|
|
89
|
-
// Your custom config
|
|
90
|
-
]
|
|
91
|
-
|
|
92
|
-
// NestJS project
|
|
93
|
-
export default [
|
|
94
|
-
...eslintConfig({ config: [ConfigOption.Nest] })
|
|
95
|
-
// Your custom config
|
|
96
|
-
]
|
|
97
|
-
|
|
98
|
-
// Vue project
|
|
99
|
-
export default [
|
|
100
|
-
...eslintConfig({ config: [ConfigOption.Vue] })
|
|
101
|
-
// Your custom config
|
|
102
|
-
]
|
|
29
|
+
export default eslintConfig()
|
|
103
30
|
```
|
|
104
31
|
|
|
105
|
-
|
|
32
|
+
## Framework packages
|
|
106
33
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
OptionalOption.Cspell,
|
|
118
|
-
// TailwindCss
|
|
119
|
-
OptionalOption.Tailwind,
|
|
120
|
-
// Vitest and testing-library
|
|
121
|
-
OptionalOption.Vitest,
|
|
122
|
-
// I18next
|
|
123
|
-
OptionalOption.I18next,
|
|
124
|
-
// Mdx
|
|
125
|
-
OptionalOption.Mdx,
|
|
126
|
-
// Markdown
|
|
127
|
-
OptionalOption.Markdown,
|
|
128
|
-
// SonarJS
|
|
129
|
-
OptionalOption.Sonarjs,
|
|
130
|
-
// Stencil
|
|
131
|
-
OptionalOption.Stencil,
|
|
132
|
-
// Playwright
|
|
133
|
-
OptionalOption.Playwright,
|
|
134
|
-
// Prettier
|
|
135
|
-
OptionalOption.Prettier
|
|
136
|
-
]
|
|
137
|
-
})
|
|
138
|
-
// Your custom config
|
|
139
|
-
]
|
|
140
|
-
```
|
|
141
|
-
|
|
142
|
-
### Settings Usage (Experimental)
|
|
143
|
-
|
|
144
|
-
This experimental option allows ESLint to honor your `.gitignore` file:
|
|
145
|
-
|
|
146
|
-
```js
|
|
147
|
-
import { eslintConfig, SettingOption } from '@santi020k/eslint-config-basic'
|
|
148
|
-
|
|
149
|
-
export default [
|
|
150
|
-
...eslintConfig({
|
|
151
|
-
// ESLint will ignore files specified in .gitignore
|
|
152
|
-
settings: [SettingOption.Gitignore]
|
|
153
|
-
})
|
|
154
|
-
// Your custom config
|
|
155
|
-
]
|
|
156
|
-
```
|
|
157
|
-
|
|
158
|
-
## AI Agent Capabilities
|
|
159
|
-
|
|
160
|
-
This project is optimized for AI agents and LLM-based tools. It includes an `.agent/skills/` directory containing specialized workflows, guidelines, and context specific to this monorepo. Agents can automatically use these skills to assist with development, testing, and release processes.
|
|
161
|
-
|
|
162
|
-
## Monorepo Structure
|
|
163
|
-
|
|
164
|
-
This project is a monorepo managed with **Turbo** and **npm Workspaces**.
|
|
165
|
-
|
|
166
|
-
- `packages/basic`: Main package entry point.
|
|
167
|
-
- `packages/core`: Core logic and shared types.
|
|
168
|
-
- `packages/typescript`: TypeScript specific rules.
|
|
169
|
-
- `packages/react`: React and Hooks rules.
|
|
170
|
-
- `packages/next`: Next.js rules.
|
|
171
|
-
- `packages/astro`: Astro rules.
|
|
172
|
-
- `packages/expo`: Expo/React Native rules.
|
|
173
|
-
- `packages/optionals`: Optional configurations (Tailwind, Vitest, etc.).
|
|
174
|
-
- `packages/tests`: Integration tests.
|
|
175
|
-
- `packages/playground`: Testing playground for local development.
|
|
34
|
+
- TypeScript: [`@santi020k/eslint-config-typescript`](https://santi020k.github.io/eslint-config-basic/frameworks/typescript.html)
|
|
35
|
+
- React: [`@santi020k/eslint-config-react`](https://santi020k.github.io/eslint-config-basic/frameworks/react.html)
|
|
36
|
+
- Next.js: [`@santi020k/eslint-config-next`](https://santi020k.github.io/eslint-config-basic/frameworks/next.html)
|
|
37
|
+
- Astro: [`@santi020k/eslint-config-astro`](https://santi020k.github.io/eslint-config-basic/frameworks/astro.html)
|
|
38
|
+
- Vue: [`@santi020k/eslint-config-vue`](https://santi020k.github.io/eslint-config-basic/frameworks/vue.html)
|
|
39
|
+
- Svelte: [`@santi020k/eslint-config-svelte`](https://santi020k.github.io/eslint-config-basic/frameworks/svelte.html)
|
|
40
|
+
- Solid: [`@santi020k/eslint-config-solid`](https://santi020k.github.io/eslint-config-basic/frameworks/solid.html)
|
|
41
|
+
- Angular: [`@santi020k/eslint-config-angular`](https://santi020k.github.io/eslint-config-basic/frameworks/angular.html)
|
|
42
|
+
- NestJS: [`@santi020k/eslint-config-nest`](https://santi020k.github.io/eslint-config-basic/frameworks/nest.html)
|
|
43
|
+
- Expo: [`@santi020k/eslint-config-expo`](https://santi020k.github.io/eslint-config-basic/frameworks/expo.html)
|
|
176
44
|
|
|
177
45
|
## Development
|
|
178
46
|
|
|
179
|
-
If you want to contribute or modify the configurations:
|
|
180
|
-
|
|
181
|
-
### Prerequisites
|
|
182
|
-
|
|
183
|
-
- Node.js (version specified in `.nvmrc`)
|
|
184
|
-
- npm
|
|
185
|
-
|
|
186
|
-
### Setup
|
|
187
|
-
|
|
188
|
-
```bash
|
|
189
|
-
npm install
|
|
190
|
-
```
|
|
191
|
-
|
|
192
|
-
### Useful Commands
|
|
193
|
-
```bash
|
|
194
|
-
npm run build # Build all packages using Turbo
|
|
195
|
-
npm run lint # Lint all packages
|
|
196
|
-
npm run test # Run integration tests
|
|
197
|
-
npm run dev # Development mode with watch
|
|
198
|
-
npm run inspector # Open ESLint config inspector
|
|
199
|
-
npm run docs # Generate API documentation
|
|
200
|
-
```
|
|
201
|
-
|
|
202
|
-
### Publishing Workflow
|
|
203
|
-
|
|
204
|
-
This repository uses **Changesets** (`@changesets/cli`) to automatically handle workspace dependency versioning and publishing to npm.
|
|
205
|
-
|
|
206
|
-
To publish a new version of the packages:
|
|
207
|
-
|
|
208
|
-
1. Make sure you are authenticated with npm in your terminal (`npm login`).
|
|
209
|
-
2. Generate a changeset summarizing your changes:
|
|
210
|
-
```bash
|
|
211
|
-
npm run changeset
|
|
212
|
-
```
|
|
213
|
-
3. Consume the changeset to bump package versions automatically:
|
|
214
|
-
```bash
|
|
215
|
-
npm run version-packages
|
|
216
|
-
```
|
|
217
|
-
4. Build all packages and publish them to npm:
|
|
218
|
-
```bash
|
|
219
|
-
npm run release
|
|
220
|
-
```
|
|
221
|
-
|
|
222
|
-
### ESLint Config Inspector
|
|
223
|
-
|
|
224
|
-
You can visually inspect the generated ESLint configuration using the built-in inspector:
|
|
225
|
-
|
|
226
47
|
```bash
|
|
227
|
-
npm run
|
|
48
|
+
npm run docs:dev
|
|
228
49
|
```
|
|
229
50
|
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
### API Documentation
|
|
233
|
-
|
|
234
|
-
Auto-generated API docs are available online:
|
|
235
|
-
[**https://santi020k.github.io/eslint-config-basic/**](https://santi020k.github.io/eslint-config-basic/)
|
|
236
|
-
|
|
237
|
-
You can also generate them locally:
|
|
238
|
-
|
|
239
|
-
```bash
|
|
240
|
-
npm run docs
|
|
241
|
-
```
|
|
242
|
-
|
|
243
|
-
This outputs markdown documentation to the `docs/` directory.
|
|
244
|
-
|
|
245
|
-
## Compatibility & Known Issues
|
|
246
|
-
|
|
247
|
-
### Astro 5+
|
|
248
|
-
|
|
249
|
-
This package includes robust defaults for Astro projects, including:
|
|
250
|
-
|
|
251
|
-
- Automatic detection of virtual scripts inside `.astro` files.
|
|
252
|
-
- Disabled `react/jsx-no-undef` (Astro handles this).
|
|
253
|
-
- Enforced `never` comma-dangle for Astro templates.
|
|
254
|
-
- Support for JSX/TSX inside Astro components.
|
|
255
|
-
|
|
256
|
-
## Opinionated but Flexible
|
|
257
|
-
|
|
258
|
-
This ESLint configuration is based on my personal preferences and practices, and it may evolve over time. **Important:** I recommend using a fixed version to avoid unexpected changes that might introduce new linter errors. To ensure stability, do not use `^` or `~` when specifying the version. If a rule feels too strict, consider changing it from an error to a warning to allow more flexibility during development.
|
|
259
|
-
|
|
260
|
-
## Scripts
|
|
261
|
-
|
|
262
|
-
Add the following useful scripts to your `package.json`:
|
|
263
|
-
|
|
264
|
-
```json
|
|
265
|
-
"scripts": {
|
|
266
|
-
"lint": "eslint . --report-unused-disable-directives",
|
|
267
|
-
"lint:fix": "npm run lint -- --fix"
|
|
268
|
-
}
|
|
269
|
-
```
|
|
270
|
-
|
|
271
|
-
## How to Implement in an Existing Project
|
|
272
|
-
|
|
273
|
-
1. Install the Dependencies: Ensure that both ESLint and this configuration package are installed.
|
|
274
|
-
2. Update Your ESLint Configuration: Extend **@santi020k/eslint-config-basic** in your ESLint configuration file as shown above.
|
|
275
|
-
3. Run ESLint: Lint your project files and automatically fix issues if possible:
|
|
276
|
-
|
|
277
|
-
```bash
|
|
278
|
-
npm run lint
|
|
279
|
-
npm run lint:fix
|
|
280
|
-
```
|
|
281
|
-
|
|
282
|
-
4. **Adjust as Necessary:** Review and modify the linting rules based on your project's needs. Some rules might be too strict or not applicable; feel free to disable or adjust them.
|
|
283
|
-
|
|
284
|
-
## Future Features
|
|
285
|
-
|
|
286
|
-
- [x] Testing
|
|
287
|
-
- [x] Refactored rules structure (Monorepo transition)
|
|
288
|
-
- [x] Astro and Expo support
|
|
289
|
-
- [x] Enhanced documentation
|
|
290
|
-
- [x] Additional framework support (contributions welcome!):
|
|
291
|
-
- [x] Vue
|
|
292
|
-
- [ ] Angular
|
|
293
|
-
- [x] NestJS
|
|
294
|
-
|
|
295
|
-
## Contributing
|
|
296
|
-
|
|
297
|
-
Contributions are welcome! Please read the [Contributing Guide](CONTRIBUTING.md) for details on setting up the project, adding new configurations, and submitting pull requests.
|
|
298
|
-
|
|
299
|
-
## Acknowledgements
|
|
300
|
-
|
|
301
|
-
Special thanks to the developers and maintainers of the following libraries, which form the backbone of this ESLint configuration:
|
|
302
|
-
|
|
303
|
-
- [eslint-config-standard](https://www.npmjs.com/package/eslint-config-standard)
|
|
304
|
-
- [eslint-plugin-import](https://www.npmjs.com/package/eslint-plugin-import)
|
|
305
|
-
- [eslint-plugin-n](https://www.npmjs.com/package/eslint-plugin-n)
|
|
306
|
-
- [eslint-plugin-promise](https://www.npmjs.com/package/eslint-plugin-promise)
|
|
307
|
-
- [eslint-plugin-react](https://www.npmjs.com/package/eslint-plugin-react)
|
|
308
|
-
- [eslint-plugin-react-hooks](https://www.npmjs.com/package/eslint-plugin-react-hooks)
|
|
309
|
-
- [eslint-plugin-jsx-a11y](https://www.npmjs.com/package/eslint-plugin-jsx-a11y)
|
|
310
|
-
- [eslint-plugin-simple-import-sort](https://www.npmjs.com/package/eslint-plugin-simple-import-sort)
|
|
311
|
-
- [eslint-plugin-sonarjs](https://www.npmjs.com/package/eslint-plugin-sonarjs)
|
|
312
|
-
- [eslint-plugin-unused-imports](https://www.npmjs.com/package/eslint-plugin-unused-imports)
|
|
313
|
-
- [@stylistic/eslint-plugin](https://www.npmjs.com/package/@stylistic/eslint-plugin)
|
|
314
|
-
- [@typescript-eslint](https://www.npmjs.com/package/@typescript-eslint/eslint-plugin)
|
|
315
|
-
- [@cspell/eslint-plugin](https://www.npmjs.com/package/@cspell/eslint-plugin)
|
|
316
|
-
- [eslint-plugin-better-tailwindcss](https://www.npmjs.com/package/eslint-plugin-better-tailwindcss)
|
|
317
|
-
- [eslint-plugin-vitest](https://www.npmjs.com/package/eslint-plugin-vitest)
|
|
318
|
-
- [eslint-plugin-astro](https://www.npmjs.com/package/eslint-plugin-astro)
|
|
319
|
-
- [eslint-plugin-next](https://www.npmjs.com/package/eslint-plugin-next)
|
|
320
|
-
- [eslint-plugin-vue](https://www.npmjs.com/package/eslint-plugin-vue)
|
|
321
|
-
- [eslint-plugin-unicorn](https://www.npmjs.com/package/eslint-plugin-unicorn)
|
|
322
|
-
- [eslint-plugin-regexp](https://www.npmjs.com/package/eslint-plugin-regexp)
|
|
323
|
-
- [eslint-plugin-i18next](https://www.npmjs.com/package/eslint-plugin-i18next)
|
|
324
|
-
- [eslint-plugin-mdx](https://www.npmjs.com/package/eslint-plugin-mdx)
|
|
325
|
-
- [eslint-config-prettier](https://www.npmjs.com/package/eslint-config-prettier)
|
|
326
|
-
- [eslint-config-expo](https://www.npmjs.com/package/eslint-config-expo)
|
|
327
|
-
- ...and many others
|
|
328
|
-
|
|
329
|
-
Their ongoing contributions help maintain the high standards of code quality we all strive for.
|
|
330
|
-
|
|
331
|
-
Thank you for using **@santi020k/eslint-config-basic**. Together, let's write cleaner, more maintainable code!
|
|
51
|
+
That command regenerates the API markdown and starts the VitePress site from [`packages/docs`](/Users/smith/Projects/santi020k/eslint-config-basic/packages/docs).
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// src/compose.ts
|
|
2
|
+
import tsEslint from "typescript-eslint";
|
|
3
|
+
var promoteRuleSeverity = (value) => {
|
|
4
|
+
if (value === void 0) return void 0;
|
|
5
|
+
if (value === "warn" || value === 1) return "error";
|
|
6
|
+
if (Array.isArray(value) && (value[0] === "warn" || value[0] === 1)) {
|
|
7
|
+
return ["error", ...value.slice(1)];
|
|
8
|
+
}
|
|
9
|
+
return value;
|
|
10
|
+
};
|
|
11
|
+
var applyStrictMode = (configs, strict) => {
|
|
12
|
+
if (!strict) return configs;
|
|
13
|
+
return configs.map((config) => {
|
|
14
|
+
if (config.rules) {
|
|
15
|
+
const strictRules = Object.fromEntries(
|
|
16
|
+
Object.entries(config.rules).map(([key, value]) => [key, promoteRuleSeverity(value)])
|
|
17
|
+
);
|
|
18
|
+
return { ...config, rules: strictRules };
|
|
19
|
+
}
|
|
20
|
+
return config;
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
var getTypedRulesOverrides = () => ({
|
|
24
|
+
name: "eslint-config-basic/typed-rules-overrides",
|
|
25
|
+
files: [
|
|
26
|
+
"**/*.js",
|
|
27
|
+
"**/*.jsx",
|
|
28
|
+
"**/*.mjs",
|
|
29
|
+
"**/*.cjs",
|
|
30
|
+
"**/*.md",
|
|
31
|
+
"**/*.mdx",
|
|
32
|
+
"**/*.md/*.ts",
|
|
33
|
+
"**/*.md/*.tsx",
|
|
34
|
+
"**/*.mdx/*.ts",
|
|
35
|
+
"**/*.mdx/*.tsx",
|
|
36
|
+
"**/*.astro/*.js",
|
|
37
|
+
"**/*.astro/*.ts",
|
|
38
|
+
"**/*.vue/*.ts",
|
|
39
|
+
"**/*.vue/*.tsx",
|
|
40
|
+
"**/*.svelte/*.ts",
|
|
41
|
+
"**/*.svelte/*.tsx",
|
|
42
|
+
"**/.vitepress/**/*.ts",
|
|
43
|
+
"**/.vitepress/**/*.mts",
|
|
44
|
+
"**/.vitepress/**/*.tsx",
|
|
45
|
+
"**/.vitepress/**/*.js",
|
|
46
|
+
"**/.vitepress/**/*.mjs",
|
|
47
|
+
"**/.vitepress/**/*.jsx"
|
|
48
|
+
],
|
|
49
|
+
languageOptions: {
|
|
50
|
+
parserOptions: {
|
|
51
|
+
project: null,
|
|
52
|
+
program: null,
|
|
53
|
+
projectService: false,
|
|
54
|
+
allowDefaultProject: true
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
rules: {
|
|
58
|
+
...tsEslint.configs.disableTypeChecked.rules,
|
|
59
|
+
"no-unused-expressions": "off",
|
|
60
|
+
"@typescript-eslint/no-unused-expressions": "off"
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
export {
|
|
65
|
+
applyStrictMode,
|
|
66
|
+
getTypedRulesOverrides
|
|
67
|
+
};
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import {
|
|
2
|
+
applyStrictMode,
|
|
3
|
+
getTypedRulesOverrides
|
|
4
|
+
} from "./chunk-2Z6LYTBS.js";
|
|
5
|
+
import {
|
|
6
|
+
getOptionalConfigs,
|
|
7
|
+
getPrettierConfig
|
|
8
|
+
} from "./chunk-WGZBHVWD.js";
|
|
9
|
+
import {
|
|
10
|
+
resolveFramework,
|
|
11
|
+
resolvePreset
|
|
12
|
+
} from "./chunk-SSGAWVVA.js";
|
|
13
|
+
|
|
14
|
+
// src/index.ts
|
|
15
|
+
import {
|
|
16
|
+
coreConfig,
|
|
17
|
+
createCoreConfig,
|
|
18
|
+
detectProjectOptions,
|
|
19
|
+
gitignore,
|
|
20
|
+
hasReactConfig,
|
|
21
|
+
NextMode,
|
|
22
|
+
Runtime,
|
|
23
|
+
Setting
|
|
24
|
+
} from "@santi020k/eslint-config-core";
|
|
25
|
+
import { createTypescriptConfig } from "@santi020k/eslint-config-typescript";
|
|
26
|
+
import {
|
|
27
|
+
Library,
|
|
28
|
+
Tool,
|
|
29
|
+
Extension,
|
|
30
|
+
Setting as Setting2,
|
|
31
|
+
Runtime as Runtime2,
|
|
32
|
+
Preset,
|
|
33
|
+
Testing,
|
|
34
|
+
Format,
|
|
35
|
+
NextMode as NextMode2,
|
|
36
|
+
ReactConfigKeys,
|
|
37
|
+
hasReactConfig as hasReactConfig2,
|
|
38
|
+
coreConfig as coreConfig2,
|
|
39
|
+
createCoreConfig as createCoreConfig2,
|
|
40
|
+
getGlobalsForRuntime,
|
|
41
|
+
jsConfig,
|
|
42
|
+
gitignore as gitignore2,
|
|
43
|
+
detectProjectOptions as detectProjectOptions2
|
|
44
|
+
} from "@santi020k/eslint-config-core";
|
|
45
|
+
import { typescriptConfig, tsConfig } from "@santi020k/eslint-config-typescript";
|
|
46
|
+
import {
|
|
47
|
+
cspell,
|
|
48
|
+
cypress,
|
|
49
|
+
graphql,
|
|
50
|
+
i18next,
|
|
51
|
+
jest,
|
|
52
|
+
jsdoc,
|
|
53
|
+
jsonc,
|
|
54
|
+
markdown,
|
|
55
|
+
mdx,
|
|
56
|
+
perfectionist,
|
|
57
|
+
playwright,
|
|
58
|
+
prettier,
|
|
59
|
+
regexp,
|
|
60
|
+
security,
|
|
61
|
+
sonarjs,
|
|
62
|
+
stencil,
|
|
63
|
+
storybook,
|
|
64
|
+
swagger,
|
|
65
|
+
tailwind,
|
|
66
|
+
tanstackQuery,
|
|
67
|
+
tanstackRouter,
|
|
68
|
+
testingLibrary,
|
|
69
|
+
toml,
|
|
70
|
+
unicorn,
|
|
71
|
+
vitest,
|
|
72
|
+
yaml
|
|
73
|
+
} from "@santi020k/eslint-config-optionals";
|
|
74
|
+
var eslintConfig = (options) => {
|
|
75
|
+
const detected = options === void 0 ? detectProjectOptions() : {};
|
|
76
|
+
const presetDefaults = options?.preset ? resolvePreset(options.preset) : {};
|
|
77
|
+
const {
|
|
78
|
+
typescript = presetDefaults.typescript ?? detected.typescript ?? false,
|
|
79
|
+
libraries = presetDefaults.libraries ?? detected.libraries ?? [],
|
|
80
|
+
testing = presetDefaults.testing ?? detected.testing ?? [],
|
|
81
|
+
formats = presetDefaults.formats ?? detected.formats ?? [],
|
|
82
|
+
tools = presetDefaults.tools ?? detected.tools ?? [],
|
|
83
|
+
extensions = presetDefaults.extensions ?? detected.extensions ?? [],
|
|
84
|
+
settings = detected.settings ?? [],
|
|
85
|
+
strict = options?.strict ?? false,
|
|
86
|
+
runtime = presetDefaults.runtime ?? detected.runtime ?? Runtime.Universal,
|
|
87
|
+
tsconfigRootDir = options?.tsconfigRootDir,
|
|
88
|
+
nextMode = presetDefaults.nextMode ?? detected.nextMode ?? NextMode.Pages,
|
|
89
|
+
frameworks = { ...presetDefaults.frameworks, ...options?.frameworks }
|
|
90
|
+
} = options ?? {};
|
|
91
|
+
const uniqueLibraries = [...new Set(libraries)];
|
|
92
|
+
const uniqueTesting = [...new Set(testing)];
|
|
93
|
+
const uniqueFormats = [...new Set(formats)];
|
|
94
|
+
const uniqueTools = [...new Set(tools)];
|
|
95
|
+
const uniqueExtensions = [...new Set(extensions)];
|
|
96
|
+
const uniqueSettings = [...new Set(settings)];
|
|
97
|
+
if ((frameworks.next || frameworks.expo) && !frameworks.react) {
|
|
98
|
+
throw new TypeError(
|
|
99
|
+
"Next and Expo configurations require frameworks.react. Import @santi020k/eslint-config-react and pass it via frameworks.react."
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
const reactParam = resolveFramework("react", frameworks.react);
|
|
103
|
+
const nextParam = resolveFramework("next", frameworks.next);
|
|
104
|
+
const astroParam = resolveFramework("astro", frameworks.astro);
|
|
105
|
+
const expoParam = resolveFramework("expo", frameworks.expo);
|
|
106
|
+
const nestParam = resolveFramework("nest", frameworks.nest);
|
|
107
|
+
const vueParam = resolveFramework("vue", frameworks.vue);
|
|
108
|
+
const svelteParam = resolveFramework("svelte", frameworks.svelte);
|
|
109
|
+
const solidParam = resolveFramework("solid", frameworks.solid);
|
|
110
|
+
const angularParam = resolveFramework("angular", frameworks.angular);
|
|
111
|
+
const hasReact = hasReactConfig({ frameworks });
|
|
112
|
+
const useGitignore = !uniqueSettings.includes(Setting.NoGitignore);
|
|
113
|
+
const runtimeCoreConfig = runtime !== Runtime.Universal ? createCoreConfig(runtime) : coreConfig;
|
|
114
|
+
const configs = [
|
|
115
|
+
// Settings
|
|
116
|
+
...useGitignore ? gitignore : [],
|
|
117
|
+
// Global TSConfig Root Dir fix
|
|
118
|
+
...tsconfigRootDir ? [{
|
|
119
|
+
name: "eslint-config-basic/tsconfig-root-dir",
|
|
120
|
+
languageOptions: {
|
|
121
|
+
parserOptions: {
|
|
122
|
+
tsconfigRootDir
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}] : [],
|
|
126
|
+
// Core JS config with runtime-aware globals
|
|
127
|
+
...runtimeCoreConfig,
|
|
128
|
+
// React config (included if any React-based framework is used/passed)
|
|
129
|
+
...hasReact ? reactParam : [],
|
|
130
|
+
// Framework-specific configs (Modularized)
|
|
131
|
+
...typescript ? createTypescriptConfig({ tsconfigRootDir }) : [],
|
|
132
|
+
...nextParam,
|
|
133
|
+
// Next.js App Router overrides (#12)
|
|
134
|
+
...frameworks.next && nextMode === NextMode.AppRouter ? [
|
|
135
|
+
{
|
|
136
|
+
name: "eslint-config-next/app-router-overrides",
|
|
137
|
+
files: ["app/**/*.{ts,tsx}"],
|
|
138
|
+
rules: {
|
|
139
|
+
"@next/next/no-html-link-for-pages": "off"
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
] : [],
|
|
143
|
+
...astroParam,
|
|
144
|
+
...expoParam,
|
|
145
|
+
...nestParam,
|
|
146
|
+
...vueParam,
|
|
147
|
+
...svelteParam,
|
|
148
|
+
...solidParam,
|
|
149
|
+
...angularParam,
|
|
150
|
+
// Optionals
|
|
151
|
+
...getOptionalConfigs(
|
|
152
|
+
uniqueLibraries,
|
|
153
|
+
uniqueTools,
|
|
154
|
+
uniqueTesting,
|
|
155
|
+
uniqueFormats,
|
|
156
|
+
uniqueExtensions
|
|
157
|
+
),
|
|
158
|
+
// Global overrides for non-TS files
|
|
159
|
+
getTypedRulesOverrides(),
|
|
160
|
+
// Prettier always last
|
|
161
|
+
...getPrettierConfig(uniqueTools)
|
|
162
|
+
];
|
|
163
|
+
return applyStrictMode(configs, strict);
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
export {
|
|
167
|
+
eslintConfig,
|
|
168
|
+
Library,
|
|
169
|
+
Tool,
|
|
170
|
+
Extension,
|
|
171
|
+
Setting2 as Setting,
|
|
172
|
+
Runtime2 as Runtime,
|
|
173
|
+
Preset,
|
|
174
|
+
Testing,
|
|
175
|
+
Format,
|
|
176
|
+
NextMode2 as NextMode,
|
|
177
|
+
ReactConfigKeys,
|
|
178
|
+
hasReactConfig2 as hasReactConfig,
|
|
179
|
+
coreConfig2 as coreConfig,
|
|
180
|
+
createCoreConfig2 as createCoreConfig,
|
|
181
|
+
getGlobalsForRuntime,
|
|
182
|
+
jsConfig,
|
|
183
|
+
gitignore2 as gitignore,
|
|
184
|
+
detectProjectOptions2 as detectProjectOptions,
|
|
185
|
+
typescriptConfig,
|
|
186
|
+
tsConfig,
|
|
187
|
+
cspell,
|
|
188
|
+
cypress,
|
|
189
|
+
graphql,
|
|
190
|
+
i18next,
|
|
191
|
+
jest,
|
|
192
|
+
jsdoc,
|
|
193
|
+
jsonc,
|
|
194
|
+
markdown,
|
|
195
|
+
mdx,
|
|
196
|
+
perfectionist,
|
|
197
|
+
playwright,
|
|
198
|
+
prettier,
|
|
199
|
+
regexp,
|
|
200
|
+
security,
|
|
201
|
+
sonarjs,
|
|
202
|
+
stencil,
|
|
203
|
+
storybook,
|
|
204
|
+
swagger,
|
|
205
|
+
tailwind,
|
|
206
|
+
tanstackQuery,
|
|
207
|
+
tanstackRouter,
|
|
208
|
+
testingLibrary,
|
|
209
|
+
toml,
|
|
210
|
+
unicorn,
|
|
211
|
+
vitest,
|
|
212
|
+
yaml
|
|
213
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// src/resolvers.ts
|
|
2
|
+
import {
|
|
3
|
+
Extension,
|
|
4
|
+
Format,
|
|
5
|
+
Library,
|
|
6
|
+
Preset,
|
|
7
|
+
Runtime,
|
|
8
|
+
Testing,
|
|
9
|
+
Tool
|
|
10
|
+
} from "@santi020k/eslint-config-core";
|
|
11
|
+
var resolveFramework = (frameworkName, framework) => {
|
|
12
|
+
if (!framework) return [];
|
|
13
|
+
if (framework === true) {
|
|
14
|
+
throw new TypeError(
|
|
15
|
+
`Framework "${frameworkName}" requires an imported config. Install @santi020k/eslint-config-${frameworkName} and pass it via frameworks.${frameworkName}.`
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
return Array.isArray(framework) ? framework : framework.default;
|
|
19
|
+
};
|
|
20
|
+
var resolvePreset = (preset) => {
|
|
21
|
+
switch (preset) {
|
|
22
|
+
case Preset.Basic:
|
|
23
|
+
return { runtime: Runtime.Universal };
|
|
24
|
+
case Preset.Node:
|
|
25
|
+
return {
|
|
26
|
+
typescript: true,
|
|
27
|
+
runtime: Runtime.Node
|
|
28
|
+
};
|
|
29
|
+
case Preset.Browser:
|
|
30
|
+
return {
|
|
31
|
+
typescript: true,
|
|
32
|
+
runtime: Runtime.Browser
|
|
33
|
+
};
|
|
34
|
+
case Preset.All:
|
|
35
|
+
return {
|
|
36
|
+
typescript: true,
|
|
37
|
+
libraries: Object.values(Library),
|
|
38
|
+
tools: Object.values(Tool),
|
|
39
|
+
testing: Object.values(Testing),
|
|
40
|
+
formats: Object.values(Format),
|
|
41
|
+
extensions: Object.values(Extension),
|
|
42
|
+
runtime: Runtime.Universal
|
|
43
|
+
};
|
|
44
|
+
default:
|
|
45
|
+
return {};
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export {
|
|
50
|
+
resolveFramework,
|
|
51
|
+
resolvePreset
|
|
52
|
+
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// src/optionals.ts
|
|
2
|
+
import {
|
|
3
|
+
Extension,
|
|
4
|
+
Format,
|
|
5
|
+
Library,
|
|
6
|
+
Testing,
|
|
7
|
+
Tool
|
|
8
|
+
} from "@santi020k/eslint-config-core";
|
|
9
|
+
import {
|
|
10
|
+
cspell,
|
|
11
|
+
cypress,
|
|
12
|
+
graphql,
|
|
13
|
+
i18next,
|
|
14
|
+
jest,
|
|
15
|
+
jsdoc,
|
|
16
|
+
jsonc,
|
|
17
|
+
markdown,
|
|
18
|
+
mdx,
|
|
19
|
+
perfectionist,
|
|
20
|
+
playwright,
|
|
21
|
+
prettier,
|
|
22
|
+
regexp,
|
|
23
|
+
security,
|
|
24
|
+
sonarjs,
|
|
25
|
+
stencil,
|
|
26
|
+
storybook,
|
|
27
|
+
swagger,
|
|
28
|
+
tailwind,
|
|
29
|
+
tanstackQuery,
|
|
30
|
+
tanstackRouter,
|
|
31
|
+
testingLibrary,
|
|
32
|
+
toml,
|
|
33
|
+
unicorn,
|
|
34
|
+
vitest,
|
|
35
|
+
yaml
|
|
36
|
+
} from "@santi020k/eslint-config-optionals";
|
|
37
|
+
var getOptionalConfigs = (libraries, tools, testing, formats, extensions) => {
|
|
38
|
+
const configs = [];
|
|
39
|
+
if (tools.includes(Tool.Cspell)) configs.push(...cspell);
|
|
40
|
+
if (libraries.includes(Library.Tailwind)) configs.push(...tailwind);
|
|
41
|
+
if (libraries.includes(Library.I18next)) configs.push(...i18next);
|
|
42
|
+
if (libraries.includes(Library.Stencil)) configs.push(...stencil);
|
|
43
|
+
if (libraries.includes(Library.TanstackQuery)) configs.push(...tanstackQuery);
|
|
44
|
+
if (libraries.includes(Library.TanstackRouter)) configs.push(...tanstackRouter);
|
|
45
|
+
if (libraries.includes(Library.Storybook)) configs.push(...storybook);
|
|
46
|
+
if (testing.includes(Testing.Vitest)) configs.push(...vitest);
|
|
47
|
+
if (testing.includes(Testing.Playwright)) configs.push(...playwright);
|
|
48
|
+
if (testing.includes(Testing.Jest)) configs.push(...jest);
|
|
49
|
+
if (testing.includes(Testing.Cypress)) configs.push(...cypress);
|
|
50
|
+
if (testing.includes(Testing.TestingLibrary)) configs.push(...testingLibrary);
|
|
51
|
+
if (formats.includes(Format.Mdx)) configs.push(...mdx);
|
|
52
|
+
if (formats.includes(Format.Markdown)) configs.push(...markdown);
|
|
53
|
+
if (formats.includes(Format.Jsonc)) configs.push(...jsonc);
|
|
54
|
+
if (formats.includes(Format.Yaml)) configs.push(...yaml);
|
|
55
|
+
if (formats.includes(Format.Toml)) configs.push(...toml);
|
|
56
|
+
if (formats.includes(Format.Graphql)) configs.push(...graphql);
|
|
57
|
+
if (extensions.includes(Extension.Regexp)) configs.push(...regexp);
|
|
58
|
+
if (extensions.includes(Extension.Unicorn)) configs.push(...unicorn);
|
|
59
|
+
if (extensions.includes(Extension.Sonarjs)) configs.push(...sonarjs);
|
|
60
|
+
if (extensions.includes(Extension.Security)) configs.push(...security);
|
|
61
|
+
if (extensions.includes(Extension.Perfectionist)) configs.push(...perfectionist);
|
|
62
|
+
if (tools.includes(Tool.Jsdoc)) configs.push(...jsdoc);
|
|
63
|
+
if (tools.includes(Tool.Swagger)) configs.push(...swagger);
|
|
64
|
+
return configs;
|
|
65
|
+
};
|
|
66
|
+
var getPrettierConfig = (tools) => tools.includes(Tool.Prettier) ? prettier : [];
|
|
67
|
+
|
|
68
|
+
export {
|
|
69
|
+
getOptionalConfigs,
|
|
70
|
+
getPrettierConfig
|
|
71
|
+
};
|
package/dist/cli.d.ts
ADDED
package/dist/cli.js
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
detectProjectOptions
|
|
4
|
+
} from "./chunk-CH2MVUQN.js";
|
|
5
|
+
import "./chunk-2Z6LYTBS.js";
|
|
6
|
+
import "./chunk-WGZBHVWD.js";
|
|
7
|
+
import "./chunk-SSGAWVVA.js";
|
|
8
|
+
|
|
9
|
+
// src/cli.ts
|
|
10
|
+
import { existsSync, readFileSync, writeFileSync } from "fs";
|
|
11
|
+
import { basename, join } from "path";
|
|
12
|
+
import { fileURLToPath } from "url";
|
|
13
|
+
var getDefaultConfigFilename = (cwd) => {
|
|
14
|
+
const packageJsonPath = join(cwd, "package.json");
|
|
15
|
+
if (!existsSync(packageJsonPath)) return "eslint.config.mjs";
|
|
16
|
+
try {
|
|
17
|
+
const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
|
|
18
|
+
return packageJson.type === "module" ? "eslint.config.js" : "eslint.config.mjs";
|
|
19
|
+
} catch {
|
|
20
|
+
return "eslint.config.mjs";
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
var resolveConfigPath = (cwd) => {
|
|
24
|
+
const existingConfigPath = [
|
|
25
|
+
"eslint.config.js",
|
|
26
|
+
"eslint.config.mjs"
|
|
27
|
+
].map((filename) => join(cwd, filename)).find(existsSync);
|
|
28
|
+
return existingConfigPath ?? join(cwd, getDefaultConfigFilename(cwd));
|
|
29
|
+
};
|
|
30
|
+
var getFrameworkKeys = (frameworks) => {
|
|
31
|
+
const frameworkKeys = new Set(Object.keys(frameworks ?? {}));
|
|
32
|
+
if (frameworkKeys.has("next") || frameworkKeys.has("expo")) {
|
|
33
|
+
frameworkKeys.add("react");
|
|
34
|
+
}
|
|
35
|
+
return [...frameworkKeys];
|
|
36
|
+
};
|
|
37
|
+
var createConfigContent = (cwd) => {
|
|
38
|
+
const options = detectProjectOptions(cwd);
|
|
39
|
+
const frameworkKeys = getFrameworkKeys(options.frameworks);
|
|
40
|
+
const imports = ["import { eslintConfig } from '@santi020k/eslint-config-basic'"];
|
|
41
|
+
frameworkKeys.forEach((key) => {
|
|
42
|
+
imports.push(`import ${key} from '@santi020k/eslint-config-${key}'`);
|
|
43
|
+
});
|
|
44
|
+
const configContent = `${imports.join("\n")}
|
|
45
|
+
|
|
46
|
+
export default eslintConfig({
|
|
47
|
+
typescript: ${JSON.stringify(options.typescript ?? false)},
|
|
48
|
+
frameworks: {
|
|
49
|
+
${frameworkKeys.map((key) => `${key}: ${key}`).join(",\n ")}
|
|
50
|
+
},
|
|
51
|
+
libraries: ${JSON.stringify(options.libraries ?? [], null, 2)},
|
|
52
|
+
testing: ${JSON.stringify(options.testing ?? [], null, 2)},
|
|
53
|
+
formats: ${JSON.stringify(options.formats ?? [], null, 2)},
|
|
54
|
+
tools: ${JSON.stringify(options.tools ?? [], null, 2)},
|
|
55
|
+
extensions: ${JSON.stringify(options.extensions ?? [], null, 2)},
|
|
56
|
+
runtime: ${JSON.stringify(options.runtime ?? "universal")},
|
|
57
|
+
settings: ${JSON.stringify(options.settings ?? [], null, 2)}
|
|
58
|
+
})
|
|
59
|
+
`;
|
|
60
|
+
return {
|
|
61
|
+
configPath: resolveConfigPath(cwd),
|
|
62
|
+
configContent
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
var handleInit = (cwd = process.cwd()) => {
|
|
66
|
+
const configPath = resolveConfigPath(cwd);
|
|
67
|
+
if (existsSync(configPath)) {
|
|
68
|
+
console.warn(`\u26A0\uFE0F ${basename(configPath)} already exists. Skipping...`);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
console.log("\u{1F50D} Detecting project settings...");
|
|
72
|
+
const { configContent } = createConfigContent(cwd);
|
|
73
|
+
writeFileSync(configPath, configContent);
|
|
74
|
+
console.log(`\u2705 Created ${basename(configPath)} with auto-detected settings!`);
|
|
75
|
+
console.log("\u{1F680} Ready to lint!");
|
|
76
|
+
};
|
|
77
|
+
var handleUpdate = (cwd = process.cwd()) => {
|
|
78
|
+
console.log("\u{1F50D} Detecting project settings...");
|
|
79
|
+
const { configPath, configContent } = createConfigContent(cwd);
|
|
80
|
+
writeFileSync(configPath, configContent);
|
|
81
|
+
console.log(`\u2705 Updated ${basename(configPath)} with auto-detected settings!`);
|
|
82
|
+
console.log("\u{1F680} Ready to lint!");
|
|
83
|
+
};
|
|
84
|
+
var run = () => {
|
|
85
|
+
const command = process.argv[2];
|
|
86
|
+
if (command === "init") {
|
|
87
|
+
handleInit();
|
|
88
|
+
} else if (command === "update") {
|
|
89
|
+
handleUpdate();
|
|
90
|
+
} else {
|
|
91
|
+
console.log("Usage: basic-eslint <init|update>");
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
if (process.argv[1] && (process.argv[1] === fileURLToPath(import.meta.url) || process.argv[1].endsWith("cli.js") || process.argv[1].endsWith("cli.ts"))) {
|
|
95
|
+
run();
|
|
96
|
+
}
|
|
97
|
+
export {
|
|
98
|
+
handleInit,
|
|
99
|
+
handleUpdate
|
|
100
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { FlatConfigArray } from '@santi020k/eslint-config-core';
|
|
2
|
+
import { TSESLint } from '@typescript-eslint/utils';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Applies strict mode by promoting all 'warn' rules to 'error'.
|
|
6
|
+
*/
|
|
7
|
+
declare const applyStrictMode: (configs: FlatConfigArray, strict: boolean) => FlatConfigArray;
|
|
8
|
+
/**
|
|
9
|
+
* Returns global overrides for non-TS files to prevent typed rules errors (#15).
|
|
10
|
+
*/
|
|
11
|
+
declare const getTypedRulesOverrides: () => TSESLint.FlatConfig.Config;
|
|
12
|
+
|
|
13
|
+
export { applyStrictMode, getTypedRulesOverrides };
|
package/dist/compose.js
ADDED
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
import { EslintConfigOptions, FlatConfigArray } from '@santi020k/eslint-config-core';
|
|
2
|
-
export {
|
|
2
|
+
export { EslintConfigOptions, Extension, FlatConfigArray, Format, ImportedFramework, Library, NextMode, Preset, ReactConfigKeys, Runtime, Setting, Testing, Tool, coreConfig, createCoreConfig, detectProjectOptions, getGlobalsForRuntime, gitignore, hasReactConfig, jsConfig } from '@santi020k/eslint-config-core';
|
|
3
3
|
export { tsConfig, typescriptConfig } from '@santi020k/eslint-config-typescript';
|
|
4
|
-
export {
|
|
5
|
-
export { nextConfig } from '@santi020k/eslint-config-next';
|
|
6
|
-
export { astroConfig } from '@santi020k/eslint-config-astro';
|
|
7
|
-
export { expoConfig } from '@santi020k/eslint-config-expo';
|
|
8
|
-
export { nestConfig } from '@santi020k/eslint-config-nest';
|
|
9
|
-
export { vueConfig } from '@santi020k/eslint-config-vue';
|
|
10
|
-
export { cspell, i18next, markdown, mdx, playwright, prettier, regexp, sonarjs, stencil, tailwind, unicorn, vitest } from '@santi020k/eslint-config-optionals';
|
|
4
|
+
export { cspell, cypress, graphql, i18next, jest, jsdoc, jsonc, markdown, mdx, perfectionist, playwright, prettier, regexp, security, sonarjs, stencil, storybook, swagger, tailwind, tanstackQuery, tanstackRouter, testingLibrary, toml, unicorn, vitest, yaml } from '@santi020k/eslint-config-optionals';
|
|
11
5
|
|
|
12
6
|
/**
|
|
13
7
|
* Generates the ESLint configuration array, applying configurations
|
|
@@ -16,6 +10,6 @@ export { cspell, i18next, markdown, mdx, playwright, prettier, regexp, sonarjs,
|
|
|
16
10
|
* @param {EslintConfigOptions} options - Configuration and optional settings
|
|
17
11
|
* @returns {FlatConfigArray} The final ESLint configuration array
|
|
18
12
|
*/
|
|
19
|
-
declare const eslintConfig: (
|
|
13
|
+
declare const eslintConfig: (options?: EslintConfigOptions) => FlatConfigArray;
|
|
20
14
|
|
|
21
15
|
export { eslintConfig };
|
package/dist/index.js
CHANGED
|
@@ -1,135 +1,99 @@
|
|
|
1
|
-
// src/index.ts
|
|
2
1
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
Extension,
|
|
3
|
+
Format,
|
|
4
|
+
Library,
|
|
5
|
+
NextMode,
|
|
6
|
+
Preset,
|
|
7
|
+
ReactConfigKeys,
|
|
8
|
+
Runtime,
|
|
9
|
+
Setting,
|
|
10
|
+
Testing,
|
|
11
|
+
Tool,
|
|
9
12
|
coreConfig,
|
|
10
|
-
|
|
11
|
-
gitignore
|
|
12
|
-
} from "@santi020k/eslint-config-core";
|
|
13
|
-
import { typescriptConfig, tsConfig } from "@santi020k/eslint-config-typescript";
|
|
14
|
-
import { reactConfig } from "@santi020k/eslint-config-react";
|
|
15
|
-
import { nextConfig } from "@santi020k/eslint-config-next";
|
|
16
|
-
import { astroConfig } from "@santi020k/eslint-config-astro";
|
|
17
|
-
import { expoConfig } from "@santi020k/eslint-config-expo";
|
|
18
|
-
import { nestConfig } from "@santi020k/eslint-config-nest";
|
|
19
|
-
import { vueConfig } from "@santi020k/eslint-config-vue";
|
|
20
|
-
import {
|
|
13
|
+
createCoreConfig,
|
|
21
14
|
cspell,
|
|
15
|
+
cypress,
|
|
16
|
+
detectProjectOptions,
|
|
17
|
+
eslintConfig,
|
|
18
|
+
getGlobalsForRuntime,
|
|
19
|
+
gitignore,
|
|
20
|
+
graphql,
|
|
21
|
+
hasReactConfig,
|
|
22
22
|
i18next,
|
|
23
|
+
jest,
|
|
24
|
+
jsConfig,
|
|
25
|
+
jsdoc,
|
|
26
|
+
jsonc,
|
|
23
27
|
markdown,
|
|
24
28
|
mdx,
|
|
29
|
+
perfectionist,
|
|
30
|
+
playwright,
|
|
25
31
|
prettier,
|
|
26
32
|
regexp,
|
|
33
|
+
security,
|
|
34
|
+
sonarjs,
|
|
27
35
|
stencil,
|
|
36
|
+
storybook,
|
|
37
|
+
swagger,
|
|
28
38
|
tailwind,
|
|
39
|
+
tanstackQuery,
|
|
40
|
+
tanstackRouter,
|
|
41
|
+
testingLibrary,
|
|
42
|
+
toml,
|
|
43
|
+
tsConfig,
|
|
44
|
+
typescriptConfig,
|
|
29
45
|
unicorn,
|
|
30
46
|
vitest,
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
import
|
|
35
|
-
import
|
|
36
|
-
applyConfigIfOptionPresent as applyConfigIfOptionPresent2,
|
|
37
|
-
ConfigOption as ConfigOption2,
|
|
38
|
-
coreConfig as coreConfig2,
|
|
39
|
-
gitignore as gitignore2,
|
|
40
|
-
hasReactConfig as hasReactConfig2,
|
|
41
|
-
OptionalOption as OptionalOption2,
|
|
42
|
-
SettingOption as SettingOption2
|
|
43
|
-
} from "@santi020k/eslint-config-core";
|
|
44
|
-
import { expoConfig as expoConfig2 } from "@santi020k/eslint-config-expo";
|
|
45
|
-
import { nestConfig as nestConfig2 } from "@santi020k/eslint-config-nest";
|
|
46
|
-
import { nextConfig as nextConfig2 } from "@santi020k/eslint-config-next";
|
|
47
|
-
import {
|
|
48
|
-
cspell as cspell2,
|
|
49
|
-
i18next as i18next2,
|
|
50
|
-
markdown as markdown2,
|
|
51
|
-
mdx as mdx2,
|
|
52
|
-
playwright as playwright2,
|
|
53
|
-
prettier as prettier2,
|
|
54
|
-
regexp as regexp2,
|
|
55
|
-
sonarjs as sonarjs2,
|
|
56
|
-
stencil as stencil2,
|
|
57
|
-
tailwind as tailwind2,
|
|
58
|
-
unicorn as unicorn2,
|
|
59
|
-
vitest as vitest2
|
|
60
|
-
} from "@santi020k/eslint-config-optionals";
|
|
61
|
-
import { reactConfig as reactConfig2 } from "@santi020k/eslint-config-react";
|
|
62
|
-
import { typescriptConfig as typescriptConfig2 } from "@santi020k/eslint-config-typescript";
|
|
63
|
-
import { vueConfig as vueConfig2 } from "@santi020k/eslint-config-vue";
|
|
64
|
-
var eslintConfig = ({
|
|
65
|
-
config = [],
|
|
66
|
-
optionals = [],
|
|
67
|
-
settings = []
|
|
68
|
-
} = {}) => {
|
|
69
|
-
const uniqueConfig = [...new Set(config)];
|
|
70
|
-
const uniqueOptionals = [...new Set(optionals)];
|
|
71
|
-
const uniqueSettings = [...new Set(settings)];
|
|
72
|
-
const hasReact = hasReactConfig2(uniqueConfig);
|
|
73
|
-
const useGitignore = !uniqueSettings.includes(SettingOption2.NoGitignore);
|
|
74
|
-
return [
|
|
75
|
-
// Settings
|
|
76
|
-
...useGitignore ? gitignore2 : [],
|
|
77
|
-
// Core JS config (always included)
|
|
78
|
-
...coreConfig2,
|
|
79
|
-
// React config (included if any React-based framework is used)
|
|
80
|
-
...hasReact ? reactConfig2 : [],
|
|
81
|
-
// Framework-specific configs
|
|
82
|
-
...applyConfigIfOptionPresent2(uniqueConfig, ConfigOption2.Ts, typescriptConfig2),
|
|
83
|
-
...applyConfigIfOptionPresent2(uniqueConfig, ConfigOption2.Next, nextConfig2),
|
|
84
|
-
...applyConfigIfOptionPresent2(uniqueConfig, ConfigOption2.Astro, astroConfig2),
|
|
85
|
-
...applyConfigIfOptionPresent2(uniqueConfig, ConfigOption2.Expo, expoConfig2),
|
|
86
|
-
...applyConfigIfOptionPresent2(uniqueConfig, ConfigOption2.Nest, nestConfig2),
|
|
87
|
-
...applyConfigIfOptionPresent2(uniqueConfig, ConfigOption2.Vue, vueConfig2),
|
|
88
|
-
// Optionals
|
|
89
|
-
...uniqueOptionals.includes(OptionalOption2.Cspell) ? cspell2 : [],
|
|
90
|
-
...uniqueOptionals.includes(OptionalOption2.Tailwind) ? tailwind2 : [],
|
|
91
|
-
...uniqueOptionals.includes(OptionalOption2.Vitest) ? vitest2 : [],
|
|
92
|
-
...uniqueOptionals.includes(OptionalOption2.I18next) ? i18next2 : [],
|
|
93
|
-
...uniqueOptionals.includes(OptionalOption2.Stencil) ? stencil2 : [],
|
|
94
|
-
...uniqueOptionals.includes(OptionalOption2.Regexp) ? regexp2 : [],
|
|
95
|
-
...uniqueOptionals.includes(OptionalOption2.Mdx) ? mdx2 : [],
|
|
96
|
-
...uniqueOptionals.includes(OptionalOption2.Markdown) ? markdown2 : [],
|
|
97
|
-
...uniqueOptionals.includes(OptionalOption2.Unicorn) ? unicorn2 : [],
|
|
98
|
-
...uniqueOptionals.includes(OptionalOption2.Sonarjs) ? sonarjs2 : [],
|
|
99
|
-
...uniqueOptionals.includes(OptionalOption2.Playwright) ? playwright2 : [],
|
|
100
|
-
// Prettier must be last to override stylistic rules
|
|
101
|
-
...uniqueOptionals.includes(OptionalOption2.Prettier) ? prettier2 : []
|
|
102
|
-
];
|
|
103
|
-
};
|
|
47
|
+
yaml
|
|
48
|
+
} from "./chunk-CH2MVUQN.js";
|
|
49
|
+
import "./chunk-2Z6LYTBS.js";
|
|
50
|
+
import "./chunk-WGZBHVWD.js";
|
|
51
|
+
import "./chunk-SSGAWVVA.js";
|
|
104
52
|
export {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
53
|
+
Extension,
|
|
54
|
+
Format,
|
|
55
|
+
Library,
|
|
56
|
+
NextMode,
|
|
57
|
+
Preset,
|
|
58
|
+
ReactConfigKeys,
|
|
59
|
+
Runtime,
|
|
60
|
+
Setting,
|
|
61
|
+
Testing,
|
|
62
|
+
Tool,
|
|
111
63
|
coreConfig,
|
|
64
|
+
createCoreConfig,
|
|
112
65
|
cspell,
|
|
66
|
+
cypress,
|
|
67
|
+
detectProjectOptions,
|
|
113
68
|
eslintConfig,
|
|
114
|
-
|
|
69
|
+
getGlobalsForRuntime,
|
|
115
70
|
gitignore,
|
|
71
|
+
graphql,
|
|
116
72
|
hasReactConfig,
|
|
117
73
|
i18next,
|
|
74
|
+
jest,
|
|
118
75
|
jsConfig,
|
|
76
|
+
jsdoc,
|
|
77
|
+
jsonc,
|
|
119
78
|
markdown,
|
|
120
79
|
mdx,
|
|
121
|
-
|
|
122
|
-
nextConfig,
|
|
80
|
+
perfectionist,
|
|
123
81
|
playwright,
|
|
124
82
|
prettier,
|
|
125
|
-
reactConfig,
|
|
126
83
|
regexp,
|
|
84
|
+
security,
|
|
127
85
|
sonarjs,
|
|
128
86
|
stencil,
|
|
87
|
+
storybook,
|
|
88
|
+
swagger,
|
|
129
89
|
tailwind,
|
|
90
|
+
tanstackQuery,
|
|
91
|
+
tanstackRouter,
|
|
92
|
+
testingLibrary,
|
|
93
|
+
toml,
|
|
130
94
|
tsConfig,
|
|
131
95
|
typescriptConfig,
|
|
132
96
|
unicorn,
|
|
133
97
|
vitest,
|
|
134
|
-
|
|
98
|
+
yaml
|
|
135
99
|
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Library, Tool, Testing, Format, Extension, FlatConfigArray } from '@santi020k/eslint-config-core';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Gets the optional configurations based on selected options.
|
|
5
|
+
* This function maintains the recommended ordering (e.g. Prettier last).
|
|
6
|
+
*/
|
|
7
|
+
declare const getOptionalConfigs: (libraries: Library[], tools: Tool[], testing: Testing[], formats: Format[], extensions: Extension[]) => FlatConfigArray;
|
|
8
|
+
/**
|
|
9
|
+
* Returns the Prettier configuration if selected.
|
|
10
|
+
*/
|
|
11
|
+
declare const getPrettierConfig: (tools: Tool[]) => FlatConfigArray;
|
|
12
|
+
|
|
13
|
+
export { getOptionalConfigs, getPrettierConfig };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ImportedFramework, FlatConfigArray, Preset, EslintConfigOptions } from '@santi020k/eslint-config-core';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Resolves an imported framework (either array or default export) into a config array.
|
|
5
|
+
*/
|
|
6
|
+
declare const resolveFramework: (frameworkName: string, framework?: ImportedFramework) => FlatConfigArray;
|
|
7
|
+
/**
|
|
8
|
+
* Resolves a preset into options
|
|
9
|
+
*/
|
|
10
|
+
declare const resolvePreset: (preset: Preset) => Partial<EslintConfigOptions>;
|
|
11
|
+
|
|
12
|
+
export { resolveFramework, resolvePreset };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@santi020k/eslint-config-basic",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.1",
|
|
4
4
|
"description": "A comprehensive ESLint configuration package for JavaScript, TypeScript, and React projects.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -24,25 +24,59 @@
|
|
|
24
24
|
"clean": "rm -rf dist",
|
|
25
25
|
"check:exports": "publint",
|
|
26
26
|
"prepack": "rm -f README.md && cp ../../README.md ./README.md",
|
|
27
|
-
"postpack": "rm -f README.md && ln -s ../../README.md ./README.md"
|
|
27
|
+
"postpack": "rm -f README.md && ln -s ../../README.md ./README.md",
|
|
28
|
+
"typecheck": "tsc --noEmit"
|
|
29
|
+
},
|
|
30
|
+
"bin": {
|
|
31
|
+
"basic-eslint": "./dist/cli.js"
|
|
28
32
|
},
|
|
29
33
|
"dependencies": {
|
|
30
|
-
"@santi020k/eslint-config-
|
|
31
|
-
"@santi020k/eslint-config-
|
|
32
|
-
"@santi020k/eslint-config-
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
"@santi020k/eslint-config-
|
|
38
|
-
"@santi020k/eslint-config-
|
|
39
|
-
"@eslint
|
|
40
|
-
"@eslint
|
|
41
|
-
"@
|
|
42
|
-
"@
|
|
43
|
-
"
|
|
44
|
-
"eslint": "^
|
|
45
|
-
"
|
|
34
|
+
"@santi020k/eslint-config-core": "^0.8.1",
|
|
35
|
+
"@santi020k/eslint-config-optionals": "^0.8.1",
|
|
36
|
+
"@santi020k/eslint-config-typescript": "^0.8.1",
|
|
37
|
+
"eslint": "^10.1.0",
|
|
38
|
+
"typescript-eslint": "^8.57.1"
|
|
39
|
+
},
|
|
40
|
+
"peerDependencies": {
|
|
41
|
+
"@santi020k/eslint-config-angular": "^0.8.1",
|
|
42
|
+
"@santi020k/eslint-config-astro": "^0.8.1",
|
|
43
|
+
"@santi020k/eslint-config-expo": "^0.8.1",
|
|
44
|
+
"@santi020k/eslint-config-nest": "^0.8.1",
|
|
45
|
+
"@santi020k/eslint-config-next": "^0.8.1",
|
|
46
|
+
"@santi020k/eslint-config-react": "^0.8.1",
|
|
47
|
+
"@santi020k/eslint-config-solid": "^0.8.1",
|
|
48
|
+
"@santi020k/eslint-config-svelte": "^0.8.1",
|
|
49
|
+
"@santi020k/eslint-config-vue": "^0.8.1",
|
|
50
|
+
"eslint": "^10.1.0"
|
|
51
|
+
},
|
|
52
|
+
"peerDependenciesMeta": {
|
|
53
|
+
"@santi020k/eslint-config-angular": {
|
|
54
|
+
"optional": true
|
|
55
|
+
},
|
|
56
|
+
"@santi020k/eslint-config-astro": {
|
|
57
|
+
"optional": true
|
|
58
|
+
},
|
|
59
|
+
"@santi020k/eslint-config-expo": {
|
|
60
|
+
"optional": true
|
|
61
|
+
},
|
|
62
|
+
"@santi020k/eslint-config-nest": {
|
|
63
|
+
"optional": true
|
|
64
|
+
},
|
|
65
|
+
"@santi020k/eslint-config-next": {
|
|
66
|
+
"optional": true
|
|
67
|
+
},
|
|
68
|
+
"@santi020k/eslint-config-react": {
|
|
69
|
+
"optional": true
|
|
70
|
+
},
|
|
71
|
+
"@santi020k/eslint-config-solid": {
|
|
72
|
+
"optional": true
|
|
73
|
+
},
|
|
74
|
+
"@santi020k/eslint-config-svelte": {
|
|
75
|
+
"optional": true
|
|
76
|
+
},
|
|
77
|
+
"@santi020k/eslint-config-vue": {
|
|
78
|
+
"optional": true
|
|
79
|
+
}
|
|
46
80
|
},
|
|
47
81
|
"devDependencies": {
|
|
48
82
|
"tsup": "^8.5.1",
|
|
@@ -52,6 +86,9 @@
|
|
|
52
86
|
"publishConfig": {
|
|
53
87
|
"access": "public"
|
|
54
88
|
},
|
|
89
|
+
"engines": {
|
|
90
|
+
"node": ">=18.18.0"
|
|
91
|
+
},
|
|
55
92
|
"license": "MIT",
|
|
56
93
|
"author": "santi020k",
|
|
57
94
|
"repository": {
|