@vortiquo/eslint-config 0.0.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/LICENSE +22 -0
- package/README.md +192 -0
- package/base-typescript.js +90 -0
- package/base.js +74 -0
- package/index.js +9 -0
- package/nestjs.js +43 -0
- package/nextjs.js +51 -0
- package/node-library.js +42 -0
- package/package.json +89 -0
- package/react-library.js +34 -0
- package/react.js +75 -0
- package/server.js +47 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Vortiquo
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
package/README.md
ADDED
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
# @vortiquo/eslint-config
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@vortiquo/eslint-config)
|
|
4
|
+
[](https://github.com/vortiquo/configs/blob/main/LICENSE)
|
|
5
|
+
|
|
6
|
+
Modern ESLint v9 flat configurations with TypeScript, React, and Node.js
|
|
7
|
+
support.
|
|
8
|
+
|
|
9
|
+
## Features
|
|
10
|
+
|
|
11
|
+
- ⚡ **ESLint v9** - Modern flat config format
|
|
12
|
+
- 🔒 **Strict TypeScript** - Uses `strictTypeChecked` preset
|
|
13
|
+
- 📦 **Ready-to-use presets** - Next.js, React, Node.js, NestJS
|
|
14
|
+
- 🎨 **Prettier compatible** - No formatting conflicts
|
|
15
|
+
- 📝 **Import sorting** - Auto-fixable with `simple-import-sort`
|
|
16
|
+
- 🏎️ **Turbo support** - Monorepo cache awareness
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npm install -D @vortiquo/eslint-config eslint typescript
|
|
22
|
+
# or
|
|
23
|
+
pnpm add -D @vortiquo/eslint-config eslint typescript
|
|
24
|
+
# or
|
|
25
|
+
yarn add -D @vortiquo/eslint-config eslint typescript
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Available Configs
|
|
29
|
+
|
|
30
|
+
| Config | Use Case |
|
|
31
|
+
| --------------- | ------------------------------------- |
|
|
32
|
+
| `nextjs` | Next.js applications |
|
|
33
|
+
| `server` | Backend APIs (Fastify, Express, Hono) |
|
|
34
|
+
| `nestjs` | NestJS applications |
|
|
35
|
+
| `react` | React applications |
|
|
36
|
+
| `react-library` | React/UI component libraries |
|
|
37
|
+
| `node-library` | Shared Node.js packages |
|
|
38
|
+
|
|
39
|
+
## Usage
|
|
40
|
+
|
|
41
|
+
Create an `eslint.config.js` in your project:
|
|
42
|
+
|
|
43
|
+
### Next.js
|
|
44
|
+
|
|
45
|
+
```js
|
|
46
|
+
import { nextjs } from '@vortiquo/eslint-config/nextjs';
|
|
47
|
+
|
|
48
|
+
export default [
|
|
49
|
+
...nextjs,
|
|
50
|
+
{
|
|
51
|
+
languageOptions: {
|
|
52
|
+
parserOptions: {
|
|
53
|
+
project: './tsconfig.json',
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
];
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Backend API (Fastify/Express/Hono)
|
|
61
|
+
|
|
62
|
+
```js
|
|
63
|
+
import { server } from '@vortiquo/eslint-config/server';
|
|
64
|
+
|
|
65
|
+
export default [
|
|
66
|
+
...server,
|
|
67
|
+
{
|
|
68
|
+
languageOptions: {
|
|
69
|
+
parserOptions: {
|
|
70
|
+
project: './tsconfig.json',
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
];
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### NestJS
|
|
78
|
+
|
|
79
|
+
```js
|
|
80
|
+
import { nestjs } from '@vortiquo/eslint-config/nestjs';
|
|
81
|
+
|
|
82
|
+
export default [
|
|
83
|
+
...nestjs,
|
|
84
|
+
{
|
|
85
|
+
languageOptions: {
|
|
86
|
+
parserOptions: {
|
|
87
|
+
project: './tsconfig.json',
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
];
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### React Component Library
|
|
95
|
+
|
|
96
|
+
```js
|
|
97
|
+
import { reactLibrary } from '@vortiquo/eslint-config/react-library';
|
|
98
|
+
|
|
99
|
+
export default [
|
|
100
|
+
...reactLibrary,
|
|
101
|
+
{
|
|
102
|
+
languageOptions: {
|
|
103
|
+
parserOptions: {
|
|
104
|
+
project: './tsconfig.json',
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
];
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### Node.js Library
|
|
112
|
+
|
|
113
|
+
```js
|
|
114
|
+
import { nodeLibrary } from '@vortiquo/eslint-config/node-library';
|
|
115
|
+
|
|
116
|
+
export default [
|
|
117
|
+
...nodeLibrary,
|
|
118
|
+
{
|
|
119
|
+
languageOptions: {
|
|
120
|
+
parserOptions: {
|
|
121
|
+
project: './tsconfig.json',
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
];
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## Extending Configs
|
|
129
|
+
|
|
130
|
+
All configs are arrays that can be spread and extended:
|
|
131
|
+
|
|
132
|
+
```js
|
|
133
|
+
import { nextjs } from '@vortiquo/eslint-config/nextjs';
|
|
134
|
+
|
|
135
|
+
export default [
|
|
136
|
+
...nextjs,
|
|
137
|
+
{
|
|
138
|
+
rules: {
|
|
139
|
+
'no-console': 'off',
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
ignores: ['generated/**'],
|
|
144
|
+
},
|
|
145
|
+
];
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
## What's Included
|
|
149
|
+
|
|
150
|
+
### Base Rules
|
|
151
|
+
|
|
152
|
+
- Prettier integration (formatting handled by Prettier)
|
|
153
|
+
- Turbo plugin (monorepo cache awareness)
|
|
154
|
+
- Import sorting (auto-fixable)
|
|
155
|
+
- Best practices (curly, eqeqeq, prefer-const)
|
|
156
|
+
|
|
157
|
+
### TypeScript Rules
|
|
158
|
+
|
|
159
|
+
- Strict type checking (`strictTypeChecked`)
|
|
160
|
+
- Consistent type imports/exports
|
|
161
|
+
- No explicit `any`
|
|
162
|
+
- Promise handling (`no-floating-promises`)
|
|
163
|
+
|
|
164
|
+
### React Rules
|
|
165
|
+
|
|
166
|
+
- React recommended + JSX runtime
|
|
167
|
+
- React Hooks rules
|
|
168
|
+
- Self-closing components
|
|
169
|
+
- Prop sorting
|
|
170
|
+
|
|
171
|
+
### Next.js Rules
|
|
172
|
+
|
|
173
|
+
- Core Web Vitals
|
|
174
|
+
- Image optimization
|
|
175
|
+
- App Router support
|
|
176
|
+
|
|
177
|
+
## Config Hierarchy
|
|
178
|
+
|
|
179
|
+
```
|
|
180
|
+
base (JS rules, Prettier, Turbo)
|
|
181
|
+
└── base-typescript (TS strict rules)
|
|
182
|
+
├── react (React + Hooks)
|
|
183
|
+
│ ├── react-library (stricter)
|
|
184
|
+
│ └── nextjs (Next.js specific)
|
|
185
|
+
├── server (Node.js APIs)
|
|
186
|
+
│ └── nestjs (decorators)
|
|
187
|
+
└── node-library (Node.js packages)
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
## License
|
|
191
|
+
|
|
192
|
+
MIT © [Vortiquo](https://vortiquo.com)
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import tseslint from 'typescript-eslint';
|
|
2
|
+
import { base } from './base.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Base TypeScript ESLint configuration.
|
|
6
|
+
* Extends base config with TypeScript-specific rules.
|
|
7
|
+
*
|
|
8
|
+
* @type {import("eslint").Linter.Config[]}
|
|
9
|
+
*/
|
|
10
|
+
export const baseTypescript = [
|
|
11
|
+
...base,
|
|
12
|
+
...tseslint.configs.strictTypeChecked,
|
|
13
|
+
...tseslint.configs.stylisticTypeChecked,
|
|
14
|
+
{
|
|
15
|
+
name: 'vortiquo/typescript',
|
|
16
|
+
languageOptions: {
|
|
17
|
+
parserOptions: {
|
|
18
|
+
projectService: true,
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
settings: {
|
|
22
|
+
'import/resolver': {
|
|
23
|
+
typescript: true,
|
|
24
|
+
node: true,
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
rules: {
|
|
28
|
+
// Override base no-unused-vars with TypeScript version
|
|
29
|
+
'no-unused-vars': 'off',
|
|
30
|
+
'@typescript-eslint/no-unused-vars': [
|
|
31
|
+
'error',
|
|
32
|
+
{
|
|
33
|
+
argsIgnorePattern: '^_',
|
|
34
|
+
varsIgnorePattern: '^_',
|
|
35
|
+
caughtErrorsIgnorePattern: '^_',
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
|
|
39
|
+
// Type imports (enforces `import type` for types - better tree-shaking)
|
|
40
|
+
'@typescript-eslint/consistent-type-imports': [
|
|
41
|
+
'error',
|
|
42
|
+
{ prefer: 'type-imports', fixStyle: 'separate-type-imports' },
|
|
43
|
+
],
|
|
44
|
+
'@typescript-eslint/consistent-type-exports': [
|
|
45
|
+
'error',
|
|
46
|
+
{ fixMixedExportsWithInlineTypeSpecifier: true },
|
|
47
|
+
],
|
|
48
|
+
|
|
49
|
+
// Strictness - catch bugs early
|
|
50
|
+
'@typescript-eslint/no-explicit-any': 'error',
|
|
51
|
+
'@typescript-eslint/no-use-before-define': [
|
|
52
|
+
'error',
|
|
53
|
+
{ functions: false, classes: true, variables: true },
|
|
54
|
+
],
|
|
55
|
+
'@typescript-eslint/explicit-function-return-type': [
|
|
56
|
+
'error',
|
|
57
|
+
{
|
|
58
|
+
allowExpressions: true,
|
|
59
|
+
allowTypedFunctionExpressions: true,
|
|
60
|
+
allowHigherOrderFunctions: true,
|
|
61
|
+
},
|
|
62
|
+
],
|
|
63
|
+
'@typescript-eslint/no-misused-promises': [
|
|
64
|
+
'error',
|
|
65
|
+
{ checksVoidReturn: { attributes: false } },
|
|
66
|
+
],
|
|
67
|
+
'@typescript-eslint/no-floating-promises': 'error',
|
|
68
|
+
'@typescript-eslint/await-thenable': 'error',
|
|
69
|
+
|
|
70
|
+
// Preferences
|
|
71
|
+
'@typescript-eslint/consistent-type-definitions': ['error', 'type'],
|
|
72
|
+
'@typescript-eslint/array-type': ['error', { default: 'array-simple' }],
|
|
73
|
+
'@typescript-eslint/prefer-nullish-coalescing': 'error',
|
|
74
|
+
'@typescript-eslint/prefer-optional-chain': 'error',
|
|
75
|
+
'@typescript-eslint/no-unnecessary-condition': 'error',
|
|
76
|
+
'@typescript-eslint/switch-exhaustiveness-check': 'error',
|
|
77
|
+
|
|
78
|
+
// Relaxations (good DX without sacrificing safety)
|
|
79
|
+
'@typescript-eslint/no-confusing-void-expression': 'off',
|
|
80
|
+
'@typescript-eslint/restrict-template-expressions': [
|
|
81
|
+
'error',
|
|
82
|
+
{ allowNumber: true, allowBoolean: true },
|
|
83
|
+
],
|
|
84
|
+
// This one is too strict - TS already handles this well
|
|
85
|
+
'@typescript-eslint/require-await': 'off',
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
];
|
|
89
|
+
|
|
90
|
+
export default baseTypescript;
|
package/base.js
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import js from '@eslint/js';
|
|
2
|
+
import eslintConfigPrettier from 'eslint-config-prettier';
|
|
3
|
+
import importPlugin from 'eslint-plugin-import';
|
|
4
|
+
import onlyWarn from 'eslint-plugin-only-warn';
|
|
5
|
+
import simpleImportSort from 'eslint-plugin-simple-import-sort';
|
|
6
|
+
import turboPlugin from 'eslint-plugin-turbo';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Base ESLint configuration for all projects.
|
|
10
|
+
* This config provides JavaScript rules and general best practices.
|
|
11
|
+
*
|
|
12
|
+
* @type {import("eslint").Linter.Config[]}
|
|
13
|
+
*/
|
|
14
|
+
export const base = [
|
|
15
|
+
js.configs.recommended,
|
|
16
|
+
eslintConfigPrettier,
|
|
17
|
+
{
|
|
18
|
+
name: 'vortiquo/base',
|
|
19
|
+
plugins: {
|
|
20
|
+
turbo: turboPlugin,
|
|
21
|
+
import: importPlugin,
|
|
22
|
+
'simple-import-sort': simpleImportSort,
|
|
23
|
+
onlyWarn,
|
|
24
|
+
},
|
|
25
|
+
rules: {
|
|
26
|
+
// Turbo
|
|
27
|
+
'turbo/no-undeclared-env-vars': 'warn',
|
|
28
|
+
|
|
29
|
+
// Best practices
|
|
30
|
+
curly: 'error',
|
|
31
|
+
eqeqeq: ['error', 'always', { null: 'ignore' }],
|
|
32
|
+
'no-console': ['warn', { allow: ['warn', 'error'] }],
|
|
33
|
+
'no-debugger': 'warn',
|
|
34
|
+
'no-unused-vars': [
|
|
35
|
+
'error',
|
|
36
|
+
{
|
|
37
|
+
argsIgnorePattern: '^_',
|
|
38
|
+
varsIgnorePattern: '^_',
|
|
39
|
+
caughtErrorsIgnorePattern: '^_',
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
|
|
43
|
+
// Style
|
|
44
|
+
'prefer-const': 'error',
|
|
45
|
+
'prefer-template': 'error',
|
|
46
|
+
'object-shorthand': 'error',
|
|
47
|
+
'no-var': 'error',
|
|
48
|
+
|
|
49
|
+
// Import sorting (auto-fixable, great DX)
|
|
50
|
+
'simple-import-sort/imports': 'error',
|
|
51
|
+
'simple-import-sort/exports': 'error',
|
|
52
|
+
|
|
53
|
+
// Import rules
|
|
54
|
+
'import/first': 'error',
|
|
55
|
+
'import/newline-after-import': 'error',
|
|
56
|
+
'import/no-duplicates': 'error',
|
|
57
|
+
'import/no-mutable-exports': 'error',
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
name: 'vortiquo/base/ignores',
|
|
62
|
+
ignores: [
|
|
63
|
+
'**/node_modules/**',
|
|
64
|
+
'**/dist/**',
|
|
65
|
+
'**/build/**',
|
|
66
|
+
'**/.next/**',
|
|
67
|
+
'**/coverage/**',
|
|
68
|
+
'**/.turbo/**',
|
|
69
|
+
'**/public/**',
|
|
70
|
+
],
|
|
71
|
+
},
|
|
72
|
+
];
|
|
73
|
+
|
|
74
|
+
export default base;
|
package/index.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Re-export all configs for convenience
|
|
2
|
+
export { base } from './base.js';
|
|
3
|
+
export { baseTypescript } from './base-typescript.js';
|
|
4
|
+
export { react } from './react.js';
|
|
5
|
+
export { reactLibrary } from './react-library.js';
|
|
6
|
+
export { nextjs } from './nextjs.js';
|
|
7
|
+
export { server } from './server.js';
|
|
8
|
+
export { nestjs } from './nestjs.js';
|
|
9
|
+
export { nodeLibrary } from './node-library.js';
|
package/nestjs.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { server } from './server.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* ESLint configuration for NestJS applications.
|
|
5
|
+
* Extends server config with NestJS-specific rules.
|
|
6
|
+
*
|
|
7
|
+
* @type {import("eslint").Linter.Config[]}
|
|
8
|
+
*/
|
|
9
|
+
export const nestjs = [
|
|
10
|
+
...server,
|
|
11
|
+
{
|
|
12
|
+
name: 'vortiquo/nestjs',
|
|
13
|
+
rules: {
|
|
14
|
+
// NestJS uses classes extensively
|
|
15
|
+
'@typescript-eslint/consistent-type-definitions': 'off',
|
|
16
|
+
|
|
17
|
+
// NestJS uses empty constructors for DI
|
|
18
|
+
'@typescript-eslint/no-empty-function': [
|
|
19
|
+
'error',
|
|
20
|
+
{ allow: ['constructors'] },
|
|
21
|
+
],
|
|
22
|
+
|
|
23
|
+
// NestJS decorators often require classes
|
|
24
|
+
'@typescript-eslint/no-extraneous-class': 'off',
|
|
25
|
+
|
|
26
|
+
// NestJS uses parameter properties
|
|
27
|
+
'@typescript-eslint/parameter-properties': 'off',
|
|
28
|
+
|
|
29
|
+
// Allow unused vars in decorators (common pattern)
|
|
30
|
+
'@typescript-eslint/no-unused-vars': [
|
|
31
|
+
'error',
|
|
32
|
+
{
|
|
33
|
+
argsIgnorePattern: '^_',
|
|
34
|
+
varsIgnorePattern: '^_',
|
|
35
|
+
caughtErrorsIgnorePattern: '^_',
|
|
36
|
+
args: 'after-used',
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
];
|
|
42
|
+
|
|
43
|
+
export default nestjs;
|
package/nextjs.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import nextPlugin from '@next/eslint-plugin-next';
|
|
2
|
+
import { react } from './react.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* ESLint configuration for Next.js applications.
|
|
6
|
+
* Extends React config with Next.js-specific rules.
|
|
7
|
+
*
|
|
8
|
+
* @type {import("eslint").Linter.Config[]}
|
|
9
|
+
*/
|
|
10
|
+
export const nextjs = [
|
|
11
|
+
...react,
|
|
12
|
+
{
|
|
13
|
+
name: 'vortiquo/nextjs',
|
|
14
|
+
plugins: {
|
|
15
|
+
'@next/next': nextPlugin,
|
|
16
|
+
},
|
|
17
|
+
rules: {
|
|
18
|
+
...nextPlugin.configs.recommended.rules,
|
|
19
|
+
...nextPlugin.configs['core-web-vitals'].rules,
|
|
20
|
+
|
|
21
|
+
// Next.js specific
|
|
22
|
+
'@next/next/no-html-link-for-pages': 'error',
|
|
23
|
+
'@next/next/no-img-element': 'error',
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
name: 'vortiquo/nextjs/relaxations',
|
|
28
|
+
files: [
|
|
29
|
+
'**/app/**/page.tsx',
|
|
30
|
+
'**/app/**/layout.tsx',
|
|
31
|
+
'**/app/**/loading.tsx',
|
|
32
|
+
'**/app/**/error.tsx',
|
|
33
|
+
'**/app/**/not-found.tsx',
|
|
34
|
+
'**/app/**/route.ts',
|
|
35
|
+
'**/app/**/default.tsx',
|
|
36
|
+
'**/app/**/template.tsx',
|
|
37
|
+
'**/app/**/opengraph-image.tsx',
|
|
38
|
+
'**/app/**/twitter-image.tsx',
|
|
39
|
+
'**/app/**/sitemap.ts',
|
|
40
|
+
'**/app/**/robots.ts',
|
|
41
|
+
'**/middleware.ts',
|
|
42
|
+
'**/*.config.{js,ts,mjs}',
|
|
43
|
+
],
|
|
44
|
+
rules: {
|
|
45
|
+
// Next.js requires default exports for these files
|
|
46
|
+
'import/no-default-export': 'off',
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
];
|
|
50
|
+
|
|
51
|
+
export default nextjs;
|
package/node-library.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import globals from 'globals';
|
|
2
|
+
import { baseTypescript } from './base-typescript.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* ESLint configuration for Node.js libraries/packages.
|
|
6
|
+
* Extends TypeScript config for shared backend packages.
|
|
7
|
+
*
|
|
8
|
+
* @type {import("eslint").Linter.Config[]}
|
|
9
|
+
*/
|
|
10
|
+
export const nodeLibrary = [
|
|
11
|
+
...baseTypescript,
|
|
12
|
+
{
|
|
13
|
+
name: 'vortiquo/node-library',
|
|
14
|
+
languageOptions: {
|
|
15
|
+
globals: {
|
|
16
|
+
...globals.node,
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
rules: {
|
|
20
|
+
// Libraries should be strict
|
|
21
|
+
'@typescript-eslint/explicit-function-return-type': 'error',
|
|
22
|
+
'@typescript-eslint/explicit-module-boundary-types': 'error',
|
|
23
|
+
|
|
24
|
+
// No console in libraries (consumers should handle logging)
|
|
25
|
+
'no-console': 'error',
|
|
26
|
+
|
|
27
|
+
// Async handling
|
|
28
|
+
'@typescript-eslint/no-floating-promises': 'error',
|
|
29
|
+
'@typescript-eslint/require-await': 'error',
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
name: 'vortiquo/node-library/config-files',
|
|
34
|
+
files: ['**/*.config.{js,ts,mjs}', '**/tsup.config.ts'],
|
|
35
|
+
rules: {
|
|
36
|
+
'import/no-default-export': 'off',
|
|
37
|
+
'no-console': 'off',
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
];
|
|
41
|
+
|
|
42
|
+
export default nodeLibrary;
|
package/package.json
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@vortiquo/eslint-config",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Modern ESLint v9 flat configurations with TypeScript, React, Next.js, and Node.js support",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"author": "Vortiquo <dev@vortiquo.com>",
|
|
8
|
+
"homepage": "https://github.com/vortiquo/eslint-config#readme",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://github.com/vortiquo/eslint-config"
|
|
12
|
+
},
|
|
13
|
+
"scripts": {
|
|
14
|
+
"lint": "ls-lint",
|
|
15
|
+
"format": "prettier --write .",
|
|
16
|
+
"format:check": "prettier --check .",
|
|
17
|
+
"commit": "cz",
|
|
18
|
+
"prepare": "husky"
|
|
19
|
+
},
|
|
20
|
+
"bugs": {
|
|
21
|
+
"url": "https://github.com/vortiquo/eslint-config/issues"
|
|
22
|
+
},
|
|
23
|
+
"publishConfig": {
|
|
24
|
+
"access": "public"
|
|
25
|
+
},
|
|
26
|
+
"keywords": [
|
|
27
|
+
"eslint",
|
|
28
|
+
"eslint-config",
|
|
29
|
+
"eslint-flat-config",
|
|
30
|
+
"eslint9",
|
|
31
|
+
"typescript",
|
|
32
|
+
"react",
|
|
33
|
+
"nextjs",
|
|
34
|
+
"nestjs",
|
|
35
|
+
"nodejs",
|
|
36
|
+
"prettier",
|
|
37
|
+
"strict",
|
|
38
|
+
"shared-config"
|
|
39
|
+
],
|
|
40
|
+
"exports": {
|
|
41
|
+
".": "./index.js",
|
|
42
|
+
"./base": "./base.js",
|
|
43
|
+
"./base-typescript": "./base-typescript.js",
|
|
44
|
+
"./react": "./react.js",
|
|
45
|
+
"./react-library": "./react-library.js",
|
|
46
|
+
"./nextjs": "./nextjs.js",
|
|
47
|
+
"./server": "./server.js",
|
|
48
|
+
"./nestjs": "./nestjs.js",
|
|
49
|
+
"./node-library": "./node-library.js"
|
|
50
|
+
},
|
|
51
|
+
"files": [
|
|
52
|
+
"index.js",
|
|
53
|
+
"base.js",
|
|
54
|
+
"base-typescript.js",
|
|
55
|
+
"react.js",
|
|
56
|
+
"react-library.js",
|
|
57
|
+
"nextjs.js",
|
|
58
|
+
"server.js",
|
|
59
|
+
"nestjs.js",
|
|
60
|
+
"node-library.js",
|
|
61
|
+
"README.md",
|
|
62
|
+
"LICENSE"
|
|
63
|
+
],
|
|
64
|
+
"dependencies": {
|
|
65
|
+
"@commitlint/cli": "^20.2.0",
|
|
66
|
+
"@commitlint/config-conventional": "^20.2.0",
|
|
67
|
+
"@eslint/js": "^9.17.0",
|
|
68
|
+
"@ls-lint/ls-lint": "^2.3.1",
|
|
69
|
+
"@next/eslint-plugin-next": "^15.1.0",
|
|
70
|
+
"cz-conventional-changelog": "^3.3.0",
|
|
71
|
+
"eslint-config-prettier": "^10.0.1",
|
|
72
|
+
"eslint-import-resolver-typescript": "^3.7.0",
|
|
73
|
+
"eslint-plugin-import": "^2.31.0",
|
|
74
|
+
"eslint-plugin-only-warn": "^1.1.0",
|
|
75
|
+
"eslint-plugin-react": "^7.37.2",
|
|
76
|
+
"eslint-plugin-react-hooks": "^5.1.0",
|
|
77
|
+
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
78
|
+
"eslint-plugin-turbo": "^2.3.3",
|
|
79
|
+
"globals": "^15.14.0",
|
|
80
|
+
"husky": "^9.1.7",
|
|
81
|
+
"lint-staged": "^16.2.7",
|
|
82
|
+
"prettier": "^3.7.4",
|
|
83
|
+
"typescript-eslint": "^8.18.1"
|
|
84
|
+
},
|
|
85
|
+
"peerDependencies": {
|
|
86
|
+
"eslint": "^9.0.0",
|
|
87
|
+
"typescript": "^5.0.0"
|
|
88
|
+
}
|
|
89
|
+
}
|
package/react-library.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { react } from './react.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* ESLint configuration for React component libraries.
|
|
5
|
+
* Extends React config with library-specific rules.
|
|
6
|
+
*
|
|
7
|
+
* @type {import("eslint").Linter.Config[]}
|
|
8
|
+
*/
|
|
9
|
+
export const reactLibrary = [
|
|
10
|
+
...react,
|
|
11
|
+
{
|
|
12
|
+
name: 'vortiquo/react-library',
|
|
13
|
+
rules: {
|
|
14
|
+
// Libraries should be stricter about exports
|
|
15
|
+
'@typescript-eslint/explicit-module-boundary-types': 'error',
|
|
16
|
+
|
|
17
|
+
// No console in libraries
|
|
18
|
+
'no-console': 'error',
|
|
19
|
+
|
|
20
|
+
// Prefer named exports for tree-shaking
|
|
21
|
+
'import/no-default-export': 'error',
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
name: 'vortiquo/react-library/config-files',
|
|
26
|
+
files: ['**/*.config.{js,ts,mjs}', '**/tsup.config.ts'],
|
|
27
|
+
rules: {
|
|
28
|
+
'import/no-default-export': 'off',
|
|
29
|
+
'no-console': 'off',
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
];
|
|
33
|
+
|
|
34
|
+
export default reactLibrary;
|
package/react.js
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import reactPlugin from 'eslint-plugin-react';
|
|
2
|
+
import reactHooksPlugin from 'eslint-plugin-react-hooks';
|
|
3
|
+
import globals from 'globals';
|
|
4
|
+
import { baseTypescript } from './base-typescript.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* ESLint configuration for React projects (libraries, components).
|
|
8
|
+
* Extends TypeScript config with React-specific rules.
|
|
9
|
+
*
|
|
10
|
+
* @type {import("eslint").Linter.Config[]}
|
|
11
|
+
*/
|
|
12
|
+
export const react = [
|
|
13
|
+
...baseTypescript,
|
|
14
|
+
{
|
|
15
|
+
name: 'vortiquo/react',
|
|
16
|
+
files: ['**/*.{jsx,tsx}'],
|
|
17
|
+
plugins: {
|
|
18
|
+
react: reactPlugin,
|
|
19
|
+
'react-hooks': reactHooksPlugin,
|
|
20
|
+
},
|
|
21
|
+
languageOptions: {
|
|
22
|
+
globals: {
|
|
23
|
+
...globals.browser,
|
|
24
|
+
},
|
|
25
|
+
parserOptions: {
|
|
26
|
+
ecmaFeatures: {
|
|
27
|
+
jsx: true,
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
settings: {
|
|
32
|
+
react: {
|
|
33
|
+
version: 'detect',
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
rules: {
|
|
37
|
+
// React recommended
|
|
38
|
+
...reactPlugin.configs.recommended.rules,
|
|
39
|
+
...reactPlugin.configs['jsx-runtime'].rules,
|
|
40
|
+
|
|
41
|
+
// React Hooks
|
|
42
|
+
...reactHooksPlugin.configs.recommended.rules,
|
|
43
|
+
|
|
44
|
+
// React preferences
|
|
45
|
+
'react/prop-types': 'off',
|
|
46
|
+
'react/jsx-no-target-blank': 'error',
|
|
47
|
+
'react/jsx-curly-brace-presence': [
|
|
48
|
+
'error',
|
|
49
|
+
{ props: 'never', children: 'never' },
|
|
50
|
+
],
|
|
51
|
+
'react/self-closing-comp': 'error',
|
|
52
|
+
'react/jsx-sort-props': [
|
|
53
|
+
'warn',
|
|
54
|
+
{
|
|
55
|
+
callbacksLast: true,
|
|
56
|
+
shorthandFirst: true,
|
|
57
|
+
reservedFirst: true,
|
|
58
|
+
},
|
|
59
|
+
],
|
|
60
|
+
|
|
61
|
+
// Hooks
|
|
62
|
+
'react-hooks/rules-of-hooks': 'error',
|
|
63
|
+
'react-hooks/exhaustive-deps': 'warn',
|
|
64
|
+
|
|
65
|
+
// TypeScript handles these
|
|
66
|
+
'react/require-default-props': 'off',
|
|
67
|
+
'react/jsx-props-no-spreading': 'off',
|
|
68
|
+
|
|
69
|
+
// Allow explicit return types to be optional for React components
|
|
70
|
+
'@typescript-eslint/explicit-function-return-type': 'off',
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
];
|
|
74
|
+
|
|
75
|
+
export default react;
|
package/server.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import globals from 'globals';
|
|
2
|
+
import { baseTypescript } from './base-typescript.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* ESLint configuration for backend APIs (Fastify, Express, Hono).
|
|
6
|
+
* Extends TypeScript config with Node.js-specific rules.
|
|
7
|
+
*
|
|
8
|
+
* @type {import("eslint").Linter.Config[]}
|
|
9
|
+
*/
|
|
10
|
+
export const server = [
|
|
11
|
+
...baseTypescript,
|
|
12
|
+
{
|
|
13
|
+
name: 'vortiquo/server',
|
|
14
|
+
languageOptions: {
|
|
15
|
+
globals: {
|
|
16
|
+
...globals.node,
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
rules: {
|
|
20
|
+
// Allow console in backend
|
|
21
|
+
'no-console': 'off',
|
|
22
|
+
|
|
23
|
+
// Backend-specific rules
|
|
24
|
+
'no-process-exit': 'off',
|
|
25
|
+
|
|
26
|
+
// Stricter for backend code
|
|
27
|
+
'@typescript-eslint/explicit-function-return-type': 'error',
|
|
28
|
+
'@typescript-eslint/explicit-module-boundary-types': 'error',
|
|
29
|
+
|
|
30
|
+
// Async handling
|
|
31
|
+
'@typescript-eslint/no-floating-promises': 'error',
|
|
32
|
+
'@typescript-eslint/require-await': 'error',
|
|
33
|
+
'@typescript-eslint/await-thenable': 'error',
|
|
34
|
+
'@typescript-eslint/promise-function-async': 'error',
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
name: 'vortiquo/server/config-files',
|
|
39
|
+
files: ['**/*.config.{js,ts,mjs}'],
|
|
40
|
+
rules: {
|
|
41
|
+
// Config files often use default exports
|
|
42
|
+
'import/no-default-export': 'off',
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
];
|
|
46
|
+
|
|
47
|
+
export default server;
|