@klymchuk/v2-eslint 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 +89 -0
- package/dist/cjs/configs/backend.d.ts +4 -0
- package/dist/cjs/configs/backend.d.ts.map +1 -0
- package/dist/cjs/configs/backend.js +16 -0
- package/dist/cjs/configs/base.d.ts +4 -0
- package/dist/cjs/configs/base.d.ts.map +1 -0
- package/dist/cjs/configs/base.js +144 -0
- package/dist/cjs/configs/frontend.d.ts +4 -0
- package/dist/cjs/configs/frontend.d.ts.map +1 -0
- package/dist/cjs/configs/frontend.js +51 -0
- package/dist/cjs/index.d.ts +4 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +39 -0
- package/dist/cjs/package.json +1 -0
- package/dist/esm/configs/backend.d.ts +4 -0
- package/dist/esm/configs/backend.d.ts.map +1 -0
- package/dist/esm/configs/backend.js +11 -0
- package/dist/esm/configs/base.d.ts +4 -0
- package/dist/esm/configs/base.d.ts.map +1 -0
- package/dist/esm/configs/base.js +139 -0
- package/dist/esm/configs/frontend.d.ts +4 -0
- package/dist/esm/configs/frontend.d.ts.map +1 -0
- package/dist/esm/configs/frontend.js +46 -0
- package/dist/esm/index.d.ts +4 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +3 -0
- package/package.json +54 -0
package/README.md
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# @klymchuk-v2/eslint
|
|
2
|
+
|
|
3
|
+
Shared ESLint configurations for klymchuk-brand-v2 projects.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install --save-dev @klymchuk-v2/eslint
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
You'll also need to install the required peer dependencies:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install --save-dev \
|
|
15
|
+
eslint \
|
|
16
|
+
typescript-eslint \
|
|
17
|
+
@eslint/js \
|
|
18
|
+
eslint-plugin-react \
|
|
19
|
+
eslint-plugin-react-hooks \
|
|
20
|
+
@next/eslint-plugin-next \
|
|
21
|
+
eslint-config-next
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Usage
|
|
25
|
+
|
|
26
|
+
In your `eslint.config.js`:
|
|
27
|
+
|
|
28
|
+
### For Backend Projects
|
|
29
|
+
|
|
30
|
+
```javascript
|
|
31
|
+
import { base, backend } from '@klymchuk-v2/eslint';
|
|
32
|
+
|
|
33
|
+
export default [
|
|
34
|
+
...base,
|
|
35
|
+
...backend,
|
|
36
|
+
];
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### For Frontend Projects (React/Next.js)
|
|
40
|
+
|
|
41
|
+
```javascript
|
|
42
|
+
import { base, frontend } from '@klymchuk-v2/eslint';
|
|
43
|
+
|
|
44
|
+
export default [
|
|
45
|
+
...base,
|
|
46
|
+
...frontend,
|
|
47
|
+
];
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### For Full-Stack Projects
|
|
51
|
+
|
|
52
|
+
```javascript
|
|
53
|
+
import { base, frontend, backend } from '@klymchuk-v2/eslint';
|
|
54
|
+
|
|
55
|
+
export default [
|
|
56
|
+
...base,
|
|
57
|
+
...frontend,
|
|
58
|
+
...backend,
|
|
59
|
+
];
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Configurations
|
|
63
|
+
|
|
64
|
+
### Base Config
|
|
65
|
+
Core ESLint + TypeScript rules for all projects:
|
|
66
|
+
- TypeScript parser and plugin
|
|
67
|
+
- Code quality rules (no-console, eqeqeq, prefer-const)
|
|
68
|
+
- Formatting rules (semicolons, quotes, indentation, spacing)
|
|
69
|
+
- Max line length: 120 characters
|
|
70
|
+
- Brace style: One True Brace Style (1tbs)
|
|
71
|
+
- File extensions: `*.{js,jsx,ts,tsx}`
|
|
72
|
+
|
|
73
|
+
### Frontend Config
|
|
74
|
+
React and Next.js specific rules:
|
|
75
|
+
- React plugin and hooks rules
|
|
76
|
+
- Next.js plugin integration
|
|
77
|
+
- JSX formatting rules
|
|
78
|
+
- React globals (document, window)
|
|
79
|
+
- File extensions: `*.{js,jsx,ts,tsx}`
|
|
80
|
+
|
|
81
|
+
### Backend Config
|
|
82
|
+
Backend-specific configurations:
|
|
83
|
+
- Minimal backend-specific rules
|
|
84
|
+
- Extends base configuration
|
|
85
|
+
- File extensions: `*.{js,ts}`
|
|
86
|
+
|
|
87
|
+
## License
|
|
88
|
+
|
|
89
|
+
ISC
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"backend.d.ts","sourceRoot":"","sources":["../../../src/configs/backend.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGrC,QAAA,MAAM,MAAM,EAAE,MAAM,CAAC,MAAM,EAQ1B,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const base_js_1 = __importDefault(require("./base.js"));
|
|
7
|
+
const config = [
|
|
8
|
+
...base_js_1.default,
|
|
9
|
+
{
|
|
10
|
+
files: ['**/*.{js,ts}'],
|
|
11
|
+
rules: {
|
|
12
|
+
'@typescript-eslint/explicit-module-boundary-types': 'off',
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
];
|
|
16
|
+
exports.default = config;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../src/configs/base.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAErC,QAAA,MAAM,MAAM,EAAE,MAAM,CAAC,MAAM,EAiJ1B,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const js_1 = __importDefault(require("@eslint/js"));
|
|
7
|
+
const typescript_eslint_1 = __importDefault(require("typescript-eslint"));
|
|
8
|
+
const config = [
|
|
9
|
+
{
|
|
10
|
+
ignores: [
|
|
11
|
+
'node_modules',
|
|
12
|
+
'dist',
|
|
13
|
+
'.idea',
|
|
14
|
+
'.next',
|
|
15
|
+
'.nuxt',
|
|
16
|
+
'out',
|
|
17
|
+
'build',
|
|
18
|
+
'coverage',
|
|
19
|
+
],
|
|
20
|
+
},
|
|
21
|
+
js_1.default.configs.recommended,
|
|
22
|
+
...typescript_eslint_1.default.configs.recommended,
|
|
23
|
+
{
|
|
24
|
+
files: ['**/*.{js,jsx,ts,tsx}'],
|
|
25
|
+
languageOptions: {
|
|
26
|
+
parser: typescript_eslint_1.default.parser,
|
|
27
|
+
parserOptions: {
|
|
28
|
+
ecmaVersion: 'latest',
|
|
29
|
+
sourceType: 'module',
|
|
30
|
+
ecmaFeatures: {
|
|
31
|
+
jsx: true,
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
globals: {
|
|
35
|
+
console: 'readonly',
|
|
36
|
+
process: 'readonly',
|
|
37
|
+
setTimeout: 'readonly',
|
|
38
|
+
setInterval: 'readonly',
|
|
39
|
+
clearTimeout: 'readonly',
|
|
40
|
+
clearInterval: 'readonly',
|
|
41
|
+
Promise: 'readonly',
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
rules: {
|
|
45
|
+
// ========== Code quality ==========
|
|
46
|
+
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
|
|
47
|
+
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
|
|
48
|
+
'no-unused-vars': 'off', // handled by @typescript-eslint/no-unused-vars
|
|
49
|
+
'prefer-const': 'warn',
|
|
50
|
+
'no-var': 'warn',
|
|
51
|
+
'eqeqeq': ['warn', 'always'], // always use === / !==
|
|
52
|
+
// ========== Block / braces structure ==========
|
|
53
|
+
// Always use curly braces for blocks (if/else/for/while/etc)
|
|
54
|
+
// 'curly': ['error', 'all'],
|
|
55
|
+
// One True Brace Style:
|
|
56
|
+
// if (condition) {
|
|
57
|
+
// ...
|
|
58
|
+
// } else {
|
|
59
|
+
// ...
|
|
60
|
+
// }
|
|
61
|
+
'brace-style': ['warn', '1tbs', { allowSingleLine: false }],
|
|
62
|
+
// ========== Formatting (Prettier replacement) ==========
|
|
63
|
+
'semi': ['warn', 'always'], // require semicolon at end of line
|
|
64
|
+
'quotes': ['warn', 'single', { avoidEscape: true }], // single quotes
|
|
65
|
+
'comma-dangle': ['error', 'always-multiline'], // trailing comma in multiline objects/arrays
|
|
66
|
+
'indent': ['warn', 2], // 2 spaces indentation
|
|
67
|
+
'no-multiple-empty-lines': ['warn', {
|
|
68
|
+
max: 2,
|
|
69
|
+
maxBOF: 0,
|
|
70
|
+
maxEOF: 0,
|
|
71
|
+
}],
|
|
72
|
+
'eol-last': ['warn', 'always'], // newline at end of file
|
|
73
|
+
'no-trailing-spaces': 'warn',
|
|
74
|
+
'object-curly-newline': ['error', {
|
|
75
|
+
ObjectExpression: { minProperties: 4, multiline: true, consistent: true },
|
|
76
|
+
ObjectPattern: { minProperties: 4, multiline: true, consistent: true },
|
|
77
|
+
ImportDeclaration: { minProperties: 4, multiline: true, consistent: true },
|
|
78
|
+
ExportDeclaration: { minProperties: 4, multiline: true, consistent: true },
|
|
79
|
+
}],
|
|
80
|
+
// enforce "same line" or "multiple line" on object properties.
|
|
81
|
+
// https://eslint.org/docs/rules/object-property-newline
|
|
82
|
+
'object-property-newline': ['error', {
|
|
83
|
+
allowAllPropertiesOnSameLine: true,
|
|
84
|
+
}],
|
|
85
|
+
// 'object-curly-newline': [
|
|
86
|
+
// 'error',
|
|
87
|
+
// {
|
|
88
|
+
// ObjectPattern: {
|
|
89
|
+
// multiline: true,
|
|
90
|
+
// consistent: true,
|
|
91
|
+
// },
|
|
92
|
+
// ObjectExpression: {
|
|
93
|
+
// multiline: true,
|
|
94
|
+
// consistent: true,
|
|
95
|
+
// },
|
|
96
|
+
// ImportDeclaration: {
|
|
97
|
+
// multiline: true,
|
|
98
|
+
// consistent: true,
|
|
99
|
+
// },
|
|
100
|
+
// ExportDeclaration: {
|
|
101
|
+
// multiline: true,
|
|
102
|
+
// consistent: true,
|
|
103
|
+
// },
|
|
104
|
+
// },
|
|
105
|
+
// ],
|
|
106
|
+
// 'object-property-newline': [
|
|
107
|
+
// 'error',
|
|
108
|
+
// {
|
|
109
|
+
// // allow single-line objects/destructuring,
|
|
110
|
+
// // but if it's multiline – each property must be on its own line
|
|
111
|
+
// allowAllPropertiesOnSameLine: true,
|
|
112
|
+
// },
|
|
113
|
+
// ],
|
|
114
|
+
'object-curly-spacing': ['warn', 'always'], // { a: 1 } instead of {a:1}
|
|
115
|
+
'array-bracket-spacing': ['warn', 'never'], // [1, 2] instead of [ 1, 2 ]
|
|
116
|
+
'arrow-spacing': 'warn', // space around arrow functions
|
|
117
|
+
'keyword-spacing': 'warn', // space around keywords (if, for, etc)
|
|
118
|
+
'space-before-blocks': 'warn',
|
|
119
|
+
'space-before-function-paren': ['warn', {
|
|
120
|
+
anonymous: 'always',
|
|
121
|
+
named: 'never',
|
|
122
|
+
asyncArrow: 'always',
|
|
123
|
+
}],
|
|
124
|
+
'space-infix-ops': 'warn', // spaces around operators: a + b, a === b
|
|
125
|
+
'max-len': ['warn', {
|
|
126
|
+
code: 120,
|
|
127
|
+
ignorePattern: '^import |^export |// ',
|
|
128
|
+
ignoreUrls: true,
|
|
129
|
+
}], // max 120 chars per line
|
|
130
|
+
// Slight structure: empty line before return for readability
|
|
131
|
+
'newline-before-return': 'warn',
|
|
132
|
+
// ========== TypeScript ==========
|
|
133
|
+
'@typescript-eslint/no-unused-vars': [
|
|
134
|
+
'warn',
|
|
135
|
+
{ argsIgnorePattern: '^_' },
|
|
136
|
+
],
|
|
137
|
+
'@typescript-eslint/explicit-function-return-types': 'off',
|
|
138
|
+
'@typescript-eslint/no-explicit-any': 'warn',
|
|
139
|
+
'@typescript-eslint/ban-ts-comment': 'warn',
|
|
140
|
+
'@typescript-eslint/no-unused-expressions': 'off',
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
];
|
|
144
|
+
exports.default = config;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frontend.d.ts","sourceRoot":"","sources":["../../../src/configs/frontend.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAMrC,QAAA,MAAM,MAAM,EAAE,MAAM,CAAC,MAAM,EAwC1B,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const base_js_1 = __importDefault(require("./base.js"));
|
|
7
|
+
const eslint_plugin_react_1 = __importDefault(require("eslint-plugin-react"));
|
|
8
|
+
const eslint_plugin_react_hooks_1 = __importDefault(require("eslint-plugin-react-hooks"));
|
|
9
|
+
const eslint_plugin_next_1 = __importDefault(require("@next/eslint-plugin-next"));
|
|
10
|
+
const config = [
|
|
11
|
+
...base_js_1.default,
|
|
12
|
+
{
|
|
13
|
+
files: ['**/*.{js,jsx,ts,tsx}'],
|
|
14
|
+
plugins: {
|
|
15
|
+
react: eslint_plugin_react_1.default,
|
|
16
|
+
'react-hooks': eslint_plugin_react_hooks_1.default,
|
|
17
|
+
'@next/next': eslint_plugin_next_1.default,
|
|
18
|
+
},
|
|
19
|
+
rules: {
|
|
20
|
+
...eslint_plugin_react_1.default.configs.flat.recommended.rules,
|
|
21
|
+
...eslint_plugin_react_hooks_1.default.configs.recommended.rules,
|
|
22
|
+
...eslint_plugin_next_1.default.configs.recommended.rules,
|
|
23
|
+
'react/react-in-jsx-scope': 'off',
|
|
24
|
+
'react/prop-types': 'warn',
|
|
25
|
+
'react/jsx-uses-react': 'off',
|
|
26
|
+
'react-hooks/rules-of-hooks': 'error',
|
|
27
|
+
'react-hooks/exhaustive-deps': 'warn',
|
|
28
|
+
'@next/next/no-html-link-for-pages': 'off',
|
|
29
|
+
'react/jsx-max-props-per-line': [
|
|
30
|
+
'error',
|
|
31
|
+
{ 'maximum': 1, 'when': 'multiline' },
|
|
32
|
+
],
|
|
33
|
+
'react/jsx-first-prop-new-line': [
|
|
34
|
+
'error',
|
|
35
|
+
'multiline',
|
|
36
|
+
],
|
|
37
|
+
},
|
|
38
|
+
settings: {
|
|
39
|
+
react: {
|
|
40
|
+
version: 'detect',
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
languageOptions: {
|
|
44
|
+
globals: {
|
|
45
|
+
document: 'readonly',
|
|
46
|
+
window: 'readonly',
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
];
|
|
51
|
+
exports.default = config;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAA;AACtC,OAAO,KAAK,OAAO,MAAM,mBAAmB,CAAA;AAC5C,OAAO,KAAK,QAAQ,MAAM,oBAAoB,CAAA"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.frontend = exports.backend = exports.base = void 0;
|
|
37
|
+
exports.base = __importStar(require("./configs/base"));
|
|
38
|
+
exports.backend = __importStar(require("./configs/backend"));
|
|
39
|
+
exports.frontend = __importStar(require("./configs/frontend"));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"commonjs"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"backend.d.ts","sourceRoot":"","sources":["../../../src/configs/backend.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGrC,QAAA,MAAM,MAAM,EAAE,MAAM,CAAC,MAAM,EAQ1B,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../src/configs/base.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAErC,QAAA,MAAM,MAAM,EAAE,MAAM,CAAC,MAAM,EAiJ1B,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import js from '@eslint/js';
|
|
2
|
+
import tseslint from 'typescript-eslint';
|
|
3
|
+
const config = [
|
|
4
|
+
{
|
|
5
|
+
ignores: [
|
|
6
|
+
'node_modules',
|
|
7
|
+
'dist',
|
|
8
|
+
'.idea',
|
|
9
|
+
'.next',
|
|
10
|
+
'.nuxt',
|
|
11
|
+
'out',
|
|
12
|
+
'build',
|
|
13
|
+
'coverage',
|
|
14
|
+
],
|
|
15
|
+
},
|
|
16
|
+
js.configs.recommended,
|
|
17
|
+
...tseslint.configs.recommended,
|
|
18
|
+
{
|
|
19
|
+
files: ['**/*.{js,jsx,ts,tsx}'],
|
|
20
|
+
languageOptions: {
|
|
21
|
+
parser: tseslint.parser,
|
|
22
|
+
parserOptions: {
|
|
23
|
+
ecmaVersion: 'latest',
|
|
24
|
+
sourceType: 'module',
|
|
25
|
+
ecmaFeatures: {
|
|
26
|
+
jsx: true,
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
globals: {
|
|
30
|
+
console: 'readonly',
|
|
31
|
+
process: 'readonly',
|
|
32
|
+
setTimeout: 'readonly',
|
|
33
|
+
setInterval: 'readonly',
|
|
34
|
+
clearTimeout: 'readonly',
|
|
35
|
+
clearInterval: 'readonly',
|
|
36
|
+
Promise: 'readonly',
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
rules: {
|
|
40
|
+
// ========== Code quality ==========
|
|
41
|
+
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
|
|
42
|
+
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
|
|
43
|
+
'no-unused-vars': 'off', // handled by @typescript-eslint/no-unused-vars
|
|
44
|
+
'prefer-const': 'warn',
|
|
45
|
+
'no-var': 'warn',
|
|
46
|
+
'eqeqeq': ['warn', 'always'], // always use === / !==
|
|
47
|
+
// ========== Block / braces structure ==========
|
|
48
|
+
// Always use curly braces for blocks (if/else/for/while/etc)
|
|
49
|
+
// 'curly': ['error', 'all'],
|
|
50
|
+
// One True Brace Style:
|
|
51
|
+
// if (condition) {
|
|
52
|
+
// ...
|
|
53
|
+
// } else {
|
|
54
|
+
// ...
|
|
55
|
+
// }
|
|
56
|
+
'brace-style': ['warn', '1tbs', { allowSingleLine: false }],
|
|
57
|
+
// ========== Formatting (Prettier replacement) ==========
|
|
58
|
+
'semi': ['warn', 'always'], // require semicolon at end of line
|
|
59
|
+
'quotes': ['warn', 'single', { avoidEscape: true }], // single quotes
|
|
60
|
+
'comma-dangle': ['error', 'always-multiline'], // trailing comma in multiline objects/arrays
|
|
61
|
+
'indent': ['warn', 2], // 2 spaces indentation
|
|
62
|
+
'no-multiple-empty-lines': ['warn', {
|
|
63
|
+
max: 2,
|
|
64
|
+
maxBOF: 0,
|
|
65
|
+
maxEOF: 0,
|
|
66
|
+
}],
|
|
67
|
+
'eol-last': ['warn', 'always'], // newline at end of file
|
|
68
|
+
'no-trailing-spaces': 'warn',
|
|
69
|
+
'object-curly-newline': ['error', {
|
|
70
|
+
ObjectExpression: { minProperties: 4, multiline: true, consistent: true },
|
|
71
|
+
ObjectPattern: { minProperties: 4, multiline: true, consistent: true },
|
|
72
|
+
ImportDeclaration: { minProperties: 4, multiline: true, consistent: true },
|
|
73
|
+
ExportDeclaration: { minProperties: 4, multiline: true, consistent: true },
|
|
74
|
+
}],
|
|
75
|
+
// enforce "same line" or "multiple line" on object properties.
|
|
76
|
+
// https://eslint.org/docs/rules/object-property-newline
|
|
77
|
+
'object-property-newline': ['error', {
|
|
78
|
+
allowAllPropertiesOnSameLine: true,
|
|
79
|
+
}],
|
|
80
|
+
// 'object-curly-newline': [
|
|
81
|
+
// 'error',
|
|
82
|
+
// {
|
|
83
|
+
// ObjectPattern: {
|
|
84
|
+
// multiline: true,
|
|
85
|
+
// consistent: true,
|
|
86
|
+
// },
|
|
87
|
+
// ObjectExpression: {
|
|
88
|
+
// multiline: true,
|
|
89
|
+
// consistent: true,
|
|
90
|
+
// },
|
|
91
|
+
// ImportDeclaration: {
|
|
92
|
+
// multiline: true,
|
|
93
|
+
// consistent: true,
|
|
94
|
+
// },
|
|
95
|
+
// ExportDeclaration: {
|
|
96
|
+
// multiline: true,
|
|
97
|
+
// consistent: true,
|
|
98
|
+
// },
|
|
99
|
+
// },
|
|
100
|
+
// ],
|
|
101
|
+
// 'object-property-newline': [
|
|
102
|
+
// 'error',
|
|
103
|
+
// {
|
|
104
|
+
// // allow single-line objects/destructuring,
|
|
105
|
+
// // but if it's multiline – each property must be on its own line
|
|
106
|
+
// allowAllPropertiesOnSameLine: true,
|
|
107
|
+
// },
|
|
108
|
+
// ],
|
|
109
|
+
'object-curly-spacing': ['warn', 'always'], // { a: 1 } instead of {a:1}
|
|
110
|
+
'array-bracket-spacing': ['warn', 'never'], // [1, 2] instead of [ 1, 2 ]
|
|
111
|
+
'arrow-spacing': 'warn', // space around arrow functions
|
|
112
|
+
'keyword-spacing': 'warn', // space around keywords (if, for, etc)
|
|
113
|
+
'space-before-blocks': 'warn',
|
|
114
|
+
'space-before-function-paren': ['warn', {
|
|
115
|
+
anonymous: 'always',
|
|
116
|
+
named: 'never',
|
|
117
|
+
asyncArrow: 'always',
|
|
118
|
+
}],
|
|
119
|
+
'space-infix-ops': 'warn', // spaces around operators: a + b, a === b
|
|
120
|
+
'max-len': ['warn', {
|
|
121
|
+
code: 120,
|
|
122
|
+
ignorePattern: '^import |^export |// ',
|
|
123
|
+
ignoreUrls: true,
|
|
124
|
+
}], // max 120 chars per line
|
|
125
|
+
// Slight structure: empty line before return for readability
|
|
126
|
+
'newline-before-return': 'warn',
|
|
127
|
+
// ========== TypeScript ==========
|
|
128
|
+
'@typescript-eslint/no-unused-vars': [
|
|
129
|
+
'warn',
|
|
130
|
+
{ argsIgnorePattern: '^_' },
|
|
131
|
+
],
|
|
132
|
+
'@typescript-eslint/explicit-function-return-types': 'off',
|
|
133
|
+
'@typescript-eslint/no-explicit-any': 'warn',
|
|
134
|
+
'@typescript-eslint/ban-ts-comment': 'warn',
|
|
135
|
+
'@typescript-eslint/no-unused-expressions': 'off',
|
|
136
|
+
},
|
|
137
|
+
},
|
|
138
|
+
];
|
|
139
|
+
export default config;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frontend.d.ts","sourceRoot":"","sources":["../../../src/configs/frontend.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAMrC,QAAA,MAAM,MAAM,EAAE,MAAM,CAAC,MAAM,EAwC1B,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import baseConfig from './base.js';
|
|
2
|
+
import pluginReact from 'eslint-plugin-react';
|
|
3
|
+
import pluginReactHooks from 'eslint-plugin-react-hooks';
|
|
4
|
+
import pluginNext from '@next/eslint-plugin-next';
|
|
5
|
+
const config = [
|
|
6
|
+
...baseConfig,
|
|
7
|
+
{
|
|
8
|
+
files: ['**/*.{js,jsx,ts,tsx}'],
|
|
9
|
+
plugins: {
|
|
10
|
+
react: pluginReact,
|
|
11
|
+
'react-hooks': pluginReactHooks,
|
|
12
|
+
'@next/next': pluginNext,
|
|
13
|
+
},
|
|
14
|
+
rules: {
|
|
15
|
+
...pluginReact.configs.flat.recommended.rules,
|
|
16
|
+
...pluginReactHooks.configs.recommended.rules,
|
|
17
|
+
...pluginNext.configs.recommended.rules,
|
|
18
|
+
'react/react-in-jsx-scope': 'off',
|
|
19
|
+
'react/prop-types': 'warn',
|
|
20
|
+
'react/jsx-uses-react': 'off',
|
|
21
|
+
'react-hooks/rules-of-hooks': 'error',
|
|
22
|
+
'react-hooks/exhaustive-deps': 'warn',
|
|
23
|
+
'@next/next/no-html-link-for-pages': 'off',
|
|
24
|
+
'react/jsx-max-props-per-line': [
|
|
25
|
+
'error',
|
|
26
|
+
{ 'maximum': 1, 'when': 'multiline' },
|
|
27
|
+
],
|
|
28
|
+
'react/jsx-first-prop-new-line': [
|
|
29
|
+
'error',
|
|
30
|
+
'multiline',
|
|
31
|
+
],
|
|
32
|
+
},
|
|
33
|
+
settings: {
|
|
34
|
+
react: {
|
|
35
|
+
version: 'detect',
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
languageOptions: {
|
|
39
|
+
globals: {
|
|
40
|
+
document: 'readonly',
|
|
41
|
+
window: 'readonly',
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
];
|
|
46
|
+
export default config;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAA;AACtC,OAAO,KAAK,OAAO,MAAM,mBAAmB,CAAA;AAC5C,OAAO,KAAK,QAAQ,MAAM,oBAAoB,CAAA"}
|
package/package.json
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@klymchuk/v2-eslint",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"author": "Mykhailo Klymchuk",
|
|
5
|
+
"description": "Shared ESLint configurations for klymchuk-brand-v2 projects",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./dist/cjs/index.js",
|
|
8
|
+
"module": "./dist/esm/index.js",
|
|
9
|
+
"types": "./dist/esm/index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/esm/index.d.ts",
|
|
13
|
+
"import": "./dist/esm/index.js",
|
|
14
|
+
"require": "./dist/cjs/index.js"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist",
|
|
19
|
+
"README.md"
|
|
20
|
+
],
|
|
21
|
+
"publishConfig": {
|
|
22
|
+
"access": "public"
|
|
23
|
+
},
|
|
24
|
+
"repository": {
|
|
25
|
+
"type": "git",
|
|
26
|
+
"url": "git+https://github.com/micklymchuk/klymchuk-brand-v2-shared.git",
|
|
27
|
+
"directory": "packages/eslint"
|
|
28
|
+
},
|
|
29
|
+
"keywords": [
|
|
30
|
+
"eslint",
|
|
31
|
+
"eslint-config",
|
|
32
|
+
"typescript",
|
|
33
|
+
"react",
|
|
34
|
+
"nextjs"
|
|
35
|
+
],
|
|
36
|
+
"scripts": {
|
|
37
|
+
"build": "npm run build:esm && npm run build:cjs && npm run fix-cjs",
|
|
38
|
+
"build:esm": "tsc -p tsconfig.esm.json",
|
|
39
|
+
"build:cjs": "tsc -p tsconfig.cjs.json",
|
|
40
|
+
"fix-cjs": "echo '{\"type\":\"commonjs\"}' > dist/cjs/package.json",
|
|
41
|
+
"clean": "rm -rf dist",
|
|
42
|
+
"prepublishOnly": "npm run build"
|
|
43
|
+
},
|
|
44
|
+
"peerDependencies": {
|
|
45
|
+
"@eslint/js": ">=9",
|
|
46
|
+
"@next/eslint-plugin-next": ">=14",
|
|
47
|
+
"eslint": ">=8",
|
|
48
|
+
"eslint-config-next": ">=14",
|
|
49
|
+
"eslint-plugin-react": ">=7",
|
|
50
|
+
"eslint-plugin-react-hooks": ">=4",
|
|
51
|
+
"typescript-eslint": ">=8"
|
|
52
|
+
},
|
|
53
|
+
"license": "ISC"
|
|
54
|
+
}
|