@leancodepl/eslint-config 9.6.5 → 9.7.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/CHANGELOG.md +32 -0
- package/jest.config.js +8 -0
- package/package.json +3 -1
- package/project.json +7 -0
- package/src/index.js +5 -10
- package/src/lib/a11y.js +8 -1
- package/src/lib/base-react.js +44 -34
- package/src/lib/base.js +72 -52
- package/src/lib/imports.js +74 -71
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,38 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See
|
|
4
4
|
[Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [9.7.0](https://github.com/leancodepl/js_corelibrary/compare/v9.6.6...v9.7.0) (2025-12-18)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- add eslint-config-prettier
|
|
11
|
+
([c671ee8](https://github.com/leancodepl/js_corelibrary/commit/c671ee8b0202014fc3b0f3c31268af5f012328fb))
|
|
12
|
+
- make eslint configs independent
|
|
13
|
+
([157c92b](https://github.com/leancodepl/js_corelibrary/commit/157c92b4cc68e870a210d754814c383aba859f0a))
|
|
14
|
+
- make local eslint config run directly from built js
|
|
15
|
+
([a82e48a](https://github.com/leancodepl/js_corelibrary/commit/a82e48a758d2d40352f832fba260759e3b77e70e))
|
|
16
|
+
|
|
17
|
+
### Features
|
|
18
|
+
|
|
19
|
+
- add switch-case-braces eslint rule
|
|
20
|
+
([f3bb74e](https://github.com/leancodepl/js_corelibrary/commit/f3bb74e53c8e8f40defa8bef409a7f1cf2329d73))
|
|
21
|
+
- rewrite esling-config with typescript
|
|
22
|
+
([92d53fe](https://github.com/leancodepl/js_corelibrary/commit/92d53fedc6d3ced2feaa81b803bdb9c299de537c))
|
|
23
|
+
|
|
24
|
+
# Change Log
|
|
25
|
+
|
|
26
|
+
All notable changes to this project will be documented in this file. See
|
|
27
|
+
[Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
28
|
+
|
|
29
|
+
## [9.6.6](https://github.com/leancodepl/js_corelibrary/compare/v9.6.5...v9.6.6) (2025-11-18)
|
|
30
|
+
|
|
31
|
+
**Note:** Version bump only for package @leancodepl/eslint-config
|
|
32
|
+
|
|
33
|
+
# Change Log
|
|
34
|
+
|
|
35
|
+
All notable changes to this project will be documented in this file. See
|
|
36
|
+
[Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
37
|
+
|
|
6
38
|
## [9.6.5](https://github.com/leancodepl/js_corelibrary/compare/v9.6.4...v9.6.5) (2025-10-16)
|
|
7
39
|
|
|
8
40
|
**Note:** Version bump only for package @leancodepl/eslint-config
|
package/jest.config.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
displayName: "@leancodepl/eslint-config",
|
|
3
|
+
moduleFileExtensions: ["js"],
|
|
4
|
+
testEnvironment: "node",
|
|
5
|
+
coverageDirectory: "../../../coverage/packages/linters/eslint-config",
|
|
6
|
+
testMatch: ["<rootDir>/src/**/__tests__/**/*.spec.js"],
|
|
7
|
+
transform: {},
|
|
8
|
+
}
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leancodepl/eslint-config",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.7.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"dependencies": {
|
|
7
|
+
"@leancodepl/eslint-plugin": "9.7.0",
|
|
7
8
|
"eslint-plugin-import": ">=2.31.0",
|
|
8
9
|
"eslint-plugin-jsx-a11y": ">=6.10.0",
|
|
9
10
|
"eslint-plugin-perfectionist": ">=4.0.0",
|
|
@@ -12,6 +13,7 @@
|
|
|
12
13
|
"globals": ">=15.0.0"
|
|
13
14
|
},
|
|
14
15
|
"peerDependencies": {
|
|
16
|
+
"@types/eslint-plugin-jsx-a11y": ">=6.10.0",
|
|
15
17
|
"eslint": ">=8.9.0",
|
|
16
18
|
"eslint-config-prettier": ">=9.1.0",
|
|
17
19
|
"eslint-plugin-react": ">=7.34.1",
|
package/project.json
CHANGED
|
@@ -19,6 +19,13 @@
|
|
|
19
19
|
"publish": {
|
|
20
20
|
"command": "node tools/scripts/publish.mjs @leancodepl/eslint-config {args.registry} {args.ver} {args.tag}",
|
|
21
21
|
"dependsOn": ["build"]
|
|
22
|
+
},
|
|
23
|
+
"test": {
|
|
24
|
+
"executor": "@nx/jest:jest",
|
|
25
|
+
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
|
|
26
|
+
"options": {
|
|
27
|
+
"jestConfig": "packages/linters/eslint-config/jest.config.js"
|
|
28
|
+
}
|
|
22
29
|
}
|
|
23
30
|
}
|
|
24
31
|
}
|
package/src/index.js
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
const a11y = require("./lib/a11y")
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
const imports = require("./lib/imports")
|
|
1
|
+
const { a11y } = require("./lib/a11y.js")
|
|
2
|
+
const { baseReact } = require("./lib/base-react.js")
|
|
3
|
+
const { base } = require("./lib/base.js")
|
|
4
|
+
const { imports } = require("./lib/imports.js")
|
|
5
5
|
|
|
6
|
-
module.exports = {
|
|
7
|
-
imports,
|
|
8
|
-
base,
|
|
9
|
-
baseReact,
|
|
10
|
-
a11y,
|
|
11
|
-
}
|
|
6
|
+
module.exports = { a11y, base, baseReact, imports }
|
package/src/lib/a11y.js
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
1
|
const jsxA11y = require("eslint-plugin-jsx-a11y")
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* @typedef {import('@typescript-eslint/utils').TSESLint.FlatConfig.Config} Config
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/** @type {Config[]} */
|
|
8
|
+
const a11y = [jsxA11y.flatConfigs.recommended]
|
|
9
|
+
|
|
10
|
+
module.exports = { a11y }
|
package/src/lib/base-react.js
CHANGED
|
@@ -2,42 +2,52 @@ const react = require("eslint-plugin-react")
|
|
|
2
2
|
const reactHooks = require("eslint-plugin-react-hooks")
|
|
3
3
|
const globals = require("globals")
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
/**
|
|
6
|
+
* @typedef {import('@typescript-eslint/utils').TSESLint.FlatConfig.Config} Config
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/** @type {Config[]} */
|
|
10
|
+
const baseReact = [
|
|
11
|
+
{
|
|
12
|
+
plugins: {
|
|
13
|
+
react,
|
|
14
|
+
"react-hooks": reactHooks,
|
|
15
|
+
},
|
|
16
|
+
languageOptions: {
|
|
17
|
+
parserOptions: {
|
|
18
|
+
ecmaFeatures: {
|
|
19
|
+
jsx: true,
|
|
10
20
|
},
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
21
|
+
},
|
|
22
|
+
globals: {
|
|
23
|
+
...globals.browser,
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
rules: {
|
|
27
|
+
"react/jsx-boolean-value": "error",
|
|
28
|
+
"react/jsx-curly-brace-presence": "warn",
|
|
29
|
+
"react/jsx-fragments": "warn",
|
|
30
|
+
"react/jsx-no-useless-fragment": ["error", { allowExpressions: true }],
|
|
31
|
+
"react/jsx-sort-props": [
|
|
32
|
+
"warn",
|
|
33
|
+
{
|
|
34
|
+
callbacksLast: true,
|
|
35
|
+
shorthandFirst: true,
|
|
36
|
+
shorthandLast: false,
|
|
37
|
+
ignoreCase: true,
|
|
38
|
+
noSortAlphabetically: false,
|
|
39
|
+
reservedFirst: true,
|
|
20
40
|
},
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
"react/jsx-curly-brace-presence": "warn",
|
|
24
|
-
"react/jsx-fragments": "warn",
|
|
25
|
-
"react/jsx-no-useless-fragment": ["error", { allowExpressions: true }],
|
|
26
|
-
"react/jsx-sort-props": [
|
|
27
|
-
"warn",
|
|
28
|
-
{
|
|
29
|
-
callbacksLast: true,
|
|
30
|
-
shorthandFirst: true,
|
|
31
|
-
shorthandLast: false,
|
|
32
|
-
ignoreCase: true,
|
|
33
|
-
noSortAlphabetically: false,
|
|
34
|
-
reservedFirst: true,
|
|
35
|
-
},
|
|
36
|
-
],
|
|
37
|
-
"react/self-closing-comp": "error",
|
|
41
|
+
],
|
|
42
|
+
"react/self-closing-comp": "error",
|
|
38
43
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
44
|
+
"react-hooks/exhaustive-deps": "error",
|
|
45
|
+
"react-hooks/rules-of-hooks": "error",
|
|
46
|
+
|
|
47
|
+
"react/jsx-uses-react": "off",
|
|
48
|
+
"react/jsx-uses-vars": "error",
|
|
42
49
|
},
|
|
50
|
+
},
|
|
43
51
|
]
|
|
52
|
+
|
|
53
|
+
module.exports = { baseReact }
|
package/src/lib/base.js
CHANGED
|
@@ -1,58 +1,78 @@
|
|
|
1
|
+
const parser = require("@typescript-eslint/parser")
|
|
2
|
+
const eslintConfigPrettier = require("eslint-config-prettier")
|
|
1
3
|
const perfectionist = require("eslint-plugin-perfectionist")
|
|
4
|
+
const tseslint = require("typescript-eslint")
|
|
5
|
+
const { leancodePlugin } = require("@leancodepl/eslint-plugin")
|
|
2
6
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
7
|
+
/**
|
|
8
|
+
* @typedef {import('@typescript-eslint/utils').TSESLint.FlatConfig.Config} Config
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/** @type {Config[]} */
|
|
12
|
+
const base = [
|
|
13
|
+
{
|
|
14
|
+
languageOptions: {
|
|
15
|
+
parser: tseslint.parser,
|
|
16
|
+
},
|
|
17
|
+
plugins: {
|
|
18
|
+
"@typescript-eslint": tseslint.plugin,
|
|
19
|
+
perfectionist,
|
|
20
|
+
leancode: leancodePlugin,
|
|
21
|
+
},
|
|
22
|
+
rules: {
|
|
23
|
+
curly: ["error", "multi-line", "consistent"],
|
|
24
|
+
"max-params": ["error", { max: 4 }],
|
|
25
|
+
"no-console": ["warn", { allow: ["warn", "error", "assert"] }],
|
|
26
|
+
"no-eval": "error",
|
|
27
|
+
"no-useless-rename": "error",
|
|
28
|
+
"arrow-body-style": ["error", "as-needed"],
|
|
29
|
+
"no-case-declarations": "off",
|
|
30
|
+
|
|
31
|
+
"leancode/switch-case-braces": "error",
|
|
15
32
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
},
|
|
26
|
-
],
|
|
27
|
-
"perfectionist/sort-array-includes": [
|
|
28
|
-
"error",
|
|
29
|
-
{
|
|
30
|
-
type: "natural",
|
|
31
|
-
order: "asc",
|
|
32
|
-
},
|
|
33
|
-
],
|
|
34
|
-
"perfectionist/sort-intersection-types": [
|
|
35
|
-
"error",
|
|
36
|
-
{
|
|
37
|
-
type: "natural",
|
|
38
|
-
order: "asc",
|
|
39
|
-
},
|
|
40
|
-
],
|
|
41
|
-
"perfectionist/sort-named-exports": [
|
|
42
|
-
"error",
|
|
43
|
-
{
|
|
44
|
-
type: "natural",
|
|
45
|
-
order: "asc",
|
|
46
|
-
},
|
|
47
|
-
],
|
|
48
|
-
"perfectionist/sort-union-types": [
|
|
49
|
-
"error",
|
|
50
|
-
{
|
|
51
|
-
type: "natural",
|
|
52
|
-
order: "asc",
|
|
53
|
-
groups: ["unknown", "nullish"],
|
|
54
|
-
},
|
|
55
|
-
],
|
|
33
|
+
"@typescript-eslint/no-empty-function": "off",
|
|
34
|
+
"@typescript-eslint/no-empty-object-type": "off",
|
|
35
|
+
"@typescript-eslint/no-explicit-any": "off",
|
|
36
|
+
"@typescript-eslint/naming-convention": [
|
|
37
|
+
"error",
|
|
38
|
+
{
|
|
39
|
+
selector: "variable",
|
|
40
|
+
format: ["camelCase", "PascalCase"],
|
|
41
|
+
leadingUnderscore: "allow",
|
|
56
42
|
},
|
|
43
|
+
],
|
|
44
|
+
"perfectionist/sort-array-includes": [
|
|
45
|
+
"error",
|
|
46
|
+
{
|
|
47
|
+
type: "natural",
|
|
48
|
+
order: "asc",
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
"perfectionist/sort-intersection-types": [
|
|
52
|
+
"error",
|
|
53
|
+
{
|
|
54
|
+
type: "natural",
|
|
55
|
+
order: "asc",
|
|
56
|
+
},
|
|
57
|
+
],
|
|
58
|
+
"perfectionist/sort-named-exports": [
|
|
59
|
+
"error",
|
|
60
|
+
{
|
|
61
|
+
type: "natural",
|
|
62
|
+
order: "asc",
|
|
63
|
+
},
|
|
64
|
+
],
|
|
65
|
+
"perfectionist/sort-union-types": [
|
|
66
|
+
"error",
|
|
67
|
+
{
|
|
68
|
+
type: "natural",
|
|
69
|
+
order: "asc",
|
|
70
|
+
groups: ["unknown", "nullish"],
|
|
71
|
+
},
|
|
72
|
+
],
|
|
57
73
|
},
|
|
74
|
+
},
|
|
75
|
+
eslintConfigPrettier,
|
|
58
76
|
]
|
|
77
|
+
|
|
78
|
+
module.exports = { base }
|
package/src/lib/imports.js
CHANGED
|
@@ -1,77 +1,80 @@
|
|
|
1
|
-
const
|
|
2
|
-
const perfectionist = require("eslint-plugin-perfectionist")
|
|
1
|
+
const importsPlugin = require("eslint-plugin-import")
|
|
3
2
|
const unusedImports = require("eslint-plugin-unused-imports")
|
|
4
3
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
/**
|
|
5
|
+
* @typedef {import('@typescript-eslint/utils').TSESLint.FlatConfig.Config} Config
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/** @type {Config[]} */
|
|
9
|
+
const imports = [
|
|
10
|
+
{
|
|
11
|
+
plugins: {
|
|
12
|
+
"unused-imports": unusedImports,
|
|
13
|
+
import: importsPlugin,
|
|
14
|
+
},
|
|
15
|
+
rules: {
|
|
16
|
+
"@typescript-eslint/no-unused-vars": "off",
|
|
17
|
+
"import/first": "error",
|
|
18
|
+
"import/newline-after-import": "error",
|
|
19
|
+
"import/no-anonymous-default-export": "error",
|
|
20
|
+
"import/no-duplicates": "error",
|
|
21
|
+
"import/no-extraneous-dependencies": "error",
|
|
22
|
+
"import/no-named-default": "error",
|
|
23
|
+
"import/no-self-import": "error",
|
|
24
|
+
"import/no-useless-path-segments": [
|
|
25
|
+
"error",
|
|
26
|
+
{
|
|
27
|
+
noUselessIndex: true,
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
"perfectionist/sort-imports": [
|
|
31
|
+
"error",
|
|
32
|
+
{
|
|
33
|
+
type: "natural",
|
|
34
|
+
order: "asc",
|
|
35
|
+
groups: [
|
|
36
|
+
"client-server-only",
|
|
37
|
+
"react",
|
|
38
|
+
["builtin", "external"],
|
|
39
|
+
["internal-type", "internal"],
|
|
40
|
+
["parent", "sibling", "index"],
|
|
41
|
+
["type", "parent-type", "sibling-type", "index-type"],
|
|
42
|
+
"side-effect",
|
|
43
|
+
"style",
|
|
44
|
+
"unknown",
|
|
45
|
+
],
|
|
46
|
+
customGroups: {
|
|
47
|
+
value: {
|
|
48
|
+
react: ["^react$", "^react-.+"],
|
|
49
|
+
"client-server-only": ["^client-only$", "^server-only$"],
|
|
50
|
+
},
|
|
51
|
+
type: {
|
|
52
|
+
react: "^react$",
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
newlinesBetween: "never",
|
|
56
|
+
internalPattern: ["^@leancodepl/.+"],
|
|
11
57
|
},
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
"import/no-extraneous-dependencies": "error",
|
|
19
|
-
"import/no-named-default": "error",
|
|
20
|
-
"import/no-self-import": "error",
|
|
21
|
-
"import/no-useless-path-segments": [
|
|
22
|
-
"error",
|
|
23
|
-
{
|
|
24
|
-
noUselessIndex: true,
|
|
25
|
-
},
|
|
26
|
-
],
|
|
27
|
-
"perfectionist/sort-imports": [
|
|
28
|
-
"error",
|
|
29
|
-
{
|
|
30
|
-
type: "natural",
|
|
31
|
-
order: "asc",
|
|
32
|
-
groups: [
|
|
33
|
-
"client-server-only",
|
|
34
|
-
"react",
|
|
35
|
-
["builtin", "external"],
|
|
36
|
-
["internal-type", "internal"],
|
|
37
|
-
["parent", "sibling", "index"],
|
|
38
|
-
["type", "parent-type", "sibling-type", "index-type"],
|
|
39
|
-
"side-effect",
|
|
40
|
-
"style",
|
|
41
|
-
"unknown",
|
|
42
|
-
],
|
|
43
|
-
customGroups: {
|
|
44
|
-
value: {
|
|
45
|
-
react: ["^react$", "^react-.+"],
|
|
46
|
-
"client-server-only": ["^client-only$", "^server-only$"],
|
|
47
|
-
},
|
|
48
|
-
type: {
|
|
49
|
-
react: "^react$",
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
newlinesBetween: "never",
|
|
53
|
-
internalPattern: ["^@leancodepl/.+"],
|
|
54
|
-
},
|
|
55
|
-
],
|
|
56
|
-
"perfectionist/sort-named-imports": [
|
|
57
|
-
"error",
|
|
58
|
-
{
|
|
59
|
-
type: "natural",
|
|
60
|
-
order: "asc",
|
|
61
|
-
},
|
|
62
|
-
],
|
|
63
|
-
"react/jsx-uses-react": "off",
|
|
64
|
-
"react/jsx-uses-vars": "error",
|
|
65
|
-
"unused-imports/no-unused-imports": "warn",
|
|
66
|
-
"unused-imports/no-unused-vars": [
|
|
67
|
-
"warn",
|
|
68
|
-
{
|
|
69
|
-
vars: "all",
|
|
70
|
-
varsIgnorePattern: "^_",
|
|
71
|
-
args: "after-used",
|
|
72
|
-
argsIgnorePattern: "^_",
|
|
73
|
-
},
|
|
74
|
-
],
|
|
58
|
+
],
|
|
59
|
+
"perfectionist/sort-named-imports": [
|
|
60
|
+
"error",
|
|
61
|
+
{
|
|
62
|
+
type: "natural",
|
|
63
|
+
order: "asc",
|
|
75
64
|
},
|
|
65
|
+
],
|
|
66
|
+
"unused-imports/no-unused-imports": "warn",
|
|
67
|
+
"unused-imports/no-unused-vars": [
|
|
68
|
+
"warn",
|
|
69
|
+
{
|
|
70
|
+
vars: "all",
|
|
71
|
+
varsIgnorePattern: "^_",
|
|
72
|
+
args: "after-used",
|
|
73
|
+
argsIgnorePattern: "^_",
|
|
74
|
+
},
|
|
75
|
+
],
|
|
76
76
|
},
|
|
77
|
+
},
|
|
77
78
|
]
|
|
79
|
+
|
|
80
|
+
module.exports = { imports }
|