@bollgade/eslint-config-base 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 +13 -0
- package/README.md +63 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +189 -0
- package/package.json +59 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
MIT License Copyright (c) 2025 Чернышев Андрей
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted,
|
|
4
|
+
free of charge, to any person obtaining a copy of this software and associated
|
|
5
|
+
documentation files (the "Software"), to deal in the Software without
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
|
|
8
|
+
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
9
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
|
|
10
|
+
EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
|
11
|
+
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
12
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
13
|
+
THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# @bollgade/eslint-config-base
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@bollgade/eslint-config-base)
|
|
4
|
+
[](https://www.npmjs.com/package/@bollgade/eslint-config-base)
|
|
5
|
+
|
|
6
|
+
Base **ESLint flat config** for TypeScript projects: NestJS, Express, and plain TypeScript.
|
|
7
|
+
It bundles rules from [`@eslint/js`](https://www.npmjs.com/package/@eslint/js), [`typescript-eslint`](https://www.npmjs.com/package/typescript-eslint), [`eslint-plugin-import`](https://www.npmjs.com/package/eslint-plugin-import), [`eslint-plugin-unused-imports`](https://www.npmjs.com/package/eslint-plugin-unused-imports), [`@stylistic/eslint-plugin`](https://www.npmjs.com/package/@stylistic/eslint-plugin), and integrates Prettier via [`eslint-plugin-prettier`](https://www.npmjs.com/package/eslint-plugin-prettier) (using its `recommended` preset).
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install -D @bollgade/eslint-config-base
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Usage (ESLint 9 flat config)
|
|
16
|
+
|
|
17
|
+
Create eslint.config.mts (or eslint.config.js):
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
// eslint.config.mts
|
|
21
|
+
import { defineConfig } from 'eslint/config';
|
|
22
|
+
import baseConfig from '@bollgade/eslint-config-base';
|
|
23
|
+
|
|
24
|
+
export default defineConfig(
|
|
25
|
+
baseConfig,
|
|
26
|
+
);
|
|
27
|
+
With local overrides:
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
// eslint.config.mts
|
|
32
|
+
import { defineConfig } from "eslint/config";
|
|
33
|
+
import baseConfig from "@bollgade/eslint-config-base";
|
|
34
|
+
|
|
35
|
+
export default defineConfig(baseConfig, {
|
|
36
|
+
rules: {
|
|
37
|
+
// your overrides
|
|
38
|
+
"no-console": "off",
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
This config assumes you have `tsconfig.json` in your project root; it is used for typed linting via parserOptions.project.
|
|
44
|
+
|
|
45
|
+
## What’s included
|
|
46
|
+
|
|
47
|
+
| Category | Purpose | Main config / rules |
|
|
48
|
+
| -------- | ------------------------- | ----------------------------------------------------------------------------------------------------------------- |
|
|
49
|
+
| Core | Baseline JS linting | `@eslint/js` → `eslint.configs.recommended` + a few extras (e.g. `no-trailing-spaces`, `max-len`) |
|
|
50
|
+
| Language | Runtime globals + parsing | `ecmaVersion: 2024`, `sourceType: 'module'`, `globals: node + jest` |
|
|
51
|
+
| TS rules | Strictness & safety | `strictTypeChecked` + `stylisticTypeChecked` + extra rules like `no-floating-promises`, `no-unsafe-member-access` |
|
|
52
|
+
| Imports | Import hygiene | `eslint-plugin-import` flat configs + `import/order` + `import/no-extraneous-dependencies` |
|
|
53
|
+
| Style | ESLint-first formatting | `@stylistic/eslint-plugin` preset + a few overrides |
|
|
54
|
+
| Prettier | Formatting enforcement | `eslint-plugin-prettier/recommended` + `prettier/prettier` (`singleQuote: true`) |
|
|
55
|
+
|
|
56
|
+
## Roadmap
|
|
57
|
+
|
|
58
|
+
Planned improvements:
|
|
59
|
+
|
|
60
|
+
- Expose a `createBaseConfig(options)` factory to:
|
|
61
|
+
- Customize `tsconfig` path(s) used for typed linting (e.g. `tsconfig.json`, `tsconfig.eslint.json`).
|
|
62
|
+
- Toggle strict type-aware linting on/off (switch between strict typed configs and lighter presets).
|
|
63
|
+
- Enable/disable most rule categories and customize them via options (without requiring users to append manual override blocks).
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
import eslint from "@eslint/js";
|
|
3
|
+
import stylisticPlugin from "@stylistic/eslint-plugin";
|
|
4
|
+
import { defineConfig } from "eslint/config";
|
|
5
|
+
import { flatConfigs as importPluginFlat } from "eslint-plugin-import";
|
|
6
|
+
import eslintPluginPrettierRecommended from "eslint-plugin-prettier/recommended";
|
|
7
|
+
import eslintPluginUnusedImports from "eslint-plugin-unused-imports";
|
|
8
|
+
import globals from "globals";
|
|
9
|
+
import {
|
|
10
|
+
parser as tseslintParser,
|
|
11
|
+
configs as tseslintConfigs
|
|
12
|
+
} from "typescript-eslint";
|
|
13
|
+
var shouldBeIgnored = {
|
|
14
|
+
ignores: [
|
|
15
|
+
// dependencies
|
|
16
|
+
"/node_modules",
|
|
17
|
+
"/.pnp",
|
|
18
|
+
".pnp.js",
|
|
19
|
+
// testing
|
|
20
|
+
"/coverage",
|
|
21
|
+
// production
|
|
22
|
+
"/build",
|
|
23
|
+
"/dist",
|
|
24
|
+
"npm-debug.log*",
|
|
25
|
+
"yarn-debug.log*",
|
|
26
|
+
"yarn-error.log*"
|
|
27
|
+
]
|
|
28
|
+
};
|
|
29
|
+
var overridePrettier = [
|
|
30
|
+
eslintPluginPrettierRecommended,
|
|
31
|
+
{
|
|
32
|
+
rules: {
|
|
33
|
+
"prettier/prettier": ["error", { singleQuote: true }]
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
];
|
|
37
|
+
var typescriptLangOpt = {
|
|
38
|
+
languageOptions: {
|
|
39
|
+
parser: tseslintParser,
|
|
40
|
+
parserOptions: {
|
|
41
|
+
project: ["./tsconfig.json"],
|
|
42
|
+
tsconfigRootDir: process.cwd()
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
var typescript = [
|
|
47
|
+
typescriptLangOpt,
|
|
48
|
+
...tseslintConfigs.strictTypeChecked,
|
|
49
|
+
...tseslintConfigs.stylisticTypeChecked,
|
|
50
|
+
{
|
|
51
|
+
rules: {
|
|
52
|
+
"@typescript-eslint/no-unsafe-member-access": ["error"],
|
|
53
|
+
"@typescript-eslint/no-floating-promises": "warn",
|
|
54
|
+
"@typescript-eslint/no-unused-vars": [
|
|
55
|
+
"warn",
|
|
56
|
+
{
|
|
57
|
+
vars: "all",
|
|
58
|
+
varsIgnorePattern: "^_",
|
|
59
|
+
args: "after-used",
|
|
60
|
+
argsIgnorePattern: "^_"
|
|
61
|
+
}
|
|
62
|
+
]
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
];
|
|
66
|
+
var overridesForTests = {
|
|
67
|
+
files: ["**/*.{test,spec}.{ts,js}"],
|
|
68
|
+
rules: {
|
|
69
|
+
"max-len": "off"
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
var languageOptions = {
|
|
73
|
+
languageOptions: {
|
|
74
|
+
globals: {
|
|
75
|
+
...globals.node,
|
|
76
|
+
...globals.jest
|
|
77
|
+
},
|
|
78
|
+
ecmaVersion: 2024,
|
|
79
|
+
sourceType: "module"
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
var imports = [
|
|
83
|
+
importPluginFlat.recommended,
|
|
84
|
+
{
|
|
85
|
+
plugins: {
|
|
86
|
+
"unused-imports": eslintPluginUnusedImports
|
|
87
|
+
},
|
|
88
|
+
rules: {
|
|
89
|
+
"unused-imports/no-unused-imports": "error",
|
|
90
|
+
"import/order": [
|
|
91
|
+
"error",
|
|
92
|
+
{
|
|
93
|
+
groups: [
|
|
94
|
+
["builtin", "external"],
|
|
95
|
+
"internal",
|
|
96
|
+
["parent", "sibling", "index"]
|
|
97
|
+
],
|
|
98
|
+
alphabetize: {
|
|
99
|
+
order: "asc",
|
|
100
|
+
caseInsensitive: true
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
],
|
|
104
|
+
"import/no-extraneous-dependencies": [
|
|
105
|
+
"error",
|
|
106
|
+
{
|
|
107
|
+
devDependencies: [
|
|
108
|
+
"**/*.config.{ts,js}",
|
|
109
|
+
"**/eslint.config.*",
|
|
110
|
+
"**/*.{test,spec}.{ts,js}",
|
|
111
|
+
"**/{tests,__tests__,test,config}/**/*.{ts,js}"
|
|
112
|
+
]
|
|
113
|
+
}
|
|
114
|
+
],
|
|
115
|
+
"import/extensions": "off",
|
|
116
|
+
"import/prefer-default-export": "off"
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
];
|
|
120
|
+
var importsForTS = [
|
|
121
|
+
importPluginFlat.typescript,
|
|
122
|
+
{
|
|
123
|
+
settings: {
|
|
124
|
+
"import/resolver": {
|
|
125
|
+
typescript: {
|
|
126
|
+
alwaysTryTypes: true
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
files: ["**/*.{ts,tsx}"]
|
|
131
|
+
}
|
|
132
|
+
];
|
|
133
|
+
var stylistic = [
|
|
134
|
+
stylisticPlugin.configs.customize({
|
|
135
|
+
semi: true,
|
|
136
|
+
arrowParens: true,
|
|
137
|
+
jsx: false
|
|
138
|
+
}),
|
|
139
|
+
{
|
|
140
|
+
rules: {
|
|
141
|
+
"@stylistic/quote-props": ["error", "as-needed"],
|
|
142
|
+
"@stylistic/operator-linebreak": "off",
|
|
143
|
+
"@stylistic/type-annotation-spacing": "error",
|
|
144
|
+
"@stylistic/space-before-blocks": "error"
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
];
|
|
148
|
+
var eslintDefaults = [
|
|
149
|
+
eslint.configs.recommended,
|
|
150
|
+
{
|
|
151
|
+
rules: {
|
|
152
|
+
"no-trailing-spaces": "error",
|
|
153
|
+
"no-shadow": "off",
|
|
154
|
+
"no-underscore-dangle": "off",
|
|
155
|
+
"no-use-before-define": ["error", "nofunc"],
|
|
156
|
+
"no-param-reassign": [
|
|
157
|
+
"error",
|
|
158
|
+
{ ignorePropertyModificationsForRegex: ["state"] }
|
|
159
|
+
],
|
|
160
|
+
"no-undef": "off",
|
|
161
|
+
"no-console": "warn",
|
|
162
|
+
// Разрешаем в backend
|
|
163
|
+
// Style
|
|
164
|
+
"max-len": [
|
|
165
|
+
"error",
|
|
166
|
+
{
|
|
167
|
+
ignoreComments: true,
|
|
168
|
+
code: 120
|
|
169
|
+
}
|
|
170
|
+
],
|
|
171
|
+
"prefer-arrow-callback": ["error", { allowNamedFunctions: true }]
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
];
|
|
175
|
+
var config = defineConfig(
|
|
176
|
+
shouldBeIgnored,
|
|
177
|
+
eslintDefaults,
|
|
178
|
+
overridePrettier,
|
|
179
|
+
languageOptions,
|
|
180
|
+
stylistic,
|
|
181
|
+
typescript,
|
|
182
|
+
imports,
|
|
183
|
+
importsForTS,
|
|
184
|
+
overridesForTests
|
|
185
|
+
);
|
|
186
|
+
var index_default = config;
|
|
187
|
+
export {
|
|
188
|
+
index_default as default
|
|
189
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@bollgade/eslint-config-base",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Base ESLint config for TypeScript backend & vanilla JS/TS",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": "./dist/index.js"
|
|
11
|
+
},
|
|
12
|
+
"keywords": [
|
|
13
|
+
"eslint",
|
|
14
|
+
"eslintconfig",
|
|
15
|
+
"eslint-config",
|
|
16
|
+
"eslint flat config",
|
|
17
|
+
"flat config",
|
|
18
|
+
"typescript",
|
|
19
|
+
"prettier",
|
|
20
|
+
"import",
|
|
21
|
+
"unused-imports",
|
|
22
|
+
"node",
|
|
23
|
+
"backend",
|
|
24
|
+
"nestjs"
|
|
25
|
+
],
|
|
26
|
+
"author": "Bollgade <bollgade@gmail.com>",
|
|
27
|
+
"scripts": {
|
|
28
|
+
"build": "tsup src/index.ts --format esm --dts --clean",
|
|
29
|
+
"prepublishOnly": "npm run build",
|
|
30
|
+
"lint:ts": "eslint \"**/*.{ts,tsx}\" --max-warnings=0",
|
|
31
|
+
"lint:ts:fix": "npm run lint:ts -- --fix",
|
|
32
|
+
"type-check": "tsc --project ./tsconfig.json --noEmit"
|
|
33
|
+
},
|
|
34
|
+
"publishConfig": {
|
|
35
|
+
"access": "public"
|
|
36
|
+
},
|
|
37
|
+
"peerDependencies": {
|
|
38
|
+
"eslint": ">=9.0.0"
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@eslint/js": "^9.18.0",
|
|
42
|
+
"@stylistic/eslint-plugin": "^5.2.3",
|
|
43
|
+
"eslint-import-resolver-typescript": "^4.4.4",
|
|
44
|
+
"eslint-plugin-import": "^2.32.0",
|
|
45
|
+
"eslint-plugin-prettier": "^5.5.4",
|
|
46
|
+
"eslint-plugin-unused-imports": "^4.1.4",
|
|
47
|
+
"globals": "^15.0.0",
|
|
48
|
+
"typescript-eslint": "^8.40.0"
|
|
49
|
+
},
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"@types/node": "22.10.7",
|
|
52
|
+
"eslint": "9.39.2",
|
|
53
|
+
"tsup": "8.5.1",
|
|
54
|
+
"typescript": "5.9.3"
|
|
55
|
+
},
|
|
56
|
+
"engines": {
|
|
57
|
+
"node": ">=18.18.0"
|
|
58
|
+
}
|
|
59
|
+
}
|