@tucchi-/eslint-config 1.0.0
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 +21 -0
- package/README.md +81 -0
- package/index.js +59 -0
- package/package.json +37 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 tucch1
|
|
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.
|
package/README.md
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# @tucchi-/eslint-config
|
|
2
|
+
|
|
3
|
+
Modern ESLint config with strict TypeScript and unicorn rules.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **typescript-eslint strict + stylistic** - Strict type checking
|
|
8
|
+
- **eslint-plugin-unicorn** - Modern JavaScript best practices
|
|
9
|
+
- **Complexity rules** - Prevent deeply nested code
|
|
10
|
+
|
|
11
|
+
### Included Rules
|
|
12
|
+
|
|
13
|
+
| Category | Rules |
|
|
14
|
+
|----------|-------|
|
|
15
|
+
| TypeScript | `strict`, `stylistic`, no `any`, no `!`, `type` only, arrow functions only |
|
|
16
|
+
| Unicorn | Full `recommended` preset |
|
|
17
|
+
| Complexity | `max-depth: 1`, `max-nested-callbacks: 1`, `complexity: 5` |
|
|
18
|
+
|
|
19
|
+
## Install
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npm install -D @tucchi-/eslint-config eslint typescript
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
Create `eslint.config.js`:
|
|
28
|
+
|
|
29
|
+
```js
|
|
30
|
+
import config from "@tucchi-/eslint-config";
|
|
31
|
+
|
|
32
|
+
export default config();
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### With Options
|
|
36
|
+
|
|
37
|
+
```js
|
|
38
|
+
import config from "@tucchi-/eslint-config";
|
|
39
|
+
|
|
40
|
+
export default config({
|
|
41
|
+
files: ["src/**/*.ts"],
|
|
42
|
+
ignores: ["dist/", "coverage/"],
|
|
43
|
+
maxDepth: 2, // Allow one level of nesting if needed
|
|
44
|
+
rules: {
|
|
45
|
+
"unicorn/no-null": "off", // Override specific rules
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### With Bun
|
|
51
|
+
|
|
52
|
+
Add `Bun` global:
|
|
53
|
+
|
|
54
|
+
```js
|
|
55
|
+
import config from "@tucchi-/eslint-config";
|
|
56
|
+
|
|
57
|
+
export default [
|
|
58
|
+
...config(),
|
|
59
|
+
{
|
|
60
|
+
languageOptions: {
|
|
61
|
+
globals: { Bun: "readonly" },
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
];
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## What's Enforced
|
|
68
|
+
|
|
69
|
+
- `null` → `undefined`
|
|
70
|
+
- Full variable names (`msg` → `message`, `cb` → `callback`)
|
|
71
|
+
- `node:` protocol for Node.js imports
|
|
72
|
+
- Top-level await preferred
|
|
73
|
+
- No nesting allowed (early return pattern enforced)
|
|
74
|
+
- No `any` type
|
|
75
|
+
- No non-null assertions (`!`)
|
|
76
|
+
- `type` only (no `interface`)
|
|
77
|
+
- Arrow functions only (no `function`)
|
|
78
|
+
|
|
79
|
+
## License
|
|
80
|
+
|
|
81
|
+
MIT
|
package/index.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import eslint from "@eslint/js";
|
|
2
|
+
import tseslint from "typescript-eslint";
|
|
3
|
+
import unicorn from "eslint-plugin-unicorn";
|
|
4
|
+
import globals from "globals";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Modern ESLint config with strict TypeScript and unicorn rules
|
|
8
|
+
* @param {Object} options
|
|
9
|
+
* @param {string[]} [options.files] - File patterns to lint (default: ["src/**/*.ts"])
|
|
10
|
+
* @param {string[]} [options.ignores] - Patterns to ignore
|
|
11
|
+
* @param {number} [options.maxDepth] - Maximum nesting depth (default: 1, no nesting allowed)
|
|
12
|
+
* @param {Object} [options.rules] - Additional rules to override
|
|
13
|
+
*/
|
|
14
|
+
export default function modernConfig(options = {}) {
|
|
15
|
+
const {
|
|
16
|
+
files = ["src/**/*.ts", "**/*.ts"],
|
|
17
|
+
ignores = ["node_modules/", "dist/"],
|
|
18
|
+
maxDepth = 1,
|
|
19
|
+
rules = {},
|
|
20
|
+
} = options;
|
|
21
|
+
|
|
22
|
+
return tseslint.config(
|
|
23
|
+
eslint.configs.recommended,
|
|
24
|
+
...tseslint.configs.strict,
|
|
25
|
+
...tseslint.configs.stylistic,
|
|
26
|
+
unicorn.configs.recommended,
|
|
27
|
+
{
|
|
28
|
+
files,
|
|
29
|
+
languageOptions: {
|
|
30
|
+
globals: {
|
|
31
|
+
...globals.node,
|
|
32
|
+
...globals.browser,
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
rules: {
|
|
36
|
+
// TypeScript
|
|
37
|
+
"@typescript-eslint/no-unused-vars": ["error", { argsIgnorePattern: "^_" }],
|
|
38
|
+
"@typescript-eslint/consistent-type-definitions": ["error", "type"], // type > interface
|
|
39
|
+
|
|
40
|
+
// Function style
|
|
41
|
+
"func-style": ["error", "expression"], // arrow function > function
|
|
42
|
+
|
|
43
|
+
// Complexity
|
|
44
|
+
"max-depth": ["error", maxDepth],
|
|
45
|
+
"max-nested-callbacks": ["error", 1],
|
|
46
|
+
complexity: ["error", 5],
|
|
47
|
+
|
|
48
|
+
// User overrides
|
|
49
|
+
...rules,
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
ignores,
|
|
54
|
+
}
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Named exports for granular usage
|
|
59
|
+
export { eslint, tseslint, unicorn, globals };
|
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@tucchi-/eslint-config",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Modern ESLint config with TypeScript strict, unicorn, and complexity rules",
|
|
5
|
+
"author": "tucchi-",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"main": "index.js",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": "./index.js"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"index.js"
|
|
14
|
+
],
|
|
15
|
+
"keywords": [
|
|
16
|
+
"eslint",
|
|
17
|
+
"eslint-config",
|
|
18
|
+
"typescript",
|
|
19
|
+
"unicorn",
|
|
20
|
+
"modern",
|
|
21
|
+
"strict"
|
|
22
|
+
],
|
|
23
|
+
"repository": {
|
|
24
|
+
"type": "git",
|
|
25
|
+
"url": "https://github.com/tucchi-/eslint-config"
|
|
26
|
+
},
|
|
27
|
+
"peerDependencies": {
|
|
28
|
+
"eslint": "^9.0.0",
|
|
29
|
+
"typescript": "^5.0.0"
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@eslint/js": "^9.39.2",
|
|
33
|
+
"eslint-plugin-unicorn": "^62.0.0",
|
|
34
|
+
"globals": "^17.2.0",
|
|
35
|
+
"typescript-eslint": "^8.54.0"
|
|
36
|
+
}
|
|
37
|
+
}
|