@hansevision/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/README.md +107 -0
- package/dist/index.cjs +7 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +41 -0
- package/dist/index.js.map +1 -0
- package/package.json +39 -0
package/README.md
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
# @hansevision/eslint-config
|
|
2
|
+
|
|
3
|
+
A shareable, opinionated ESLint configuration for TypeScript projects.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install --save-dev @hansevision/eslint-config eslint typescript \
|
|
9
|
+
@typescript-eslint/eslint-plugin @typescript-eslint/parser \
|
|
10
|
+
eslint-plugin-sonarjs eslint-plugin-check-file
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
### ESLint v8 (`.eslintrc.js`)
|
|
16
|
+
|
|
17
|
+
```js
|
|
18
|
+
module.exports = {
|
|
19
|
+
extends: ["@hansevision/eslint-config"],
|
|
20
|
+
rules: {
|
|
21
|
+
// eigene Überschreibungen
|
|
22
|
+
"no-console": "warn",
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### Or ESLint in .eslintrc.json
|
|
28
|
+
|
|
29
|
+
{
|
|
30
|
+
"extends": ["@hansevision/eslint-config"]
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
### Or ESM import
|
|
34
|
+
|
|
35
|
+
```js
|
|
36
|
+
import base from "@hansevision/eslint-config";
|
|
37
|
+
|
|
38
|
+
export default {
|
|
39
|
+
...base,
|
|
40
|
+
// your project-specific overrides
|
|
41
|
+
};
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Available Configurations
|
|
45
|
+
|
|
46
|
+
| Export | Description |
|
|
47
|
+
| ------------------ | ----------------------------------------- |
|
|
48
|
+
| `default` / `base` | Recommended rules for TypeScript projects |
|
|
49
|
+
|
|
50
|
+
## Rules Overview
|
|
51
|
+
|
|
52
|
+
### Plugins
|
|
53
|
+
|
|
54
|
+
| Plugin | Purpose |
|
|
55
|
+
| -------------------- | --------------------------------------- |
|
|
56
|
+
| `@typescript-eslint` | TypeScript-aware lint rules |
|
|
57
|
+
| `sonarjs` | Code quality and smell detection |
|
|
58
|
+
| `check-file` | Enforce consistent file & folder naming |
|
|
59
|
+
|
|
60
|
+
### Base rules
|
|
61
|
+
|
|
62
|
+
| Rule | Severity | Notes |
|
|
63
|
+
| ------------------------------------------ | -------- | ------------------------------------------------- |
|
|
64
|
+
| `eslint:recommended` | — | ESLint built-in recommended rules |
|
|
65
|
+
| `plugin:@typescript-eslint/recommended` | — | typescript-eslint recommended rules |
|
|
66
|
+
| `plugin:sonarjs/recommended` | — | SonarJS recommended rules |
|
|
67
|
+
| `quotes` | error | Enforce double quotes |
|
|
68
|
+
| `no-var` | error | Disallow `var`, use `const`/`let` |
|
|
69
|
+
| `no-console` | error | Allow only `console.warn` and `console.error` |
|
|
70
|
+
| `no-debugger` | error | Disallow `debugger` statements |
|
|
71
|
+
| `eqeqeq` | error | Always require strict equality (`===`) |
|
|
72
|
+
| `curly` | error | Always require braces for control statements |
|
|
73
|
+
| `@typescript-eslint/no-explicit-any` | warn | Discourage use of `any` type |
|
|
74
|
+
| `@typescript-eslint/no-unused-vars` | error | Ignore variables/args prefixed with `_` |
|
|
75
|
+
| `@typescript-eslint/no-non-null-assertion` | warn | Discourage non-null assertions (`!`) |
|
|
76
|
+
| `sonarjs/no-duplicate-string` | error | Flag strings repeated ≥ 2 times |
|
|
77
|
+
| `sonarjs/max-lines` | error | Maximum 40 lines per file |
|
|
78
|
+
| `sonarjs/arrow-function-convention` | error | Require parentheses and braces in arrow functions |
|
|
79
|
+
| `check-file/folder-naming-convention` | error | `src/` subfolders must use camelCase |
|
|
80
|
+
|
|
81
|
+
## Development
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
# Install dependencies
|
|
85
|
+
npm install
|
|
86
|
+
|
|
87
|
+
# Build the package
|
|
88
|
+
npm run build
|
|
89
|
+
|
|
90
|
+
# Watch mode
|
|
91
|
+
npm run dev
|
|
92
|
+
|
|
93
|
+
# Lint the source
|
|
94
|
+
npm run lint
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Publishing
|
|
98
|
+
|
|
99
|
+
Update the package name in `package.json` (replace `@hansevision` with your npm scope or organization), then:
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
npm publish --access public
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## License
|
|
106
|
+
|
|
107
|
+
UNLICENSED — proprietary, all rights reserved.
|
package/dist/index.cjs
ADDED
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAErC,eAAO,MAAM,IAAI,EAAE,MAAM,CAAC,MAmCzB,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.base = void 0;
|
|
4
|
+
exports.base = {
|
|
5
|
+
parser: "@typescript-eslint/parser",
|
|
6
|
+
parserOptions: {
|
|
7
|
+
ecmaVersion: 2020,
|
|
8
|
+
sourceType: "module",
|
|
9
|
+
},
|
|
10
|
+
plugins: ["@typescript-eslint", "sonarjs"],
|
|
11
|
+
extends: [
|
|
12
|
+
"eslint:recommended",
|
|
13
|
+
"plugin:@typescript-eslint/recommended",
|
|
14
|
+
"plugin:sonarjs/recommended",
|
|
15
|
+
],
|
|
16
|
+
rules: {
|
|
17
|
+
"quotes": ["error", "double"],
|
|
18
|
+
"no-console": ["error", { "allow": ["warn", "error"] }],
|
|
19
|
+
"no-var": "error",
|
|
20
|
+
"@typescript-eslint/no-explicit-any": "warn",
|
|
21
|
+
"@typescript-eslint/no-unused-vars": [
|
|
22
|
+
"error",
|
|
23
|
+
{ "argsIgnorePattern": "^_", "varsIgnorePattern": "^_" },
|
|
24
|
+
],
|
|
25
|
+
"@typescript-eslint/no-non-null-assertion": "warn",
|
|
26
|
+
"no-debugger": "error",
|
|
27
|
+
"eqeqeq": ["error", "always"],
|
|
28
|
+
"curly": ["error", "all"],
|
|
29
|
+
"check-file/folder-naming-convention": [
|
|
30
|
+
"error",
|
|
31
|
+
{
|
|
32
|
+
"src/**/": "CAMEL_CASE"
|
|
33
|
+
}
|
|
34
|
+
],
|
|
35
|
+
"sonarjs/no-duplicate-string": ["error", { "threshold": 2 }],
|
|
36
|
+
"sonarjs/max-lines": ["error", { "maximum": 40 }],
|
|
37
|
+
"sonarjs/arrow-function-convention": ["error", { "requireParameterParentheses": true, "requireBodyBraces": true }]
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
exports.default = exports.base;
|
|
41
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAEa,QAAA,IAAI,GAAkB;IACjC,MAAM,EAAE,2BAA2B;IACnC,aAAa,EAAE;QACb,WAAW,EAAE,IAAI;QACjB,UAAU,EAAE,QAAQ;KACrB;IACD,OAAO,EAAE,CAAC,oBAAoB,EAAE,SAAS,CAAC;IAC1C,OAAO,EAAE;QACP,oBAAoB;QACpB,uCAAuC;QACvC,4BAA4B;KAC7B;IACD,KAAK,EAAE;QACL,QAAQ,EAAE,CAAC,OAAO,EAAE,QAAQ,CAAC;QAC7B,YAAY,EAAE,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;QACvD,QAAQ,EAAE,OAAO;QACjB,oCAAoC,EAAE,MAAM;QAC5C,mCAAmC,EAAE;YACnC,OAAO;YACP,EAAE,mBAAmB,EAAE,IAAI,EAAE,mBAAmB,EAAE,IAAI,EAAE;SACzD;QACD,0CAA0C,EAAE,MAAM;QAClD,aAAa,EAAE,OAAO;QACtB,QAAQ,EAAE,CAAC,OAAO,EAAE,QAAQ,CAAC;QAC7B,OAAO,EAAE,CAAC,OAAO,EAAE,KAAK,CAAC;QACzB,qCAAqC,EAAE;YACrC,OAAO;YACP;gBACE,SAAS,EAAE,YAAY;aACxB;SACF;QACD,6BAA6B,EAAE,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,CAAC,EAAE,CAAC;QAC5D,mBAAmB,EAAE,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC;QACjD,mCAAmC,EAAE,CAAC,OAAO,EAAE,EAAE,6BAA6B,EAAE,IAAI,EAAE,mBAAmB,EAAE,IAAI,EAAE,CAAC;KACnH;CACF,CAAC;AAEF,kBAAe,YAAI,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@hansevision/eslint-config",
|
|
3
|
+
"author": "HanseVision",
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"description": "Shareable ESLint configuration with TypeScript support",
|
|
6
|
+
"keywords": [],
|
|
7
|
+
"license": "UNLICENSED",
|
|
8
|
+
"type": "module",
|
|
9
|
+
"main": "./dist/index.cjs",
|
|
10
|
+
"module": "./dist/index.js",
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"import": "./dist/index.js",
|
|
15
|
+
"require": "./dist/index.cjs",
|
|
16
|
+
"types": "./dist/index.d.ts"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"dist"
|
|
21
|
+
],
|
|
22
|
+
"scripts": {
|
|
23
|
+
"build": "tsc --project tsconfig.build.json && node scripts/build-cjs.js",
|
|
24
|
+
"dev": "tsc --watch --project tsconfig.build.json",
|
|
25
|
+
"lint": "npm run build && eslint src --ext .ts",
|
|
26
|
+
"prepublishOnly": "npm run build"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@types/eslint": "^8.0.0",
|
|
30
|
+
"@typescript-eslint/eslint-plugin": "^5.62.0",
|
|
31
|
+
"@typescript-eslint/parser": "^5.62.0",
|
|
32
|
+
"eslint": "^8.57.1",
|
|
33
|
+
"eslint-plugin-sonarjs": "^4.0.2",
|
|
34
|
+
"typescript": "^3.9.10"
|
|
35
|
+
},
|
|
36
|
+
"volta": {
|
|
37
|
+
"node": "16.20.2"
|
|
38
|
+
}
|
|
39
|
+
}
|