eslint-config-axkit 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 +97 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.js +87 -0
- package/package.json +82 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Łukasz Jerciński
|
|
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,97 @@
|
|
|
1
|
+
# eslint-config-axkit
|
|
2
|
+
|
|
3
|
+
Reusable ESLint flat config for TypeScript + Node.js projects with strict type checking, Prettier, Unicorn, and Vitest.
|
|
4
|
+
|
|
5
|
+
## Quick Start
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# Install
|
|
9
|
+
npm install -D eslint eslint-config-axkit
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
Create an `eslint.config.js` in your project root:
|
|
13
|
+
|
|
14
|
+
```js
|
|
15
|
+
import path from "node:path";
|
|
16
|
+
import { axkit } from "eslint-config-axkit";
|
|
17
|
+
|
|
18
|
+
const gitignorePath = path.join(import.meta.dirname, ".gitignore");
|
|
19
|
+
|
|
20
|
+
export default axkit({ gitignorePath });
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
# Run
|
|
25
|
+
npx eslint .
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Installation
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
# npm
|
|
32
|
+
npm install -D eslint eslint-config-axkit
|
|
33
|
+
|
|
34
|
+
# pnpm
|
|
35
|
+
pnpm add -D eslint eslint-config-axkit
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Configuration
|
|
39
|
+
|
|
40
|
+
Create an `eslint.config.js` in your project root:
|
|
41
|
+
|
|
42
|
+
```js
|
|
43
|
+
import path from "node:path";
|
|
44
|
+
import { axkit } from "eslint-config-axkit";
|
|
45
|
+
|
|
46
|
+
const gitignorePath = path.join(import.meta.dirname, ".gitignore");
|
|
47
|
+
|
|
48
|
+
export default axkit({ gitignorePath });
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Or without gitignore integration:
|
|
52
|
+
|
|
53
|
+
```js
|
|
54
|
+
import { axkit } from "eslint-config-axkit";
|
|
55
|
+
|
|
56
|
+
export default axkit();
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## What's Included
|
|
60
|
+
|
|
61
|
+
For the current rule set and presets, see the source code in `src/`.
|
|
62
|
+
|
|
63
|
+
## Extending the Config
|
|
64
|
+
|
|
65
|
+
Add additional rules or override existing ones by spreading additional config objects:
|
|
66
|
+
|
|
67
|
+
```js
|
|
68
|
+
import path from "node:path";
|
|
69
|
+
import { axkit } from "eslint-config-axkit";
|
|
70
|
+
|
|
71
|
+
const gitignorePath = path.join(import.meta.dirname, ".gitignore");
|
|
72
|
+
|
|
73
|
+
export default [
|
|
74
|
+
...axkit({ gitignorePath }),
|
|
75
|
+
{
|
|
76
|
+
rules: {
|
|
77
|
+
// Your custom rules
|
|
78
|
+
"no-console": "warn",
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
];
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Options
|
|
85
|
+
|
|
86
|
+
| Option | Type | Description |
|
|
87
|
+
| --------------- | -------- | -------------------------------------------------------------------------- |
|
|
88
|
+
| `gitignorePath` | `string` | Path to `.gitignore` file. Patterns will be added to ESLint's ignore list. |
|
|
89
|
+
|
|
90
|
+
## Requirements
|
|
91
|
+
|
|
92
|
+
- Node.js >= 22.14.0
|
|
93
|
+
- ESLint >= 9
|
|
94
|
+
|
|
95
|
+
## License
|
|
96
|
+
|
|
97
|
+
MIT
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Linter } from "eslint";
|
|
2
|
+
export type Options = {
|
|
3
|
+
/**
|
|
4
|
+
* Path to .gitignore file. If provided, patterns from this file
|
|
5
|
+
* will be added to ESLint's ignore list.
|
|
6
|
+
*/
|
|
7
|
+
gitignorePath?: string;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Creates a complete ESLint flat config for TypeScript + Node.js projects.
|
|
11
|
+
*
|
|
12
|
+
* Includes:
|
|
13
|
+
* - ESLint recommended rules
|
|
14
|
+
* - TypeScript strict type checking
|
|
15
|
+
* - Unicorn plugin (recommended)
|
|
16
|
+
* - Vitest plugin for test files
|
|
17
|
+
* - Prettier compatibility (disables conflicting rules)
|
|
18
|
+
*/
|
|
19
|
+
export declare function axkit(options?: Options): Linter.Config[];
|
|
20
|
+
export default axkit;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import js from "@eslint/js";
|
|
2
|
+
import globals from "globals";
|
|
3
|
+
import tseslint from "typescript-eslint";
|
|
4
|
+
import { includeIgnoreFile } from "@eslint/compat";
|
|
5
|
+
import eslintConfigPrettier from "eslint-config-prettier/flat";
|
|
6
|
+
import vitest from "@vitest/eslint-plugin";
|
|
7
|
+
import eslintPluginUnicorn from "eslint-plugin-unicorn";
|
|
8
|
+
/**
|
|
9
|
+
* Creates a complete ESLint flat config for TypeScript + Node.js projects.
|
|
10
|
+
*
|
|
11
|
+
* Includes:
|
|
12
|
+
* - ESLint recommended rules
|
|
13
|
+
* - TypeScript strict type checking
|
|
14
|
+
* - Unicorn plugin (recommended)
|
|
15
|
+
* - Vitest plugin for test files
|
|
16
|
+
* - Prettier compatibility (disables conflicting rules)
|
|
17
|
+
*/
|
|
18
|
+
export function axkit(options = {}) {
|
|
19
|
+
const { gitignorePath } = options;
|
|
20
|
+
const configs = [];
|
|
21
|
+
if (gitignorePath) {
|
|
22
|
+
configs.push(includeIgnoreFile(gitignorePath, "Copy patterns from .gitignore"));
|
|
23
|
+
}
|
|
24
|
+
configs.push(
|
|
25
|
+
// ESLint recommended
|
|
26
|
+
js.configs.recommended,
|
|
27
|
+
// TypeScript strict type checking
|
|
28
|
+
...tseslint.configs.strictTypeChecked,
|
|
29
|
+
// Base config for all JS/TS files
|
|
30
|
+
{
|
|
31
|
+
name: "axkit/base",
|
|
32
|
+
files: ["**/*.{js,mjs,cjs,ts,tsx,mts,cts}"],
|
|
33
|
+
languageOptions: {
|
|
34
|
+
globals: globals.node,
|
|
35
|
+
parserOptions: {
|
|
36
|
+
projectService: true,
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
rules: {
|
|
40
|
+
// Security rules
|
|
41
|
+
"no-eval": "error",
|
|
42
|
+
"no-new-func": "error",
|
|
43
|
+
"no-script-url": "error",
|
|
44
|
+
// Correctness rules
|
|
45
|
+
"no-return-assign": ["error", "always"],
|
|
46
|
+
radix: ["error", "as-needed"],
|
|
47
|
+
"guard-for-in": "error",
|
|
48
|
+
"prefer-object-has-own": "error",
|
|
49
|
+
// Clarity rules
|
|
50
|
+
"prefer-regex-literals": ["error", { disallowRedundantWrapping: true }],
|
|
51
|
+
"require-unicode-regexp": "error",
|
|
52
|
+
"no-extend-native": "error",
|
|
53
|
+
"no-new-wrappers": "error",
|
|
54
|
+
"no-implicit-coercion": ["error", { allow: ["!!"] }],
|
|
55
|
+
// Allow numbers in template literals (safe and common)
|
|
56
|
+
"@typescript-eslint/restrict-template-expressions": [
|
|
57
|
+
"error",
|
|
58
|
+
{ allowNumber: true },
|
|
59
|
+
],
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
// Unicorn plugin recommended config
|
|
63
|
+
eslintPluginUnicorn.configs.recommended,
|
|
64
|
+
// Disable type-checking for config files
|
|
65
|
+
{
|
|
66
|
+
name: "axkit/config-files",
|
|
67
|
+
files: ["*.config.{js,ts,mjs,mts}"],
|
|
68
|
+
...tseslint.configs.disableTypeChecked,
|
|
69
|
+
},
|
|
70
|
+
// Vitest rules for test files
|
|
71
|
+
{
|
|
72
|
+
name: "axkit/vitest",
|
|
73
|
+
files: [
|
|
74
|
+
"**/*.{test,spec}.{ts,tsx,js,mjs,cjs,mts,cts}",
|
|
75
|
+
"tests/**/*.{ts,tsx,js,mjs,cjs,mts,cts}",
|
|
76
|
+
],
|
|
77
|
+
plugins: { vitest },
|
|
78
|
+
rules: vitest.configs.recommended.rules,
|
|
79
|
+
languageOptions: {
|
|
80
|
+
globals: { ...vitest.environments.env.globals },
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
// Prettier compatibility (must be last)
|
|
84
|
+
eslintConfigPrettier);
|
|
85
|
+
return configs;
|
|
86
|
+
}
|
|
87
|
+
export default axkit;
|
package/package.json
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "eslint-config-axkit",
|
|
3
|
+
"author": "Łukasz Jerciński",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"version": "1.0.0",
|
|
6
|
+
"description": "Reusable ESLint flat config for TypeScript + Node.js projects with strict type checking, Prettier, Unicorn, and Vitest",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/Jercik/eslint-config-axkit.git"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://github.com/Jercik/eslint-config-axkit#readme",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/Jercik/eslint-config-axkit/issues"
|
|
14
|
+
},
|
|
15
|
+
"type": "module",
|
|
16
|
+
"main": "./dist/index.js",
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
21
|
+
"import": "./dist/index.js"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"dist/",
|
|
26
|
+
"README.md",
|
|
27
|
+
"LICENSE"
|
|
28
|
+
],
|
|
29
|
+
"keywords": [
|
|
30
|
+
"eslint",
|
|
31
|
+
"eslintconfig",
|
|
32
|
+
"eslint-config",
|
|
33
|
+
"flat-config",
|
|
34
|
+
"typescript",
|
|
35
|
+
"prettier",
|
|
36
|
+
"unicorn",
|
|
37
|
+
"vitest",
|
|
38
|
+
"axkit"
|
|
39
|
+
],
|
|
40
|
+
"engines": {
|
|
41
|
+
"node": ">=22.14.0"
|
|
42
|
+
},
|
|
43
|
+
"peerDependencies": {
|
|
44
|
+
"eslint": ">=9"
|
|
45
|
+
},
|
|
46
|
+
"dependencies": {
|
|
47
|
+
"@eslint/compat": "^2.0.0",
|
|
48
|
+
"@eslint/js": "^9.39.2",
|
|
49
|
+
"@vitest/eslint-plugin": "^1.6.5",
|
|
50
|
+
"eslint-config-prettier": "^10.1.8",
|
|
51
|
+
"eslint-plugin-unicorn": "^62.0.0",
|
|
52
|
+
"globals": "^17.0.0",
|
|
53
|
+
"typescript-eslint": "^8.52.0"
|
|
54
|
+
},
|
|
55
|
+
"devDependencies": {
|
|
56
|
+
"@total-typescript/ts-reset": "^0.6.1",
|
|
57
|
+
"@types/node": "^25.0.3",
|
|
58
|
+
"@vitest/coverage-v8": "^4.0.16",
|
|
59
|
+
"eslint": "^9.39.2",
|
|
60
|
+
"fta-check": "^1.5.1",
|
|
61
|
+
"fta-cli": "^3.0.0",
|
|
62
|
+
"knip": "^5.80.0",
|
|
63
|
+
"prettier": "3.7.4",
|
|
64
|
+
"semantic-release": "^25.0.2",
|
|
65
|
+
"typescript": "^5.9.3",
|
|
66
|
+
"vitest": "^4.0.16"
|
|
67
|
+
},
|
|
68
|
+
"scripts": {
|
|
69
|
+
"build": "tsc -p tsconfig.app.json",
|
|
70
|
+
"clean": "rm -rf dist *.tsbuildinfo",
|
|
71
|
+
"format": "prettier --write .",
|
|
72
|
+
"format:check": "prettier --check .",
|
|
73
|
+
"fta": "fta-check",
|
|
74
|
+
"knip": "knip",
|
|
75
|
+
"lint": "eslint",
|
|
76
|
+
"rebuild": "pnpm run clean && pnpm run build",
|
|
77
|
+
"test": "vitest run",
|
|
78
|
+
"test:coverage": "vitest run --coverage",
|
|
79
|
+
"test:watch": "vitest",
|
|
80
|
+
"typecheck": "tsc -b --noEmit"
|
|
81
|
+
}
|
|
82
|
+
}
|