@bratislava/eslint-config 0.2.0 → 0.3.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/package.json +8 -37
- package/README.md +0 -226
- package/nest.js +0 -162
- package/next.js +0 -214
- package/react.js +0 -161
package/package.json
CHANGED
|
@@ -1,62 +1,36 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bratislava/eslint-config",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.3.1",
|
|
4
|
+
"description": "Base ESLint configuration for Bratislava projects",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eslint",
|
|
7
7
|
"eslintconfig",
|
|
8
8
|
"eslint-config",
|
|
9
|
-
"bratislava"
|
|
10
|
-
"nest",
|
|
11
|
-
"nestjs",
|
|
12
|
-
"next",
|
|
13
|
-
"nextjs",
|
|
14
|
-
"react"
|
|
9
|
+
"bratislava"
|
|
15
10
|
],
|
|
16
|
-
"author": "Bratislava
|
|
11
|
+
"author": "Bratislava",
|
|
17
12
|
"license": "EUPL-1.2",
|
|
18
|
-
"scripts": {
|
|
19
|
-
"lint": "eslint .",
|
|
20
|
-
"lint:fix": "eslint . --fix"
|
|
21
|
-
},
|
|
22
13
|
"repository": {
|
|
23
14
|
"type": "git",
|
|
24
15
|
"url": "https://github.com/bratislava/eslint-config.git",
|
|
25
|
-
"
|
|
16
|
+
"directory": "packages/base"
|
|
26
17
|
},
|
|
27
18
|
"type": "module",
|
|
19
|
+
"main": "index.js",
|
|
28
20
|
"exports": {
|
|
29
|
-
".": "./index.js"
|
|
30
|
-
"./nest": "./nest.js",
|
|
31
|
-
"./next": "./next.js",
|
|
32
|
-
"./react": "./react.js"
|
|
21
|
+
".": "./index.js"
|
|
33
22
|
},
|
|
34
|
-
"main": "index.js",
|
|
35
23
|
"files": [
|
|
36
|
-
"index.js"
|
|
37
|
-
"nest.js",
|
|
38
|
-
"next.js",
|
|
39
|
-
"react.js"
|
|
24
|
+
"index.js"
|
|
40
25
|
],
|
|
41
26
|
"peerDependencies": {
|
|
42
27
|
"eslint": ">= 9",
|
|
43
28
|
"typescript": ">= 5"
|
|
44
29
|
},
|
|
45
30
|
"dependencies": {
|
|
46
|
-
"@darraghor/eslint-plugin-nestjs-typed": "7.1.3",
|
|
47
31
|
"@eslint/js": "9.34.0",
|
|
48
|
-
"@eslint/json": "0.14.0",
|
|
49
|
-
"@eslint/markdown": "^6.6.0",
|
|
50
|
-
"@next/eslint-plugin-next": "15.5.2",
|
|
51
|
-
"@tanstack/eslint-plugin-query": "5.91.2",
|
|
52
32
|
"eslint-config-prettier": "10.1.8",
|
|
53
|
-
"eslint-plugin-i18next": "6.1.3",
|
|
54
|
-
"eslint-plugin-import": "2.32.0",
|
|
55
|
-
"eslint-plugin-jest": "28.13.5",
|
|
56
|
-
"eslint-plugin-jsx-a11y": "6.10.2",
|
|
57
33
|
"eslint-plugin-no-unsanitized": "4.1.4",
|
|
58
|
-
"eslint-plugin-react": "7.37.5",
|
|
59
|
-
"eslint-plugin-react-hooks": "7.0.1",
|
|
60
34
|
"eslint-plugin-security": "3.0.1",
|
|
61
35
|
"eslint-plugin-simple-import-sort": "12.1.1",
|
|
62
36
|
"eslint-plugin-sonarjs": "3.0.5",
|
|
@@ -65,8 +39,5 @@
|
|
|
65
39
|
},
|
|
66
40
|
"engines": {
|
|
67
41
|
"node": ">=18"
|
|
68
|
-
},
|
|
69
|
-
"volta": {
|
|
70
|
-
"node": "24.12.0"
|
|
71
42
|
}
|
|
72
43
|
}
|
package/README.md
DELETED
|
@@ -1,226 +0,0 @@
|
|
|
1
|
-
# @bratislava/eslint-config
|
|
2
|
-
|
|
3
|
-
Shareable ESLint configurations for Bratislava projects. Built for ESLint v9 flat config format.
|
|
4
|
-
|
|
5
|
-
## Configurations
|
|
6
|
-
|
|
7
|
-
This package provides three ESLint configurations:
|
|
8
|
-
|
|
9
|
-
| Config | Description | Use Case |
|
|
10
|
-
| --------------------------------- | ------------------------------ | -------------------------- |
|
|
11
|
-
| `@bratislava/eslint-config/nest` | NestJS backend configuration | NestJS APIs and services |
|
|
12
|
-
| `@bratislava/eslint-config/next` | Next.js frontend configuration | Next.js applications |
|
|
13
|
-
| `@bratislava/eslint-config/react` | React configuration | React apps without Next.js |
|
|
14
|
-
|
|
15
|
-
## Installation
|
|
16
|
-
|
|
17
|
-
```bash
|
|
18
|
-
npm install --save-dev @bratislava/eslint-config eslint typescript
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
## Usage
|
|
22
|
-
|
|
23
|
-
### NestJS Projects
|
|
24
|
-
|
|
25
|
-
Create `eslint.config.mjs` in your project root:
|
|
26
|
-
|
|
27
|
-
```javascript
|
|
28
|
-
import { createNestConfig } from "@bratislava/eslint-config/nest";
|
|
29
|
-
|
|
30
|
-
export default createNestConfig({
|
|
31
|
-
tsconfigRootDir: import.meta.dirname,
|
|
32
|
-
ignores: ["src/generated-clients/*"],
|
|
33
|
-
});
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
Or use the default configuration:
|
|
37
|
-
|
|
38
|
-
```javascript
|
|
39
|
-
import nestConfig from "@bratislava/eslint-config/nest";
|
|
40
|
-
|
|
41
|
-
export default nestConfig;
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
### Next.js Projects
|
|
45
|
-
|
|
46
|
-
Create `eslint.config.mjs` in your project root:
|
|
47
|
-
|
|
48
|
-
```javascript
|
|
49
|
-
import { createNextConfig } from "@bratislava/eslint-config/next";
|
|
50
|
-
|
|
51
|
-
export default createNextConfig({
|
|
52
|
-
ignores: ["services/graphql/**"],
|
|
53
|
-
});
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
Or use the default configuration:
|
|
57
|
-
|
|
58
|
-
```javascript
|
|
59
|
-
import nextConfig from "@bratislava/eslint-config/next";
|
|
60
|
-
|
|
61
|
-
export default nextConfig;
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
### React Projects (without Next.js)
|
|
65
|
-
|
|
66
|
-
Create `eslint.config.mjs` in your project root:
|
|
67
|
-
|
|
68
|
-
```javascript
|
|
69
|
-
import { createReactConfig } from "@bratislava/eslint-config/react";
|
|
70
|
-
|
|
71
|
-
export default createReactConfig({
|
|
72
|
-
ignores: ["src/generated/**"],
|
|
73
|
-
});
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
Or use the default configuration:
|
|
77
|
-
|
|
78
|
-
```javascript
|
|
79
|
-
import reactConfig from "@bratislava/eslint-config/react";
|
|
80
|
-
|
|
81
|
-
export default reactConfig;
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
## What's Included
|
|
85
|
-
|
|
86
|
-
### Base Configuration (shared by all configs)
|
|
87
|
-
|
|
88
|
-
- **ESLint recommended** rules
|
|
89
|
-
- **TypeScript ESLint** strict and stylistic rules
|
|
90
|
-
- **Prettier** integration (disables conflicting rules)
|
|
91
|
-
- **Security** plugin for detecting security vulnerabilities
|
|
92
|
-
- **No-unsanitized** plugin for preventing XSS
|
|
93
|
-
- **SonarJS** plugin for code quality
|
|
94
|
-
- **Simple import sort** for consistent import ordering
|
|
95
|
-
|
|
96
|
-
### NestJS Config
|
|
97
|
-
|
|
98
|
-
Everything in base, plus:
|
|
99
|
-
|
|
100
|
-
- **NestJS Typed** plugin for NestJS-specific rules
|
|
101
|
-
- **Jest** plugin for test files
|
|
102
|
-
- **JSON** linting support
|
|
103
|
-
- **Markdown** linting support
|
|
104
|
-
- `no-console: error` (enforces logger usage)
|
|
105
|
-
|
|
106
|
-
### Next.js Config
|
|
107
|
-
|
|
108
|
-
Everything in base, plus:
|
|
109
|
-
|
|
110
|
-
- **Next.js** plugin with recommended and Core Web Vitals rules
|
|
111
|
-
- **React** and **React Hooks** plugins
|
|
112
|
-
- **JSX A11y** for accessibility
|
|
113
|
-
- **Import** plugin
|
|
114
|
-
- **i18next** plugin for internationalization
|
|
115
|
-
- **TanStack Query** plugin
|
|
116
|
-
- `no-console: warn`
|
|
117
|
-
|
|
118
|
-
### React Config
|
|
119
|
-
|
|
120
|
-
Everything in base, plus:
|
|
121
|
-
|
|
122
|
-
- **React** and **React Hooks** plugins
|
|
123
|
-
- **JSX A11y** for accessibility
|
|
124
|
-
- **Import** plugin
|
|
125
|
-
- **TanStack Query** plugin
|
|
126
|
-
- `no-console: warn`
|
|
127
|
-
|
|
128
|
-
## Customization
|
|
129
|
-
|
|
130
|
-
### Extending with Additional Rules
|
|
131
|
-
|
|
132
|
-
```javascript
|
|
133
|
-
import { createNestConfig } from "@bratislava/eslint-config/nest";
|
|
134
|
-
|
|
135
|
-
export default [
|
|
136
|
-
...createNestConfig({
|
|
137
|
-
tsconfigRootDir: import.meta.dirname,
|
|
138
|
-
}),
|
|
139
|
-
{
|
|
140
|
-
// Your custom rules
|
|
141
|
-
rules: {
|
|
142
|
-
"no-console": "warn", // Override to warn instead of error
|
|
143
|
-
},
|
|
144
|
-
},
|
|
145
|
-
];
|
|
146
|
-
```
|
|
147
|
-
|
|
148
|
-
### Using Individual Exports
|
|
149
|
-
|
|
150
|
-
The base config exports individual rule sets you can use:
|
|
151
|
-
|
|
152
|
-
```javascript
|
|
153
|
-
import {
|
|
154
|
-
typescriptRules,
|
|
155
|
-
eslintRules,
|
|
156
|
-
sonarjsRules,
|
|
157
|
-
simpleImportSortConfig,
|
|
158
|
-
} from "@bratislava/eslint-config";
|
|
159
|
-
```
|
|
160
|
-
|
|
161
|
-
## Peer Dependencies
|
|
162
|
-
|
|
163
|
-
This package requires:
|
|
164
|
-
|
|
165
|
-
- `eslint` >= 9
|
|
166
|
-
- `typescript` >= 5
|
|
167
|
-
|
|
168
|
-
## Publishing to npm
|
|
169
|
-
|
|
170
|
-
### Prerequisites
|
|
171
|
-
|
|
172
|
-
1. Create an npm account at https://www.npmjs.com/signup
|
|
173
|
-
2. Create the `@bratislava` organization on npm (or ensure you have publish access)
|
|
174
|
-
3. Login to npm CLI:
|
|
175
|
-
|
|
176
|
-
```bash
|
|
177
|
-
npm login
|
|
178
|
-
```
|
|
179
|
-
|
|
180
|
-
### Publishing Steps
|
|
181
|
-
|
|
182
|
-
1. **Update version** in `package.json`:
|
|
183
|
-
|
|
184
|
-
```bash
|
|
185
|
-
npm version patch # for bug fixes
|
|
186
|
-
npm version minor # for new features
|
|
187
|
-
npm version major # for breaking changes
|
|
188
|
-
```
|
|
189
|
-
|
|
190
|
-
2. **Publish the package**:
|
|
191
|
-
|
|
192
|
-
You'll need 2FA setup on your npm account.
|
|
193
|
-
|
|
194
|
-
```bash
|
|
195
|
-
npm publish --access public
|
|
196
|
-
```
|
|
197
|
-
|
|
198
|
-
## Development
|
|
199
|
-
|
|
200
|
-
### Testing Locally
|
|
201
|
-
|
|
202
|
-
Link the package locally before publishing:
|
|
203
|
-
|
|
204
|
-
```bash
|
|
205
|
-
# In the eslint-config directory
|
|
206
|
-
npm link
|
|
207
|
-
|
|
208
|
-
# In a project that will use it
|
|
209
|
-
npm link @bratislava/eslint-config
|
|
210
|
-
```
|
|
211
|
-
|
|
212
|
-
### Updating Dependencies
|
|
213
|
-
|
|
214
|
-
```bash
|
|
215
|
-
npm update
|
|
216
|
-
```
|
|
217
|
-
|
|
218
|
-
## License
|
|
219
|
-
|
|
220
|
-
EUPL-1.2
|
|
221
|
-
|
|
222
|
-
## Contributing
|
|
223
|
-
|
|
224
|
-
1. Make changes to the configuration files
|
|
225
|
-
2. Test in a real project using `npm link`
|
|
226
|
-
3. Update version and publish
|
package/nest.js
DELETED
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @bratislava/eslint-config/nest
|
|
3
|
-
*
|
|
4
|
-
* ESLint configuration for NestJS backend projects.
|
|
5
|
-
* Extends base config with NestJS-specific rules and plugins.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import eslintNestJs from '@darraghor/eslint-plugin-nestjs-typed'
|
|
9
|
-
import eslint from '@eslint/js'
|
|
10
|
-
import json from '@eslint/json'
|
|
11
|
-
import markdown from '@eslint/markdown'
|
|
12
|
-
import prettier from 'eslint-config-prettier'
|
|
13
|
-
import jest from 'eslint-plugin-jest'
|
|
14
|
-
import noUnsanitized from 'eslint-plugin-no-unsanitized'
|
|
15
|
-
import security from 'eslint-plugin-security'
|
|
16
|
-
import sonarjs from 'eslint-plugin-sonarjs'
|
|
17
|
-
import globals from 'globals'
|
|
18
|
-
import tseslint from 'typescript-eslint'
|
|
19
|
-
|
|
20
|
-
import {
|
|
21
|
-
disabledRules,
|
|
22
|
-
eslintRules,
|
|
23
|
-
simpleImportSortConfig,
|
|
24
|
-
sonarjsRules,
|
|
25
|
-
typescriptRules,
|
|
26
|
-
} from './index.js'
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* NestJS-specific rules
|
|
30
|
-
*/
|
|
31
|
-
const nestRules = {
|
|
32
|
-
// We're used to style without this, extra typing with little value
|
|
33
|
-
'@darraghor/nestjs-typed/api-property-returning-array-should-set-array': 'off',
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Backend-specific rules
|
|
38
|
-
*/
|
|
39
|
-
const backendRules = {
|
|
40
|
-
// Enforce logger use instead of console
|
|
41
|
-
'no-console': 'error',
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Jest test file configuration
|
|
46
|
-
*/
|
|
47
|
-
const jestConfig = {
|
|
48
|
-
files: ['**/*.spec.ts', '**/*.test.ts'],
|
|
49
|
-
plugins: {
|
|
50
|
-
jest,
|
|
51
|
-
},
|
|
52
|
-
rules: {
|
|
53
|
-
// Use jest version of unbound-method
|
|
54
|
-
'@typescript-eslint/unbound-method': 'off',
|
|
55
|
-
'jest/unbound-method': 'error',
|
|
56
|
-
// Allow unused vars in tests (common with mocking)
|
|
57
|
-
'@typescript-eslint/no-unused-vars': 'warn',
|
|
58
|
-
},
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Creates a NestJS ESLint configuration.
|
|
63
|
-
*
|
|
64
|
-
* @param {Object} options - Configuration options
|
|
65
|
-
* @param {string} [options.tsconfigRootDir] - Root directory for TypeScript config (defaults to process.cwd())
|
|
66
|
-
* @param {string[]} [options.ignores] - Additional patterns to ignore
|
|
67
|
-
* @returns {Array} ESLint flat config array
|
|
68
|
-
*
|
|
69
|
-
* @example
|
|
70
|
-
* // eslint.config.mjs
|
|
71
|
-
* import { createNestConfig } from '@bratislava/eslint-config/nest'
|
|
72
|
-
*
|
|
73
|
-
* export default createNestConfig({
|
|
74
|
-
* tsconfigRootDir: import.meta.dirname,
|
|
75
|
-
* ignores: ['src/generated-clients/*'],
|
|
76
|
-
* })
|
|
77
|
-
*/
|
|
78
|
-
export function createNestConfig(options = {}) {
|
|
79
|
-
const { tsconfigRootDir = process.cwd(), ignores = [] } = options
|
|
80
|
-
|
|
81
|
-
return tseslint.config(
|
|
82
|
-
// Base configs
|
|
83
|
-
eslint.configs.recommended,
|
|
84
|
-
tseslint.configs.strictTypeChecked,
|
|
85
|
-
tseslint.configs.stylistic,
|
|
86
|
-
prettier,
|
|
87
|
-
security.configs.recommended,
|
|
88
|
-
noUnsanitized.configs.recommended,
|
|
89
|
-
sonarjs.configs.recommended,
|
|
90
|
-
eslintNestJs.configs.flatRecommended,
|
|
91
|
-
|
|
92
|
-
// Markdown support
|
|
93
|
-
...markdown.configs.recommended,
|
|
94
|
-
|
|
95
|
-
// JSON support
|
|
96
|
-
{
|
|
97
|
-
plugins: {
|
|
98
|
-
json,
|
|
99
|
-
},
|
|
100
|
-
},
|
|
101
|
-
{
|
|
102
|
-
files: ['**/*.json'],
|
|
103
|
-
ignores: ['package-lock.json'],
|
|
104
|
-
language: 'json/json',
|
|
105
|
-
...json.configs.recommended,
|
|
106
|
-
},
|
|
107
|
-
|
|
108
|
-
// Import sorting
|
|
109
|
-
simpleImportSortConfig,
|
|
110
|
-
|
|
111
|
-
// Language options
|
|
112
|
-
{
|
|
113
|
-
languageOptions: {
|
|
114
|
-
parserOptions: {
|
|
115
|
-
projectService: true,
|
|
116
|
-
tsconfigRootDir,
|
|
117
|
-
},
|
|
118
|
-
globals: {
|
|
119
|
-
...globals.node,
|
|
120
|
-
...globals.es2021,
|
|
121
|
-
},
|
|
122
|
-
},
|
|
123
|
-
},
|
|
124
|
-
|
|
125
|
-
// Main rules
|
|
126
|
-
{
|
|
127
|
-
rules: {
|
|
128
|
-
...typescriptRules,
|
|
129
|
-
...eslintRules,
|
|
130
|
-
...sonarjsRules,
|
|
131
|
-
...disabledRules,
|
|
132
|
-
...nestRules,
|
|
133
|
-
...backendRules,
|
|
134
|
-
},
|
|
135
|
-
},
|
|
136
|
-
|
|
137
|
-
// Jest config for test files
|
|
138
|
-
jestConfig,
|
|
139
|
-
|
|
140
|
-
// Default ignores
|
|
141
|
-
{
|
|
142
|
-
ignores: [
|
|
143
|
-
'dist/**',
|
|
144
|
-
'node_modules/**',
|
|
145
|
-
'coverage/**',
|
|
146
|
-
'*.config.js',
|
|
147
|
-
'*.config.mjs',
|
|
148
|
-
'*.config.ts',
|
|
149
|
-
'eslint.config.js',
|
|
150
|
-
'eslint.config.mjs',
|
|
151
|
-
'eslint.config.ts',
|
|
152
|
-
...ignores,
|
|
153
|
-
],
|
|
154
|
-
},
|
|
155
|
-
)
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
* Default NestJS configuration.
|
|
160
|
-
* For customization, use createNestConfig() instead.
|
|
161
|
-
*/
|
|
162
|
-
export default createNestConfig()
|
package/next.js
DELETED
|
@@ -1,214 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @bratislava/eslint-config/next
|
|
3
|
-
*
|
|
4
|
-
* ESLint configuration for Next.js frontend projects.
|
|
5
|
-
* Extends base config with Next.js, React, and i18n-specific rules.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import eslint from '@eslint/js'
|
|
9
|
-
import nextPlugin from '@next/eslint-plugin-next'
|
|
10
|
-
import tanstackQuery from '@tanstack/eslint-plugin-query'
|
|
11
|
-
import prettier from 'eslint-config-prettier'
|
|
12
|
-
import i18next from 'eslint-plugin-i18next'
|
|
13
|
-
import importPlugin from 'eslint-plugin-import'
|
|
14
|
-
import jsxA11y from 'eslint-plugin-jsx-a11y'
|
|
15
|
-
import noUnsanitized from 'eslint-plugin-no-unsanitized'
|
|
16
|
-
import react from 'eslint-plugin-react'
|
|
17
|
-
import reactHooks from 'eslint-plugin-react-hooks'
|
|
18
|
-
import security from 'eslint-plugin-security'
|
|
19
|
-
import sonarjs from 'eslint-plugin-sonarjs'
|
|
20
|
-
import globals from 'globals'
|
|
21
|
-
import tseslint from 'typescript-eslint'
|
|
22
|
-
|
|
23
|
-
import {
|
|
24
|
-
disabledRules,
|
|
25
|
-
eslintRules,
|
|
26
|
-
simpleImportSortConfig,
|
|
27
|
-
sonarjsRules,
|
|
28
|
-
typescriptRules,
|
|
29
|
-
} from './index.js'
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* React-specific rules
|
|
33
|
-
*/
|
|
34
|
-
export const reactRules = {
|
|
35
|
-
'react/function-component-definition': [2, { namedComponents: 'arrow-function' }],
|
|
36
|
-
'react/require-default-props': 'off',
|
|
37
|
-
'react/react-in-jsx-scope': 'off',
|
|
38
|
-
'react/jsx-no-useless-fragment': [2, { allowExpressions: true }],
|
|
39
|
-
'react/display-name': 'off',
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Import plugin rules (relaxed for Next.js)
|
|
44
|
-
*/
|
|
45
|
-
export const importRules = {
|
|
46
|
-
'import/prefer-default-export': 'off',
|
|
47
|
-
'import/extensions': 'off',
|
|
48
|
-
'import/no-unresolved': 'off',
|
|
49
|
-
'import/namespace': 'off',
|
|
50
|
-
'import/default': 'off',
|
|
51
|
-
'import/no-duplicates': 'off',
|
|
52
|
-
'import/no-named-as-default': 'off',
|
|
53
|
-
'import/no-named-as-default-member': 'off',
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* JSX A11y rules
|
|
58
|
-
*/
|
|
59
|
-
export const jsxA11yRules = {
|
|
60
|
-
'jsx-a11y/anchor-is-valid': 'off',
|
|
61
|
-
'jsx-a11y/img-redundant-alt': 'warn',
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Next.js-specific rules
|
|
66
|
-
*/
|
|
67
|
-
const nextRules = {
|
|
68
|
-
'@next/next/no-img-element': 'off',
|
|
69
|
-
'no-underscore-dangle': [
|
|
70
|
-
2,
|
|
71
|
-
{ allow: ['__NEXT_DATA__', '__NEXT_LOADED_PAGES__', '__typename'] },
|
|
72
|
-
],
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Frontend-specific rules
|
|
77
|
-
*/
|
|
78
|
-
const frontendRules = {
|
|
79
|
-
// Console warnings instead of errors for frontend
|
|
80
|
-
'no-console': 'warn',
|
|
81
|
-
|
|
82
|
-
// Return statement formatting
|
|
83
|
-
'padding-line-between-statements': [
|
|
84
|
-
'warn',
|
|
85
|
-
{ blankLine: 'always', prev: '*', next: 'return' },
|
|
86
|
-
],
|
|
87
|
-
|
|
88
|
-
// Empty function allowed (common in React)
|
|
89
|
-
'@typescript-eslint/no-empty-function': 'off',
|
|
90
|
-
|
|
91
|
-
// Misused promises config for React event handlers
|
|
92
|
-
'@typescript-eslint/no-misused-promises': [
|
|
93
|
-
'error',
|
|
94
|
-
{ checksVoidReturn: { attributes: false } },
|
|
95
|
-
],
|
|
96
|
-
'@typescript-eslint/no-floating-promises': 'warn',
|
|
97
|
-
|
|
98
|
-
// i18next rules (disabled by default, enable in project if needed)
|
|
99
|
-
'i18next/no-literal-string': 'off',
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Creates a Next.js ESLint configuration.
|
|
104
|
-
*
|
|
105
|
-
* @param {Object} options - Configuration options
|
|
106
|
-
* @param {string[]} [options.ignores] - Additional patterns to ignore
|
|
107
|
-
* @returns {Array} ESLint flat config array
|
|
108
|
-
*
|
|
109
|
-
* @example
|
|
110
|
-
* // eslint.config.mjs
|
|
111
|
-
* import { createNextConfig } from '@bratislava/eslint-config/next'
|
|
112
|
-
*
|
|
113
|
-
* export default createNextConfig({
|
|
114
|
-
* ignores: ['services/graphql/**'],
|
|
115
|
-
* })
|
|
116
|
-
*/
|
|
117
|
-
export function createNextConfig(options = {}) {
|
|
118
|
-
const { ignores = [] } = options
|
|
119
|
-
|
|
120
|
-
return tseslint.config(
|
|
121
|
-
// Next.js flat config
|
|
122
|
-
nextPlugin.flatConfig.recommended,
|
|
123
|
-
nextPlugin.flatConfig.coreWebVitals,
|
|
124
|
-
|
|
125
|
-
// React and related plugins
|
|
126
|
-
{
|
|
127
|
-
plugins: {
|
|
128
|
-
react,
|
|
129
|
-
'react-hooks': reactHooks,
|
|
130
|
-
import: importPlugin,
|
|
131
|
-
'jsx-a11y': jsxA11y,
|
|
132
|
-
},
|
|
133
|
-
rules: {
|
|
134
|
-
...reactRules,
|
|
135
|
-
...importRules,
|
|
136
|
-
...jsxA11yRules,
|
|
137
|
-
...nextRules,
|
|
138
|
-
},
|
|
139
|
-
},
|
|
140
|
-
|
|
141
|
-
// Language options
|
|
142
|
-
{
|
|
143
|
-
languageOptions: {
|
|
144
|
-
parserOptions: {
|
|
145
|
-
projectService: true,
|
|
146
|
-
},
|
|
147
|
-
globals: {
|
|
148
|
-
...globals.browser,
|
|
149
|
-
...globals.node,
|
|
150
|
-
...globals.es2021,
|
|
151
|
-
},
|
|
152
|
-
},
|
|
153
|
-
},
|
|
154
|
-
|
|
155
|
-
// Base configs
|
|
156
|
-
eslint.configs.recommended,
|
|
157
|
-
tseslint.configs.strictTypeChecked,
|
|
158
|
-
tseslint.configs.stylistic,
|
|
159
|
-
prettier,
|
|
160
|
-
simpleImportSortConfig,
|
|
161
|
-
security.configs.recommended,
|
|
162
|
-
noUnsanitized.configs.recommended,
|
|
163
|
-
sonarjs.configs.recommended,
|
|
164
|
-
i18next.configs['flat/recommended'],
|
|
165
|
-
tanstackQuery.configs['flat/recommended'],
|
|
166
|
-
|
|
167
|
-
// Main rules
|
|
168
|
-
{
|
|
169
|
-
rules: {
|
|
170
|
-
...typescriptRules,
|
|
171
|
-
...eslintRules,
|
|
172
|
-
...sonarjsRules,
|
|
173
|
-
...disabledRules,
|
|
174
|
-
...frontendRules,
|
|
175
|
-
|
|
176
|
-
// SonarJS additional config for frontend
|
|
177
|
-
'sonarjs/different-types-comparison': 'off',
|
|
178
|
-
},
|
|
179
|
-
},
|
|
180
|
-
|
|
181
|
-
// Next.js pages directory config
|
|
182
|
-
{
|
|
183
|
-
files: ['**/pages/**/*.{js,jsx,ts,tsx}', '**/src/pages/**/*.{js,jsx,ts,tsx}'],
|
|
184
|
-
rules: {
|
|
185
|
-
'react/display-name': 'off',
|
|
186
|
-
},
|
|
187
|
-
},
|
|
188
|
-
|
|
189
|
-
// Ignore patterns
|
|
190
|
-
{
|
|
191
|
-
ignores: [
|
|
192
|
-
'dist/**',
|
|
193
|
-
'node_modules/**',
|
|
194
|
-
'coverage/**',
|
|
195
|
-
'*.config.js',
|
|
196
|
-
'*.config.mjs',
|
|
197
|
-
'*.config.ts',
|
|
198
|
-
'eslint.config.js',
|
|
199
|
-
'eslint.config.mjs',
|
|
200
|
-
'next-env.d.ts',
|
|
201
|
-
'**/*.svg',
|
|
202
|
-
'.next/**',
|
|
203
|
-
'out/**',
|
|
204
|
-
...ignores,
|
|
205
|
-
],
|
|
206
|
-
},
|
|
207
|
-
)
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
/**
|
|
211
|
-
* Default Next.js configuration.
|
|
212
|
-
* For customization, use createNextConfig() instead.
|
|
213
|
-
*/
|
|
214
|
-
export default createNextConfig()
|
package/react.js
DELETED
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @bratislava/eslint-config/react
|
|
3
|
-
*
|
|
4
|
-
* ESLint configuration for React projects (without Next.js).
|
|
5
|
-
* Extends base config with React-specific rules and plugins.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import eslint from '@eslint/js'
|
|
9
|
-
import tanstackQuery from '@tanstack/eslint-plugin-query'
|
|
10
|
-
import prettier from 'eslint-config-prettier'
|
|
11
|
-
import importPlugin from 'eslint-plugin-import'
|
|
12
|
-
import jsxA11y from 'eslint-plugin-jsx-a11y'
|
|
13
|
-
import noUnsanitized from 'eslint-plugin-no-unsanitized'
|
|
14
|
-
import react from 'eslint-plugin-react'
|
|
15
|
-
import reactHooks from 'eslint-plugin-react-hooks'
|
|
16
|
-
import security from 'eslint-plugin-security'
|
|
17
|
-
import sonarjs from 'eslint-plugin-sonarjs'
|
|
18
|
-
import globals from 'globals'
|
|
19
|
-
import tseslint from 'typescript-eslint'
|
|
20
|
-
|
|
21
|
-
import {
|
|
22
|
-
disabledRules,
|
|
23
|
-
eslintRules,
|
|
24
|
-
simpleImportSortConfig,
|
|
25
|
-
sonarjsRules,
|
|
26
|
-
typescriptRules,
|
|
27
|
-
} from './index.js'
|
|
28
|
-
import { importRules, jsxA11yRules,reactRules } from './next.js'
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Frontend-specific rules (same as Next.js config, without Next.js-specific rules)
|
|
32
|
-
*/
|
|
33
|
-
const frontendRules = {
|
|
34
|
-
// Console warnings instead of errors for frontend
|
|
35
|
-
'no-console': 'warn',
|
|
36
|
-
|
|
37
|
-
// Return statement formatting
|
|
38
|
-
'padding-line-between-statements': [
|
|
39
|
-
'warn',
|
|
40
|
-
{ blankLine: 'always', prev: '*', next: 'return' },
|
|
41
|
-
],
|
|
42
|
-
|
|
43
|
-
// Empty function allowed (common in React)
|
|
44
|
-
'@typescript-eslint/no-empty-function': 'off',
|
|
45
|
-
|
|
46
|
-
// Misused promises config for React event handlers
|
|
47
|
-
'@typescript-eslint/no-misused-promises': [
|
|
48
|
-
'error',
|
|
49
|
-
{ checksVoidReturn: { attributes: false } },
|
|
50
|
-
],
|
|
51
|
-
'@typescript-eslint/no-floating-promises': 'warn',
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Creates a React ESLint configuration.
|
|
56
|
-
*
|
|
57
|
-
* @param {Object} options - Configuration options
|
|
58
|
-
* @param {string[]} [options.ignores] - Additional patterns to ignore
|
|
59
|
-
* @returns {Array} ESLint flat config array
|
|
60
|
-
*
|
|
61
|
-
* @example
|
|
62
|
-
* // eslint.config.mjs
|
|
63
|
-
* import { createReactConfig } from '@bratislava/eslint-config/react'
|
|
64
|
-
*
|
|
65
|
-
* export default createReactConfig({
|
|
66
|
-
* ignores: ['src/generated/**'],
|
|
67
|
-
* })
|
|
68
|
-
*/
|
|
69
|
-
export function createReactConfig(options = {}) {
|
|
70
|
-
const { ignores = [] } = options
|
|
71
|
-
|
|
72
|
-
return tseslint.config(
|
|
73
|
-
// Base configs
|
|
74
|
-
eslint.configs.recommended,
|
|
75
|
-
tseslint.configs.strictTypeChecked,
|
|
76
|
-
tseslint.configs.stylistic,
|
|
77
|
-
prettier,
|
|
78
|
-
simpleImportSortConfig,
|
|
79
|
-
security.configs.recommended,
|
|
80
|
-
noUnsanitized.configs.recommended,
|
|
81
|
-
sonarjs.configs.recommended,
|
|
82
|
-
tanstackQuery.configs['flat/recommended'],
|
|
83
|
-
|
|
84
|
-
// React and related plugins
|
|
85
|
-
{
|
|
86
|
-
plugins: {
|
|
87
|
-
react,
|
|
88
|
-
'react-hooks': reactHooks,
|
|
89
|
-
import: importPlugin,
|
|
90
|
-
'jsx-a11y': jsxA11y,
|
|
91
|
-
},
|
|
92
|
-
rules: {
|
|
93
|
-
...reactRules,
|
|
94
|
-
...importRules,
|
|
95
|
-
...jsxA11yRules,
|
|
96
|
-
},
|
|
97
|
-
},
|
|
98
|
-
|
|
99
|
-
// Language options
|
|
100
|
-
{
|
|
101
|
-
languageOptions: {
|
|
102
|
-
parserOptions: {
|
|
103
|
-
projectService: true,
|
|
104
|
-
ecmaFeatures: {
|
|
105
|
-
jsx: true,
|
|
106
|
-
},
|
|
107
|
-
},
|
|
108
|
-
globals: {
|
|
109
|
-
...globals.browser,
|
|
110
|
-
...globals.es2021,
|
|
111
|
-
},
|
|
112
|
-
},
|
|
113
|
-
},
|
|
114
|
-
|
|
115
|
-
// React settings
|
|
116
|
-
{
|
|
117
|
-
settings: {
|
|
118
|
-
react: {
|
|
119
|
-
version: 'detect',
|
|
120
|
-
},
|
|
121
|
-
},
|
|
122
|
-
},
|
|
123
|
-
|
|
124
|
-
// Main rules
|
|
125
|
-
{
|
|
126
|
-
rules: {
|
|
127
|
-
...typescriptRules,
|
|
128
|
-
...eslintRules,
|
|
129
|
-
...sonarjsRules,
|
|
130
|
-
...disabledRules,
|
|
131
|
-
...frontendRules,
|
|
132
|
-
|
|
133
|
-
// SonarJS additional config for frontend
|
|
134
|
-
'sonarjs/different-types-comparison': 'off',
|
|
135
|
-
},
|
|
136
|
-
},
|
|
137
|
-
|
|
138
|
-
// Ignore patterns
|
|
139
|
-
{
|
|
140
|
-
ignores: [
|
|
141
|
-
'dist/**',
|
|
142
|
-
'build/**',
|
|
143
|
-
'node_modules/**',
|
|
144
|
-
'coverage/**',
|
|
145
|
-
'*.config.js',
|
|
146
|
-
'*.config.mjs',
|
|
147
|
-
'*.config.ts',
|
|
148
|
-
'eslint.config.js',
|
|
149
|
-
'eslint.config.mjs',
|
|
150
|
-
'**/*.svg',
|
|
151
|
-
...ignores,
|
|
152
|
-
],
|
|
153
|
-
},
|
|
154
|
-
)
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
/**
|
|
158
|
-
* Default React configuration.
|
|
159
|
-
* For customization, use createReactConfig() instead.
|
|
160
|
-
*/
|
|
161
|
-
export default createReactConfig()
|