eslint-config-beslogic 5.2.1 → 5.2.3
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/.dprint.jsonc +1 -1
- package/CHANGELOG.md +10 -0
- package/LICENSE +1 -1
- package/angular.mjs +5 -1
- package/eslint.config.mjs +1 -1
- package/extra-strict.mjs +12 -3
- package/index.mjs +1 -1
- package/javascript.mjs +8 -1
- package/jest.mjs +1 -1
- package/json-like.mjs +1 -1
- package/lib/utils.mjs +22 -10
- package/mui.mjs +1 -1
- package/node-js.mjs +1 -1
- package/package.json +3 -3
- package/react-native.mjs +1 -1
- package/react-redux.mjs +1 -1
- package/react.mjs +9 -8
- package/rxjs.mjs +1 -1
- package/storybook.mjs +1 -1
- package/stylistic.mjs +1 -1
- package/tsconfig.4.3.json +3 -1
- package/tsconfig.5.0.json +1 -1
- package/tsconfig.5.6.json +1 -1
- package/tsconfig.json +5 -1
- package/typescript.mjs +2 -1
package/.dprint.jsonc
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 5.2.3
|
|
4
|
+
|
|
5
|
+
- `unicorn/prevent-abbreviations` in `react` preset allow "Prop" abbreviation to allow "PropTypes" constants
|
|
6
|
+
- Added `"incremental": true` and `"strictNullChecks": true` to shared `tsconfig.json`
|
|
7
|
+
- Fixed type-checking issues in source so that pure-JS projects with `"checkJs": true` don't fail type-checking
|
|
8
|
+
|
|
9
|
+
## 5.2.2
|
|
10
|
+
|
|
11
|
+
- Don't sort alphabetically in `@stylistic/jsx-sort-props` in non-extra-strict preset
|
|
12
|
+
|
|
3
13
|
## 5.2.1
|
|
4
14
|
|
|
5
15
|
- Replaced `react/jsx-sort-props` with `@stylistic/jsx-sort-props`
|
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
The MIT License
|
|
2
2
|
|
|
3
|
-
Copyright
|
|
3
|
+
Copyright 2026 Beslogic Inc.
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
6
|
|
package/angular.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
|
-
// Copyright
|
|
2
|
+
// Copyright 2026 Beslogic Inc.
|
|
3
3
|
|
|
4
4
|
import { ASTUtils } from "@angular-eslint/utils"
|
|
5
5
|
import { defineConfig } from "@eslint/config-helpers"
|
|
@@ -21,7 +21,11 @@ const typescriptVersion = getModuleVersion("typescript", 99)
|
|
|
21
21
|
const typeDeclarationOverride = beslogicTypeScript.find(
|
|
22
22
|
config => config.name === "beslogic/typescript/type-declaration"
|
|
23
23
|
)
|
|
24
|
+
if (!typeDeclarationOverride) {
|
|
25
|
+
throw new TypeError("beslogic/typescript/type-declaration config not found in typescript.mjs")
|
|
26
|
+
}
|
|
24
27
|
|
|
28
|
+
/** @type {[import('@eslint/core').Severity, ...(string | { selector: string, message: string })[]]} */
|
|
25
29
|
export const noRestrictedSyntax = [
|
|
26
30
|
...noRestrictedSyntaxJS,
|
|
27
31
|
// TODO: Possibly implement that ourselves?
|
package/eslint.config.mjs
CHANGED
package/extra-strict.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
|
-
// Copyright
|
|
2
|
+
// Copyright 2026 Beslogic Inc.
|
|
3
3
|
|
|
4
4
|
import { defineConfig } from "@eslint/config-helpers"
|
|
5
5
|
|
|
6
|
-
import { jestFilePatterns, resolveModuleLocation } from "./lib/utils.mjs"
|
|
6
|
+
import { jestFilePatterns, jsxSortPropsConfig, resolveModuleLocation } from "./lib/utils.mjs"
|
|
7
7
|
import { noFloatingPromisesKnownSafeCalls, noRestrictedSyntax as noRestrictedSyntaxTS, restrictTemplateExpressionsConfig } from "./typescript.mjs"
|
|
8
8
|
|
|
9
9
|
// These extra strict configs are not only for Angular. User may be using a different framework
|
|
@@ -32,11 +32,12 @@ export const explicitModuleBoundaryType = [
|
|
|
32
32
|
}
|
|
33
33
|
]
|
|
34
34
|
|
|
35
|
+
/** @type {[import('@eslint/core').Severity, ...(string | { selector: string, message: string })[]]} */
|
|
35
36
|
export const noRestrictedSyntax = [
|
|
36
37
|
...noRestrictedSyntaxTS,
|
|
37
38
|
// TODO: This would really be better as its own rule.
|
|
38
39
|
// My understanding is that it only negatively affects published libs,
|
|
39
|
-
// and even then there's
|
|
40
|
+
// and even then there's ways to work around it.
|
|
40
41
|
// Ban `const` enums: https://typescript-eslint.io/troubleshooting/faqs/general/#how-can-i-ban-specific-language-feature
|
|
41
42
|
{
|
|
42
43
|
"selector": "TSEnumDeclaration[const=true]",
|
|
@@ -53,6 +54,14 @@ export default defineConfig(
|
|
|
53
54
|
"**/*.tsx"
|
|
54
55
|
],
|
|
55
56
|
"rules": {
|
|
57
|
+
"@stylistic/jsx-sort-props": [
|
|
58
|
+
"error",
|
|
59
|
+
{
|
|
60
|
+
...jsxSortPropsConfig,
|
|
61
|
+
"noSortAlphabetically": false
|
|
62
|
+
}
|
|
63
|
+
],
|
|
64
|
+
|
|
56
65
|
// This is caught when noImplicitThis is enabled, which we assume in this config
|
|
57
66
|
// https://typescript-eslint.io/rules/no-invalid-this/
|
|
58
67
|
"@typescript-eslint/no-invalid-this": "off",
|
package/index.mjs
CHANGED
package/javascript.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
|
-
// Copyright
|
|
2
|
+
// Copyright 2026 Beslogic Inc.
|
|
3
3
|
|
|
4
4
|
import { fixupPluginRules } from "@eslint/compat"
|
|
5
5
|
import { defineConfig } from "@eslint/config-helpers"
|
|
@@ -33,6 +33,7 @@ export const restrictedGlobals = [
|
|
|
33
33
|
}
|
|
34
34
|
]
|
|
35
35
|
|
|
36
|
+
/** @type {[import('@eslint/core').Severity, ...(string | { selector: string, message: string })[]]} */
|
|
36
37
|
export const noRestrictedSyntax = [
|
|
37
38
|
"error",
|
|
38
39
|
"WithStatement",
|
|
@@ -88,6 +89,8 @@ export const noMagicNumbersConfig = {
|
|
|
88
89
|
}
|
|
89
90
|
: {}
|
|
90
91
|
}
|
|
92
|
+
|
|
93
|
+
/** @type {[import('@eslint/core').Severity, Record<string, string | boolean>]} */
|
|
91
94
|
export const noUnusedVariables = [
|
|
92
95
|
"error",
|
|
93
96
|
{
|
|
@@ -101,6 +104,7 @@ export const noUnusedVariables = [
|
|
|
101
104
|
]
|
|
102
105
|
// Same as S00107
|
|
103
106
|
// Projects with dependency Injection (Angular) also need more params in their constructor
|
|
107
|
+
/** @type {[import('@eslint/core').Severity, { max: number }]} */
|
|
104
108
|
export const maxParams = [
|
|
105
109
|
"error",
|
|
106
110
|
{ "max": 7 }
|
|
@@ -207,6 +211,9 @@ export default defineConfig(
|
|
|
207
211
|
sonarjs.configs.recommended,
|
|
208
212
|
eslintPluginUnicorn.configs["flat/all"],
|
|
209
213
|
regexp.configs["flat/recommended"],
|
|
214
|
+
// @ts-ignore
|
|
215
|
+
// - https://github.com/un-ts/eslint-plugin-import-x/issues/439
|
|
216
|
+
// - https://github.com/typescript-eslint/typescript-eslint/issues/11543
|
|
210
217
|
importX.flatConfigs.recommended,
|
|
211
218
|
comments.recommended,
|
|
212
219
|
{
|
package/jest.mjs
CHANGED
package/json-like.mjs
CHANGED
package/lib/utils.mjs
CHANGED
|
@@ -31,16 +31,16 @@ export const resolveModuleLocation = (/** @type {string} */ nodeModule) => {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
export const jestNoRestrictedSyntax = (
|
|
34
|
-
/** @type {(
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
34
|
+
/** @type {readonly (number | string | {readonly selector: string})[]} */ noRestrictedSyntax
|
|
35
|
+
// eslint-disable-next-line @stylistic/no-extra-parens -- https://github.com/eslint-stylistic/eslint-stylistic/issues/1088
|
|
36
|
+
) => /** @type {import('@eslint/config-helpers').RuleConfig} */ (noRestrictedSyntax.filter(
|
|
37
|
+
entry =>
|
|
38
|
+
typeof entry === "number"
|
|
39
|
+
|| typeof entry === "string"
|
|
40
|
+
// Exclude from jest tests for compatibility with
|
|
41
|
+
// `jest/valid-describe-callback` and `jest/no-test-return-statement`
|
|
42
|
+
|| !entry.selector.startsWith("ArrowFunctionExpression")
|
|
43
|
+
))
|
|
44
44
|
|
|
45
45
|
// Matching Jest's own default file patterns: https://jestjs.io/docs/configuration#testmatch-arraystring
|
|
46
46
|
export const jestFilePatterns = [
|
|
@@ -85,3 +85,15 @@ export const idLenghtConfig = {
|
|
|
85
85
|
"z"
|
|
86
86
|
]
|
|
87
87
|
}
|
|
88
|
+
|
|
89
|
+
// eslint-disable-next-line unicorn/prevent-abbreviations -- Props allowed in React
|
|
90
|
+
export const jsxSortPropsConfig = {
|
|
91
|
+
// Keeping special props first, and not hiding props under big multiline
|
|
92
|
+
// both help a lot with readability and semantics
|
|
93
|
+
"reservedFirst": true,
|
|
94
|
+
"shorthandFirst": true,
|
|
95
|
+
"multiline": "last",
|
|
96
|
+
// Alphabetical sorting is nice for automated consistency,
|
|
97
|
+
// but is too pedantic for widespread adoption. Set in extra-strict preset.
|
|
98
|
+
"noSortAlphabetically": true
|
|
99
|
+
}
|
package/mui.mjs
CHANGED
package/node-js.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-config-beslogic",
|
|
3
|
-
"version": "5.2.
|
|
3
|
+
"version": "5.2.3",
|
|
4
4
|
"description": "ESLint rules, plugins and configs used at Beslogic",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
"scripts": {
|
|
9
9
|
"eslint-unstable-flag": "set TIMING=1 && eslint . --flag unstable_config_lookup_from_file",
|
|
10
10
|
"eslint": "set TIMING=1 && eslint . --flag v10_config_lookup_from_file",
|
|
11
|
-
"lint": "dprint check && npm run eslint",
|
|
12
|
-
"lint:fix": "npm run eslint -- --fix && dprint fmt",
|
|
11
|
+
"lint": "dprint check && npm run eslint && tsc",
|
|
12
|
+
"lint:fix": "npm run eslint -- --fix && dprint fmt && tsc",
|
|
13
13
|
"upgrade": "npx npm-check-updates -u & npm i",
|
|
14
14
|
"prepack": "type .gitignore* > .npmignore",
|
|
15
15
|
"postinstall": "node ./lib/patch-dependencies.mjs",
|
package/react-native.mjs
CHANGED
package/react-redux.mjs
CHANGED
package/react.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
|
-
// Copyright
|
|
2
|
+
// Copyright 2026 Beslogic Inc.
|
|
3
3
|
|
|
4
4
|
import { defineConfig } from "@eslint/config-helpers"
|
|
5
5
|
import jsxA11y from "eslint-plugin-jsx-a11y"
|
|
@@ -10,14 +10,15 @@ import testingLibrary from "eslint-plugin-testing-library"
|
|
|
10
10
|
import globals from "globals"
|
|
11
11
|
|
|
12
12
|
import beslogicJavascript, { preventAbbreviationsConfig as preventAbbreviationsConfigJS } from "./javascript.mjs"
|
|
13
|
-
import { jestFilePatterns } from "./lib/utils.mjs"
|
|
13
|
+
import { jestFilePatterns, jsxSortPropsConfig } from "./lib/utils.mjs"
|
|
14
14
|
import beslogicTypeScript from "./typescript.mjs"
|
|
15
15
|
|
|
16
16
|
const typeDeclarationOverride = beslogicTypeScript.find(
|
|
17
17
|
config => config.name === "beslogic/typescript/type-declaration"
|
|
18
18
|
)
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
if (!typeDeclarationOverride) {
|
|
20
|
+
throw new TypeError("beslogic/typescript/type-declaration config not found in typescript.mjs")
|
|
21
|
+
}
|
|
21
22
|
|
|
22
23
|
const preventAbbreviationsConfig = { ...preventAbbreviationsConfigJS }
|
|
23
24
|
// React props
|
|
@@ -25,6 +26,9 @@ preventAbbreviationsConfig.allowList.props = true
|
|
|
25
26
|
preventAbbreviationsConfig.allowList.Props = true
|
|
26
27
|
preventAbbreviationsConfig.allowList.ref = true
|
|
27
28
|
preventAbbreviationsConfig.allowList.Ref = true
|
|
29
|
+
preventAbbreviationsConfig.allowList.PropTypes = true
|
|
30
|
+
// Apparently Trying to set "PropTypes" doesn't work
|
|
31
|
+
preventAbbreviationsConfig.allowList.Prop = true
|
|
28
32
|
// useState's set method using the previous state
|
|
29
33
|
// Note: It's still better to name it like prevSomething
|
|
30
34
|
preventAbbreviationsConfig.allowList.prev = true
|
|
@@ -98,10 +102,7 @@ export default defineConfig(
|
|
|
98
102
|
"react/jsx-sort-props": "off",
|
|
99
103
|
"@stylistic/jsx-sort-props": [
|
|
100
104
|
"error",
|
|
101
|
-
|
|
102
|
-
// both help a lot with readability and semantics
|
|
103
|
-
// Still keeping alphabetical sorting for automatic consistency
|
|
104
|
-
{ "reservedFirst": true, "shorthandFirst": true, "multiline": "last" }
|
|
105
|
+
jsxSortPropsConfig
|
|
105
106
|
],
|
|
106
107
|
|
|
107
108
|
/*
|
package/rxjs.mjs
CHANGED
package/storybook.mjs
CHANGED
package/stylistic.mjs
CHANGED
package/tsconfig.4.3.json
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
|
-
// Copyright
|
|
2
|
+
// Copyright 2026 Beslogic Inc.
|
|
3
3
|
|
|
4
4
|
{
|
|
5
5
|
"compilerOptions": {
|
|
6
6
|
"strict": true,
|
|
7
7
|
"checkJs": true,
|
|
8
|
+
"incremental": true, // Performance improvement during dev through incremental checking
|
|
8
9
|
"newLine": "LF", // Now default in TypeScript 5.0
|
|
9
10
|
"forceConsistentCasingInFileNames": true, // Now default in TypeScript 5.0
|
|
10
11
|
"resolveJsonModule": true,
|
|
11
12
|
"noFallthroughCasesInSwitch": true,
|
|
12
13
|
"noImplicitOverride": true,
|
|
13
14
|
"noImplicitReturns": true,
|
|
15
|
+
"strictNullChecks": true, // Stop hiding null/undefined types, *even* with strict=false !
|
|
14
16
|
// This makes index accesses even stricter. You may not want it in your project.
|
|
15
17
|
// You should probably disable it at least in tests.
|
|
16
18
|
"noUncheckedIndexedAccess": true,
|
package/tsconfig.5.0.json
CHANGED
package/tsconfig.5.6.json
CHANGED
package/tsconfig.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
|
-
// Copyright
|
|
2
|
+
// Copyright 2026 Beslogic Inc.
|
|
3
3
|
|
|
4
4
|
{
|
|
5
5
|
"extends": "./tsconfig.5.6.json",
|
|
@@ -12,5 +12,9 @@
|
|
|
12
12
|
"jsx": "react-jsx",
|
|
13
13
|
"allowJs": true,
|
|
14
14
|
"noImplicitAny": false,
|
|
15
|
+
// Some issues in upstream .d.ts imports
|
|
16
|
+
"skipLibCheck": true,
|
|
17
|
+
// Necessary as long as we still test old-style Angular decorators
|
|
18
|
+
"experimentalDecorators": true,
|
|
15
19
|
},
|
|
16
20
|
}
|
package/typescript.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
|
-
// Copyright
|
|
2
|
+
// Copyright 2026 Beslogic Inc.
|
|
3
3
|
|
|
4
4
|
import { defineConfig } from "@eslint/config-helpers"
|
|
5
5
|
import { createTypeScriptImportResolver } from "eslint-import-resolver-typescript"
|
|
@@ -11,6 +11,7 @@ import { maxParams, noMagicNumbersConfig as noMagicNumbersConfigJS, noRestricted
|
|
|
11
11
|
import beslogicJest from "./jest.mjs"
|
|
12
12
|
import { jestFilePatterns, jestNoRestrictedSyntax } from "./lib/utils.mjs"
|
|
13
13
|
|
|
14
|
+
/** @type {[import('@eslint/core').Severity, ...(string | { selector: string, message: string })[]]} */
|
|
14
15
|
export const noRestrictedSyntax = [
|
|
15
16
|
...noRestrictedSyntaxJS,
|
|
16
17
|
{
|