@rootreeweb/linting 4.2.1
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 +100 -0
- package/dist/esm/eslint/astro.d.ts +3 -0
- package/dist/esm/eslint/astro.d.ts.map +1 -0
- package/dist/esm/eslint/astro.js +29 -0
- package/dist/esm/eslint/astro.js.map +1 -0
- package/dist/esm/eslint/basic.d.ts +3 -0
- package/dist/esm/eslint/basic.d.ts.map +1 -0
- package/dist/esm/eslint/basic.js +155 -0
- package/dist/esm/eslint/basic.js.map +1 -0
- package/dist/esm/eslint/index.d.ts +15 -0
- package/dist/esm/eslint/index.d.ts.map +1 -0
- package/dist/esm/eslint/index.js +23 -0
- package/dist/esm/eslint/index.js.map +1 -0
- package/dist/esm/eslint/jsdoc.d.ts +3 -0
- package/dist/esm/eslint/jsdoc.d.ts.map +1 -0
- package/dist/esm/eslint/jsdoc.js +33 -0
- package/dist/esm/eslint/jsdoc.js.map +1 -0
- package/dist/esm/eslint/next.d.ts +3 -0
- package/dist/esm/eslint/next.d.ts.map +1 -0
- package/dist/esm/eslint/next.js +15 -0
- package/dist/esm/eslint/next.js.map +1 -0
- package/dist/esm/eslint/patches/index.d.ts +10 -0
- package/dist/esm/eslint/patches/index.d.ts.map +1 -0
- package/dist/esm/eslint/patches/index.js +16 -0
- package/dist/esm/eslint/patches/index.js.map +1 -0
- package/dist/esm/eslint/patches/sonarjs.d.ts +14 -0
- package/dist/esm/eslint/patches/sonarjs.d.ts.map +1 -0
- package/dist/esm/eslint/patches/sonarjs.js +83 -0
- package/dist/esm/eslint/patches/sonarjs.js.map +1 -0
- package/dist/esm/eslint/patches/types.d.ts +30 -0
- package/dist/esm/eslint/patches/types.d.ts.map +1 -0
- package/dist/esm/eslint/patches/types.js +2 -0
- package/dist/esm/eslint/patches/types.js.map +1 -0
- package/dist/esm/eslint/plugins.d.ts +3 -0
- package/dist/esm/eslint/plugins.d.ts.map +1 -0
- package/dist/esm/eslint/plugins.js +3 -0
- package/dist/esm/eslint/plugins.js.map +1 -0
- package/dist/esm/eslint/react.d.ts +3 -0
- package/dist/esm/eslint/react.d.ts.map +1 -0
- package/dist/esm/eslint/react.js +59 -0
- package/dist/esm/eslint/react.js.map +1 -0
- package/dist/esm/eslint/tailwind.d.ts +7 -0
- package/dist/esm/eslint/tailwind.d.ts.map +1 -0
- package/dist/esm/eslint/tailwind.js +69 -0
- package/dist/esm/eslint/tailwind.js.map +1 -0
- package/dist/esm/eslint/turbo.d.ts +3 -0
- package/dist/esm/eslint/turbo.d.ts.map +1 -0
- package/dist/esm/eslint/turbo.js +5 -0
- package/dist/esm/eslint/turbo.js.map +1 -0
- package/dist/esm/eslint/utils.d.ts +11 -0
- package/dist/esm/eslint/utils.d.ts.map +1 -0
- package/dist/esm/eslint/utils.js +32 -0
- package/dist/esm/eslint/utils.js.map +1 -0
- package/dist/esm/index.d.ts +6 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +6 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/knip.d.ts +20 -0
- package/dist/esm/knip.d.ts.map +1 -0
- package/dist/esm/knip.js +25 -0
- package/dist/esm/knip.js.map +1 -0
- package/dist/esm/lintStaged.d.ts +32 -0
- package/dist/esm/lintStaged.d.ts.map +1 -0
- package/dist/esm/lintStaged.js +88 -0
- package/dist/esm/lintStaged.js.map +1 -0
- package/dist/esm/prettier.d.ts +28 -0
- package/dist/esm/prettier.d.ts.map +1 -0
- package/dist/esm/prettier.js +62 -0
- package/dist/esm/prettier.js.map +1 -0
- package/dist/esm/stylelint/basic.d.ts +5 -0
- package/dist/esm/stylelint/basic.d.ts.map +1 -0
- package/dist/esm/stylelint/basic.js +17 -0
- package/dist/esm/stylelint/basic.js.map +1 -0
- package/dist/esm/stylelint/index.d.ts +3 -0
- package/dist/esm/stylelint/index.d.ts.map +1 -0
- package/dist/esm/stylelint/index.js +3 -0
- package/dist/esm/stylelint/index.js.map +1 -0
- package/dist/esm/stylelint/tailwind.d.ts +3 -0
- package/dist/esm/stylelint/tailwind.d.ts.map +1 -0
- package/dist/esm/stylelint/tailwind.js +37 -0
- package/dist/esm/stylelint/tailwind.js.map +1 -0
- package/package.json +107 -0
package/README.md
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
# @rootreeweb/linting
|
|
2
|
+
|
|
3
|
+
## What is This?
|
|
4
|
+
|
|
5
|
+
The package provides our standard configurations for [ESLint](https://eslint.org/), [Prettier](https://prettier.io/), and [Stylelint](https://stylelint.io/).
|
|
6
|
+
|
|
7
|
+
## Getting Started
|
|
8
|
+
|
|
9
|
+
1. The first step (if you haven't done so already) is to setup authentication for using our private packages.
|
|
10
|
+
You can find instructions for doing that within the [Rootree Web Wiki](<[https://github.com/rootreeweb/rootree](https://docs.cappy.rootree.ca/guides/packages)>).
|
|
11
|
+
2. The second step is to add the library to your package file. This would typically be done with:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
yarn add @rootreeweb/linting
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## ESLint
|
|
18
|
+
|
|
19
|
+
Separate modules are available as are common preset configurations.
|
|
20
|
+
The presets can also add in additional modules as needed.
|
|
21
|
+
An example of this would be a next site that is part of a TurboRepo.
|
|
22
|
+
|
|
23
|
+
**All examples here belong in `eslint.config.js`**
|
|
24
|
+
|
|
25
|
+
### Preset
|
|
26
|
+
|
|
27
|
+
Available presets:
|
|
28
|
+
|
|
29
|
+
- presetBase
|
|
30
|
+
- presetReact
|
|
31
|
+
- presetNext
|
|
32
|
+
|
|
33
|
+
```javascript
|
|
34
|
+
import { presetBase } from "@rootreeweb/linting";
|
|
35
|
+
|
|
36
|
+
export default presetBase;
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### Mix and Match
|
|
40
|
+
|
|
41
|
+
Available modules:
|
|
42
|
+
|
|
43
|
+
- basic
|
|
44
|
+
- jsdoc
|
|
45
|
+
- react
|
|
46
|
+
- tailwind
|
|
47
|
+
- next
|
|
48
|
+
- turbo
|
|
49
|
+
|
|
50
|
+
```javascript
|
|
51
|
+
import {
|
|
52
|
+
basic,
|
|
53
|
+
jsdoc,
|
|
54
|
+
next,
|
|
55
|
+
react,
|
|
56
|
+
tailwind,
|
|
57
|
+
turbo,
|
|
58
|
+
} from "@rootreeweb/linting";
|
|
59
|
+
|
|
60
|
+
const config = [
|
|
61
|
+
...basic,
|
|
62
|
+
...jsdoc,
|
|
63
|
+
...react,
|
|
64
|
+
...tailwind,
|
|
65
|
+
...next,
|
|
66
|
+
...turbo,
|
|
67
|
+
{
|
|
68
|
+
rules: {
|
|
69
|
+
"tailwindcss/no-contradicting-classname": "warn",
|
|
70
|
+
"tailwindcss/no-custom-classname": [
|
|
71
|
+
"warn",
|
|
72
|
+
{
|
|
73
|
+
callees: ["twMerge"],
|
|
74
|
+
},
|
|
75
|
+
],
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
ignores: ["data"],
|
|
80
|
+
},
|
|
81
|
+
];
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Next preset with TurboRepo example:
|
|
85
|
+
|
|
86
|
+
```javascript
|
|
87
|
+
import { presetNext, turbo } from "@rootreeweb/linting";
|
|
88
|
+
|
|
89
|
+
export default [...presetNext, ...turbo];
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Stylelint
|
|
93
|
+
|
|
94
|
+
`stylelint.config.js` example:
|
|
95
|
+
|
|
96
|
+
```javascript
|
|
97
|
+
import { stylelint } from "@rootreeweb/linting";
|
|
98
|
+
|
|
99
|
+
export default stylelint;
|
|
100
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"astro.d.ts","sourceRoot":"","sources":["../../../src/eslint/astro.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAoBrC,eAAO,MAAM,KAAK,EAAE,MAAM,CAAC,MAAM,EAW/B,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// CJS Workaround. Seems like only the default exists in the CJS package, not using expect error because there is no error in ESM.
|
|
2
|
+
//eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
3
|
+
// @ts-ignore
|
|
4
|
+
import { configs } from "eslint-plugin-astro";
|
|
5
|
+
import { jsxA11y } from "./plugins.js";
|
|
6
|
+
const astroBase = [
|
|
7
|
+
...configs["flat/all"],
|
|
8
|
+
...configs["flat/jsx-a11y-strict"],
|
|
9
|
+
{
|
|
10
|
+
rules: {
|
|
11
|
+
"import/no-unresolved": "off", //These rules conflict with astro:content.
|
|
12
|
+
"sonarjs/no-implicit-dependencies": "off",
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
{ ignores: ["**/*.d.ts"] },
|
|
16
|
+
];
|
|
17
|
+
export const astro = astroBase.map((config) => {
|
|
18
|
+
if (config.plugins?.["jsx-a11y"]) {
|
|
19
|
+
return {
|
|
20
|
+
...config,
|
|
21
|
+
plugins: {
|
|
22
|
+
...config.plugins,
|
|
23
|
+
"jsx-a11y": jsxA11y,
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
return config;
|
|
28
|
+
});
|
|
29
|
+
//# sourceMappingURL=astro.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"astro.js","sourceRoot":"","sources":["../../../src/eslint/astro.ts"],"names":[],"mappings":"AACA,kIAAkI;AAClI,4DAA4D;AAC5D,aAAa;AACb,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAE9C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,MAAM,SAAS,GAAoB;IAClC,GAAG,OAAO,CAAC,UAAU,CAAC;IACtB,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAClC;QACC,KAAK,EAAE;YACN,sBAAsB,EAAE,KAAK,EAAE,0CAA0C;YACzE,kCAAkC,EAAE,KAAK;SACzC;KACD;IACD,EAAE,OAAO,EAAE,CAAC,WAAW,CAAC,EAAE;CAC1B,CAAC;AAEF,MAAM,CAAC,MAAM,KAAK,GAAoB,SAAS,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE;IAC9D,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC,UAAU,CAAC,EAAE,CAAC;QAClC,OAAO;YACN,GAAG,MAAM;YACT,OAAO,EAAE;gBACR,GAAG,MAAM,CAAC,OAAO;gBACjB,UAAU,EAAE,OAAO;aACnB;SACD,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AACf,CAAC,CAAC,CAAC","sourcesContent":["import type { Linter } from \"eslint\";\n// CJS Workaround. Seems like only the default exists in the CJS package, not using expect error because there is no error in ESM.\n//eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nimport { configs } from \"eslint-plugin-astro\";\n\nimport { jsxA11y } from \"./plugins.js\";\n\nconst astroBase: Linter.Config[] = [\n\t...configs[\"flat/all\"],\n\t...configs[\"flat/jsx-a11y-strict\"],\n\t{\n\t\trules: {\n\t\t\t\"import/no-unresolved\": \"off\", //These rules conflict with astro:content.\n\t\t\t\"sonarjs/no-implicit-dependencies\": \"off\",\n\t\t},\n\t},\n\t{ ignores: [\"**/*.d.ts\"] },\n];\n\nexport const astro: Linter.Config[] = astroBase.map((config) => {\n\tif (config.plugins?.[\"jsx-a11y\"]) {\n\t\treturn {\n\t\t\t...config,\n\t\t\tplugins: {\n\t\t\t\t...config.plugins,\n\t\t\t\t\"jsx-a11y\": jsxA11y,\n\t\t\t},\n\t\t};\n\t}\n\treturn config;\n});\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"basic.d.ts","sourceRoot":"","sources":["../../../src/eslint/basic.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAgBrC,eAAO,MAAM,KAAK,EAAE,MAAM,CAAC,MAAM,EA0IhC,CAAC"}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import eslint from "@eslint/js";
|
|
2
|
+
import vitest from "@vitest/eslint-plugin";
|
|
3
|
+
import { createTypeScriptImportResolver } from "eslint-import-resolver-typescript";
|
|
4
|
+
import importPlugin from "eslint-plugin-import";
|
|
5
|
+
import perfectionist from "eslint-plugin-perfectionist";
|
|
6
|
+
// @ts-expect-error TS7016 Can't get these types to work.
|
|
7
|
+
import pluginPromise from "eslint-plugin-promise";
|
|
8
|
+
import security from "eslint-plugin-security";
|
|
9
|
+
import sonarjs from "eslint-plugin-sonarjs";
|
|
10
|
+
import { defineConfig } from "eslint/config";
|
|
11
|
+
import globals from "globals";
|
|
12
|
+
import tseslint from "typescript-eslint";
|
|
13
|
+
import { applyPatches } from "./patches/index.js";
|
|
14
|
+
// Apply all custom plugin patches before building configs.
|
|
15
|
+
applyPatches({ sonarjs: sonarjs });
|
|
16
|
+
export const basic = [
|
|
17
|
+
eslint.configs.recommended,
|
|
18
|
+
...tseslint.configs.strictTypeChecked,
|
|
19
|
+
...tseslint.configs.stylisticTypeChecked,
|
|
20
|
+
importPlugin.flatConfigs.recommended,
|
|
21
|
+
security.configs.recommended,
|
|
22
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
23
|
+
pluginPromise.configs["flat/recommended"],
|
|
24
|
+
// eslint-disable-next-line import/no-named-as-default-member
|
|
25
|
+
perfectionist.configs["recommended-natural"],
|
|
26
|
+
...defineConfig({
|
|
27
|
+
plugins: { vitest },
|
|
28
|
+
rules: {
|
|
29
|
+
...vitest.configs.recommended.rules,
|
|
30
|
+
"vitest/valid-expect": ["warn", { maxArgs: 2 }],
|
|
31
|
+
},
|
|
32
|
+
}),
|
|
33
|
+
sonarjs.configs.recommended,
|
|
34
|
+
{
|
|
35
|
+
rules: {
|
|
36
|
+
"import/first": "error",
|
|
37
|
+
"import/newline-after-import": "error",
|
|
38
|
+
"import/no-cycle": "error",
|
|
39
|
+
"import/no-deprecated": "warn",
|
|
40
|
+
"import/no-duplicates": "error",
|
|
41
|
+
"import/no-useless-path-segments": "error",
|
|
42
|
+
"perfectionist/sort-imports": "off", // Conflict with the prettier ordering
|
|
43
|
+
"perfectionist/sort-named-imports": "off",
|
|
44
|
+
"promise/always-return": "off",
|
|
45
|
+
"promise/catch-or-return": "off",
|
|
46
|
+
"sonarjs/argument-type": "off", // TODO: This currently conflicts with the internal includes definition. Enable once fixed.
|
|
47
|
+
"sonarjs/assertions-in-tests": "off",
|
|
48
|
+
"sonarjs/cognitive-complexity": "warn",
|
|
49
|
+
"sonarjs/deprecation": "off", // Double coverage with @typescript-eslint/no-deprecated
|
|
50
|
+
"sonarjs/no-control-regex": "off", // Double coverage
|
|
51
|
+
"sonarjs/no-ignored-exceptions": "warn",
|
|
52
|
+
"sonarjs/no-implicit-dependencies": "warn",
|
|
53
|
+
"sonarjs/no-os-command-from-path": "warn",
|
|
54
|
+
"sonarjs/no-unused-vars": "off", // Double coverage
|
|
55
|
+
"sonarjs/prefer-read-only-props": "warn",
|
|
56
|
+
"sonarjs/prefer-single-boolean-return": "off",
|
|
57
|
+
"sonarjs/pseudo-random": "warn",
|
|
58
|
+
"sonarjs/slow-regex": "warn",
|
|
59
|
+
"sonarjs/todo-tag": "warn",
|
|
60
|
+
},
|
|
61
|
+
settings: {
|
|
62
|
+
"import/resolver": {
|
|
63
|
+
node: {
|
|
64
|
+
extensions: [".js", ".jsx", ".ts", ".tsx", ".svg", ".jpg", ".png"],
|
|
65
|
+
},
|
|
66
|
+
typescript: {
|
|
67
|
+
extensions: [".js", ".jsx", ".ts", ".tsx", ".svg", ".jpg", ".png"],
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
"import/resolver-next": [createTypeScriptImportResolver({})],
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
languageOptions: {
|
|
75
|
+
ecmaVersion: 2024,
|
|
76
|
+
globals: {
|
|
77
|
+
...globals.node,
|
|
78
|
+
...globals.browser,
|
|
79
|
+
},
|
|
80
|
+
parserOptions: {
|
|
81
|
+
projectService: true,
|
|
82
|
+
// CJS Workaround
|
|
83
|
+
// eslint-disable-next-line
|
|
84
|
+
// @ts-ignore
|
|
85
|
+
tsconfigRootDir: import.meta.dirname,
|
|
86
|
+
},
|
|
87
|
+
sourceType: "module",
|
|
88
|
+
},
|
|
89
|
+
rules: {
|
|
90
|
+
"@typescript-eslint/consistent-type-definitions": ["error", "type"],
|
|
91
|
+
"@typescript-eslint/consistent-type-imports": "error",
|
|
92
|
+
"@typescript-eslint/explicit-module-boundary-types": "warn",
|
|
93
|
+
"@typescript-eslint/no-base-to-string": "warn",
|
|
94
|
+
"@typescript-eslint/no-explicit-any": "warn",
|
|
95
|
+
"@typescript-eslint/no-floating-promises": "warn",
|
|
96
|
+
"@typescript-eslint/no-misused-spread": "warn",
|
|
97
|
+
"@typescript-eslint/no-shadow": "error",
|
|
98
|
+
"@typescript-eslint/no-unnecessary-condition": "warn",
|
|
99
|
+
"@typescript-eslint/no-unnecessary-type-parameters": "off",
|
|
100
|
+
"@typescript-eslint/no-unsafe-argument": "warn",
|
|
101
|
+
"@typescript-eslint/no-unsafe-assignment": "warn",
|
|
102
|
+
"@typescript-eslint/no-unsafe-call": "warn",
|
|
103
|
+
"@typescript-eslint/no-unsafe-member-access": "warn",
|
|
104
|
+
"@typescript-eslint/no-unsafe-return": "warn",
|
|
105
|
+
"@typescript-eslint/no-unused-vars": [
|
|
106
|
+
"error",
|
|
107
|
+
{
|
|
108
|
+
args: "all",
|
|
109
|
+
argsIgnorePattern: "^_",
|
|
110
|
+
caughtErrors: "all",
|
|
111
|
+
caughtErrorsIgnorePattern: "^_",
|
|
112
|
+
destructuredArrayIgnorePattern: "^_",
|
|
113
|
+
ignoreRestSiblings: true,
|
|
114
|
+
varsIgnorePattern: "^_",
|
|
115
|
+
},
|
|
116
|
+
],
|
|
117
|
+
"@typescript-eslint/prefer-nullish-coalescing": "warn",
|
|
118
|
+
"@typescript-eslint/require-await": "warn",
|
|
119
|
+
"@typescript-eslint/restrict-template-expressions": [
|
|
120
|
+
"warn",
|
|
121
|
+
{ allowNumber: true },
|
|
122
|
+
],
|
|
123
|
+
"no-console": ["warn", { allow: ["warn", "error"] }],
|
|
124
|
+
"no-shadow": "off",
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
...defineConfig({
|
|
128
|
+
extends: [tseslint.configs.disableTypeChecked],
|
|
129
|
+
files: [
|
|
130
|
+
"**/*.js",
|
|
131
|
+
"**/*.astro",
|
|
132
|
+
"**/*.cjs",
|
|
133
|
+
"**/*.config.ts",
|
|
134
|
+
"test.ts",
|
|
135
|
+
"test.tsx",
|
|
136
|
+
],
|
|
137
|
+
rules: {
|
|
138
|
+
"@typescript-eslint/explicit-module-boundary-types": "off",
|
|
139
|
+
},
|
|
140
|
+
}),
|
|
141
|
+
// Global Ignores
|
|
142
|
+
{
|
|
143
|
+
ignores: [
|
|
144
|
+
"dist/**/*",
|
|
145
|
+
".tsup/**/*",
|
|
146
|
+
".yarn/**/*",
|
|
147
|
+
".next/**/*",
|
|
148
|
+
".astro/**/*",
|
|
149
|
+
"vendor/**/*",
|
|
150
|
+
"playwright-report/**/*",
|
|
151
|
+
"coverage/**/*",
|
|
152
|
+
],
|
|
153
|
+
},
|
|
154
|
+
];
|
|
155
|
+
//# sourceMappingURL=basic.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"basic.js","sourceRoot":"","sources":["../../../src/eslint/basic.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,YAAY,CAAC;AAChC,OAAO,MAAM,MAAM,uBAAuB,CAAC;AAE3C,OAAO,EAAE,8BAA8B,EAAE,MAAM,mCAAmC,CAAC;AACnF,OAAO,YAAY,MAAM,sBAAsB,CAAC;AAChD,OAAO,aAAa,MAAM,6BAA6B,CAAC;AACxD,yDAAyD;AACzD,OAAO,aAAa,MAAM,uBAAuB,CAAC;AA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;CACD,CAAC","sourcesContent":["import eslint from \"@eslint/js\";\nimport vitest from \"@vitest/eslint-plugin\";\nimport type { Linter } from \"eslint\";\nimport { createTypeScriptImportResolver } from \"eslint-import-resolver-typescript\";\nimport importPlugin from \"eslint-plugin-import\";\nimport perfectionist from \"eslint-plugin-perfectionist\";\n// @ts-expect-error TS7016 Can't get these types to work.\nimport pluginPromise from \"eslint-plugin-promise\";\nimport security from \"eslint-plugin-security\";\nimport sonarjs from \"eslint-plugin-sonarjs\";\nimport { defineConfig } from \"eslint/config\";\nimport globals from \"globals\";\nimport tseslint from \"typescript-eslint\";\n\nimport { applyPatches } from \"./patches/index.js\";\n\n// Apply all custom plugin patches before building configs.\napplyPatches({ sonarjs: sonarjs });\nexport const basic: Linter.Config[] = [\n\teslint.configs.recommended,\n\t...tseslint.configs.strictTypeChecked,\n\t...tseslint.configs.stylisticTypeChecked,\n\timportPlugin.flatConfigs.recommended,\n\tsecurity.configs.recommended,\n\t// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n\tpluginPromise.configs[\"flat/recommended\"],\n\t// eslint-disable-next-line import/no-named-as-default-member\n\tperfectionist.configs[\"recommended-natural\"],\n\t...defineConfig({\n\t\tplugins: { vitest },\n\t\trules: {\n\t\t\t...vitest.configs.recommended.rules,\n\t\t\t\"vitest/valid-expect\": [\"warn\", { maxArgs: 2 }],\n\t\t},\n\t}),\n\tsonarjs.configs.recommended,\n\t{\n\t\trules: {\n\t\t\t\"import/first\": \"error\",\n\t\t\t\"import/newline-after-import\": \"error\",\n\t\t\t\"import/no-cycle\": \"error\",\n\t\t\t\"import/no-deprecated\": \"warn\",\n\t\t\t\"import/no-duplicates\": \"error\",\n\t\t\t\"import/no-useless-path-segments\": \"error\",\n\t\t\t\"perfectionist/sort-imports\": \"off\", // Conflict with the prettier ordering\n\t\t\t\"perfectionist/sort-named-imports\": \"off\",\n\t\t\t\"promise/always-return\": \"off\",\n\t\t\t\"promise/catch-or-return\": \"off\",\n\t\t\t\"sonarjs/argument-type\": \"off\", // TODO: This currently conflicts with the internal includes definition. Enable once fixed.\n\t\t\t\"sonarjs/assertions-in-tests\": \"off\",\n\t\t\t\"sonarjs/cognitive-complexity\": \"warn\",\n\t\t\t\"sonarjs/deprecation\": \"off\", // Double coverage with @typescript-eslint/no-deprecated\n\t\t\t\"sonarjs/no-control-regex\": \"off\", // Double coverage\n\t\t\t\"sonarjs/no-ignored-exceptions\": \"warn\",\n\t\t\t\"sonarjs/no-implicit-dependencies\": \"warn\",\n\t\t\t\"sonarjs/no-os-command-from-path\": \"warn\",\n\t\t\t\"sonarjs/no-unused-vars\": \"off\", // Double coverage\n\t\t\t\"sonarjs/prefer-read-only-props\": \"warn\",\n\t\t\t\"sonarjs/prefer-single-boolean-return\": \"off\",\n\t\t\t\"sonarjs/pseudo-random\": \"warn\",\n\t\t\t\"sonarjs/slow-regex\": \"warn\",\n\t\t\t\"sonarjs/todo-tag\": \"warn\",\n\t\t},\n\t\tsettings: {\n\t\t\t\"import/resolver\": {\n\t\t\t\tnode: {\n\t\t\t\t\textensions: [\".js\", \".jsx\", \".ts\", \".tsx\", \".svg\", \".jpg\", \".png\"],\n\t\t\t\t},\n\t\t\t\ttypescript: {\n\t\t\t\t\textensions: [\".js\", \".jsx\", \".ts\", \".tsx\", \".svg\", \".jpg\", \".png\"],\n\t\t\t\t},\n\t\t\t},\n\t\t\t\"import/resolver-next\": [createTypeScriptImportResolver({})],\n\t\t},\n\t},\n\t{\n\t\tlanguageOptions: {\n\t\t\tecmaVersion: 2024,\n\t\t\tglobals: {\n\t\t\t\t...globals.node,\n\t\t\t\t...globals.browser,\n\t\t\t},\n\t\t\tparserOptions: {\n\t\t\t\tprojectService: true,\n\t\t\t\t// CJS Workaround\n\t\t\t\t// eslint-disable-next-line\n\t\t\t\t// @ts-ignore\n\t\t\t\ttsconfigRootDir: import.meta.dirname,\n\t\t\t},\n\t\t\tsourceType: \"module\",\n\t\t},\n\t\trules: {\n\t\t\t\"@typescript-eslint/consistent-type-definitions\": [\"error\", \"type\"],\n\t\t\t\"@typescript-eslint/consistent-type-imports\": \"error\",\n\t\t\t\"@typescript-eslint/explicit-module-boundary-types\": \"warn\",\n\t\t\t\"@typescript-eslint/no-base-to-string\": \"warn\",\n\t\t\t\"@typescript-eslint/no-explicit-any\": \"warn\",\n\t\t\t\"@typescript-eslint/no-floating-promises\": \"warn\",\n\t\t\t\"@typescript-eslint/no-misused-spread\": \"warn\",\n\t\t\t\"@typescript-eslint/no-shadow\": \"error\",\n\t\t\t\"@typescript-eslint/no-unnecessary-condition\": \"warn\",\n\t\t\t\"@typescript-eslint/no-unnecessary-type-parameters\": \"off\",\n\t\t\t\"@typescript-eslint/no-unsafe-argument\": \"warn\",\n\t\t\t\"@typescript-eslint/no-unsafe-assignment\": \"warn\",\n\t\t\t\"@typescript-eslint/no-unsafe-call\": \"warn\",\n\t\t\t\"@typescript-eslint/no-unsafe-member-access\": \"warn\",\n\t\t\t\"@typescript-eslint/no-unsafe-return\": \"warn\",\n\t\t\t\"@typescript-eslint/no-unused-vars\": [\n\t\t\t\t\"error\",\n\t\t\t\t{\n\t\t\t\t\targs: \"all\",\n\t\t\t\t\targsIgnorePattern: \"^_\",\n\t\t\t\t\tcaughtErrors: \"all\",\n\t\t\t\t\tcaughtErrorsIgnorePattern: \"^_\",\n\t\t\t\t\tdestructuredArrayIgnorePattern: \"^_\",\n\t\t\t\t\tignoreRestSiblings: true,\n\t\t\t\t\tvarsIgnorePattern: \"^_\",\n\t\t\t\t},\n\t\t\t],\n\t\t\t\"@typescript-eslint/prefer-nullish-coalescing\": \"warn\",\n\t\t\t\"@typescript-eslint/require-await\": \"warn\",\n\t\t\t\"@typescript-eslint/restrict-template-expressions\": [\n\t\t\t\t\"warn\",\n\t\t\t\t{ allowNumber: true },\n\t\t\t],\n\t\t\t\"no-console\": [\"warn\", { allow: [\"warn\", \"error\"] }],\n\t\t\t\"no-shadow\": \"off\",\n\t\t},\n\t},\n\t...defineConfig({\n\t\textends: [tseslint.configs.disableTypeChecked],\n\t\tfiles: [\n\t\t\t\"**/*.js\",\n\t\t\t\"**/*.astro\",\n\t\t\t\"**/*.cjs\",\n\t\t\t\"**/*.config.ts\",\n\t\t\t\"test.ts\",\n\t\t\t\"test.tsx\",\n\t\t],\n\t\trules: {\n\t\t\t\"@typescript-eslint/explicit-module-boundary-types\": \"off\",\n\t\t},\n\t}),\n\t// Global Ignores\n\t{\n\t\tignores: [\n\t\t\t\"dist/**/*\",\n\t\t\t\".tsup/**/*\",\n\t\t\t\".yarn/**/*\",\n\t\t\t\".next/**/*\",\n\t\t\t\".astro/**/*\",\n\t\t\t\"vendor/**/*\",\n\t\t\t\"playwright-report/**/*\",\n\t\t\t\"coverage/**/*\",\n\t\t],\n\t},\n];\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Linter } from "eslint";
|
|
2
|
+
import { type TailwindOptions } from "./tailwind.js";
|
|
3
|
+
export * from "./astro.js";
|
|
4
|
+
export * from "./basic.js";
|
|
5
|
+
export * from "./jsdoc.js";
|
|
6
|
+
export * from "./next.js";
|
|
7
|
+
export * from "./react.js";
|
|
8
|
+
export * from "./tailwind.js";
|
|
9
|
+
export * from "./turbo.js";
|
|
10
|
+
export declare const presetBase: Linter.Config[];
|
|
11
|
+
export declare const presetReactLite: Linter.Config[];
|
|
12
|
+
export declare const getPresetReact: (options: TailwindOptions) => Linter.Config[];
|
|
13
|
+
export declare const getPresetNext: (options: TailwindOptions) => Linter.Config[];
|
|
14
|
+
export declare const getPresetAstro: (options: TailwindOptions) => Linter.Config[];
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/eslint/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAOrC,OAAO,EAAe,KAAK,eAAe,EAAE,MAAM,eAAe,CAAC;AAGlE,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAE3B,eAAO,MAAM,UAAU,EAAE,MAAM,CAAC,MAAM,EAAyB,CAAC;AAChE,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAGzC,CAAC;AACH,eAAO,MAAM,cAAc,YAAa,eAAe,KAAG,MAAM,CAAC,MAAM,EACA,CAAC;AACxE,eAAO,MAAM,aAAa,YAAa,eAAe,KAAG,MAAM,CAAC,MAAM,EACZ,CAAC;AAC3D,eAAO,MAAM,cAAc,YAAa,eAAe,KAAG,MAAM,CAAC,MAAM,EACZ,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { astro } from "./astro.js";
|
|
2
|
+
import { basic } from "./basic.js";
|
|
3
|
+
import { jsdoc } from "./jsdoc.js";
|
|
4
|
+
import { next } from "./next.js";
|
|
5
|
+
import { react } from "./react.js";
|
|
6
|
+
import { getTailwind } from "./tailwind.js";
|
|
7
|
+
import { deduplicatePlugins } from "./utils.js";
|
|
8
|
+
export * from "./astro.js";
|
|
9
|
+
export * from "./basic.js";
|
|
10
|
+
export * from "./jsdoc.js";
|
|
11
|
+
export * from "./next.js";
|
|
12
|
+
export * from "./react.js";
|
|
13
|
+
export * from "./tailwind.js";
|
|
14
|
+
export * from "./turbo.js";
|
|
15
|
+
export const presetBase = [...basic, ...jsdoc];
|
|
16
|
+
export const presetReactLite = deduplicatePlugins([
|
|
17
|
+
...presetBase,
|
|
18
|
+
...react,
|
|
19
|
+
]);
|
|
20
|
+
export const getPresetReact = (options) => deduplicatePlugins([...presetBase, ...react, ...getTailwind(options)]);
|
|
21
|
+
export const getPresetNext = (options) => deduplicatePlugins([...getPresetReact(options), ...next]);
|
|
22
|
+
export const getPresetAstro = (options) => deduplicatePlugins([...getPresetReact(options), ...astro]);
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/eslint/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,WAAW,EAAwB,MAAM,eAAe,CAAC;AAClE,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAEhD,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAE3B,MAAM,CAAC,MAAM,UAAU,GAAoB,CAAC,GAAG,KAAK,EAAE,GAAG,KAAK,CAAC,CAAC;AAChE,MAAM,CAAC,MAAM,eAAe,GAAoB,kBAAkB,CAAC;IAClE,GAAG,UAAU;IACb,GAAG,KAAK;CACR,CAAC,CAAC;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,OAAwB,EAAmB,EAAE,CAC3E,kBAAkB,CAAC,CAAC,GAAG,UAAU,EAAE,GAAG,KAAK,EAAE,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AACxE,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,OAAwB,EAAmB,EAAE,CAC1E,kBAAkB,CAAC,CAAC,GAAG,cAAc,CAAC,OAAO,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC;AAC3D,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,OAAwB,EAAmB,EAAE,CAC3E,kBAAkB,CAAC,CAAC,GAAG,cAAc,CAAC,OAAO,CAAC,EAAE,GAAG,KAAK,CAAC,CAAC,CAAC","sourcesContent":["import type { Linter } from \"eslint\";\n\nimport { astro } from \"./astro.js\";\nimport { basic } from \"./basic.js\";\nimport { jsdoc } from \"./jsdoc.js\";\nimport { next } from \"./next.js\";\nimport { react } from \"./react.js\";\nimport { getTailwind, type TailwindOptions } from \"./tailwind.js\";\nimport { deduplicatePlugins } from \"./utils.js\";\n\nexport * from \"./astro.js\";\nexport * from \"./basic.js\";\nexport * from \"./jsdoc.js\";\nexport * from \"./next.js\";\nexport * from \"./react.js\";\nexport * from \"./tailwind.js\";\nexport * from \"./turbo.js\";\n\nexport const presetBase: Linter.Config[] = [...basic, ...jsdoc];\nexport const presetReactLite: Linter.Config[] = deduplicatePlugins([\n\t...presetBase,\n\t...react,\n]);\nexport const getPresetReact = (options: TailwindOptions): Linter.Config[] =>\n\tdeduplicatePlugins([...presetBase, ...react, ...getTailwind(options)]);\nexport const getPresetNext = (options: TailwindOptions): Linter.Config[] =>\n\tdeduplicatePlugins([...getPresetReact(options), ...next]);\nexport const getPresetAstro = (options: TailwindOptions): Linter.Config[] =>\n\tdeduplicatePlugins([...getPresetReact(options), ...astro]);\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsdoc.d.ts","sourceRoot":"","sources":["../../../src/eslint/jsdoc.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGrC,eAAO,MAAM,KAAK,EAAE,MAAM,CAAC,MAAM,EA8BhC,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import jsdocEslint from "eslint-plugin-jsdoc";
|
|
2
|
+
export const jsdoc = [
|
|
3
|
+
jsdocEslint.configs["flat/recommended-typescript"],
|
|
4
|
+
{
|
|
5
|
+
plugins: {
|
|
6
|
+
jsdocEslint,
|
|
7
|
+
},
|
|
8
|
+
rules: {
|
|
9
|
+
"jsdoc/check-template-names": "error",
|
|
10
|
+
"jsdoc/require-jsdoc": [
|
|
11
|
+
"error",
|
|
12
|
+
{
|
|
13
|
+
require: {
|
|
14
|
+
ClassDeclaration: true,
|
|
15
|
+
FunctionDeclaration: true,
|
|
16
|
+
MethodDefinition: true,
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
],
|
|
20
|
+
"jsdoc/require-template": "warn",
|
|
21
|
+
"jsdoc/require-throws": "warn",
|
|
22
|
+
"jsdoc/tag-lines": "off",
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
files: ["**/*.js", "**/*.jsx", "**/*.cjs", "**/*.mjs"],
|
|
27
|
+
plugins: {
|
|
28
|
+
jsdoc: jsdocEslint,
|
|
29
|
+
},
|
|
30
|
+
rules: { "jsdoc/check-tag-names": "off" },
|
|
31
|
+
},
|
|
32
|
+
];
|
|
33
|
+
//# sourceMappingURL=jsdoc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsdoc.js","sourceRoot":"","sources":["../../../src/eslint/jsdoc.ts"],"names":[],"mappings":"AACA,OAAO,WAAW,MAAM,qBAAqB,CAAC;AAE9C,MAAM,CAAC,MAAM,KAAK,GAAoB;IACrC,WAAW,CAAC,OAAO,CAAC,6BAA6B,CAAC;IAClD;QACC,OAAO,EAAE;YACR,WAAW;SACX;QACD,KAAK,EAAE;YACN,4BAA4B,EAAE,OAAO;YACrC,qBAAqB,EAAE;gBACtB,OAAO;gBACP;oBACC,OAAO,EAAE;wBACR,gBAAgB,EAAE,IAAI;wBACtB,mBAAmB,EAAE,IAAI;wBACzB,gBAAgB,EAAE,IAAI;qBACtB;iBACD;aACD;YACD,wBAAwB,EAAE,MAAM;YAChC,sBAAsB,EAAE,MAAM;YAC9B,iBAAiB,EAAE,KAAK;SACxB;KACD;IACD;QACC,KAAK,EAAE,CAAC,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,CAAC;QACtD,OAAO,EAAE;YACR,KAAK,EAAE,WAAW;SAClB;QACD,KAAK,EAAE,EAAE,uBAAuB,EAAE,KAAK,EAAE;KACzC;CACD,CAAC","sourcesContent":["import type { Linter } from \"eslint\";\nimport jsdocEslint from \"eslint-plugin-jsdoc\";\n\nexport const jsdoc: Linter.Config[] = [\n\tjsdocEslint.configs[\"flat/recommended-typescript\"],\n\t{\n\t\tplugins: {\n\t\t\tjsdocEslint,\n\t\t},\n\t\trules: {\n\t\t\t\"jsdoc/check-template-names\": \"error\",\n\t\t\t\"jsdoc/require-jsdoc\": [\n\t\t\t\t\"error\",\n\t\t\t\t{\n\t\t\t\t\trequire: {\n\t\t\t\t\t\tClassDeclaration: true,\n\t\t\t\t\t\tFunctionDeclaration: true,\n\t\t\t\t\t\tMethodDefinition: true,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t],\n\t\t\t\"jsdoc/require-template\": \"warn\",\n\t\t\t\"jsdoc/require-throws\": \"warn\",\n\t\t\t\"jsdoc/tag-lines\": \"off\",\n\t\t},\n\t},\n\t{\n\t\tfiles: [\"**/*.js\", \"**/*.jsx\", \"**/*.cjs\", \"**/*.mjs\"],\n\t\tplugins: {\n\t\t\tjsdoc: jsdocEslint,\n\t\t},\n\t\trules: { \"jsdoc/check-tag-names\": \"off\" },\n\t},\n];\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"next.d.ts","sourceRoot":"","sources":["../../../src/eslint/next.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAErC,eAAO,MAAM,IAAI,EAAE,MAAM,CAAC,MAAM,EAY/B,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import pluginNext from "@next/eslint-plugin-next";
|
|
2
|
+
export const next = [
|
|
3
|
+
{
|
|
4
|
+
plugins: {
|
|
5
|
+
"@next/next": pluginNext,
|
|
6
|
+
},
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
files: ["**/*.ts", "**/*.tsx"],
|
|
10
|
+
rules: {
|
|
11
|
+
...pluginNext.configs.recommended.rules,
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
];
|
|
15
|
+
//# sourceMappingURL=next.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"next.js","sourceRoot":"","sources":["../../../src/eslint/next.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,0BAA0B,CAAC;AAGlD,MAAM,CAAC,MAAM,IAAI,GAAoB;IACpC;QACC,OAAO,EAAE;YACR,YAAY,EAAE,UAAU;SACxB;KACD;IACD;QACC,KAAK,EAAE,CAAC,SAAS,EAAE,UAAU,CAAC;QAC9B,KAAK,EAAE;YACN,GAAG,UAAU,CAAC,OAAO,CAAC,WAAW,CAAC,KAAK;SACvC;KACD;CACD,CAAC","sourcesContent":["import pluginNext from \"@next/eslint-plugin-next\";\nimport type { Linter } from \"eslint\";\n\nexport const next: Linter.Config[] = [\n\t{\n\t\tplugins: {\n\t\t\t\"@next/next\": pluginNext,\n\t\t},\n\t},\n\t{\n\t\tfiles: [\"**/*.ts\", \"**/*.tsx\"],\n\t\trules: {\n\t\t\t...pluginNext.configs.recommended.rules,\n\t\t},\n\t},\n];\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ESLintPlugin } from "./types.js";
|
|
2
|
+
export * from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Orchestrates and applies all registered plugin overrides to the loaded
|
|
5
|
+
* plugins.
|
|
6
|
+
*
|
|
7
|
+
* @param plugins - A map of loaded ESLint plugin instances.
|
|
8
|
+
*/
|
|
9
|
+
export declare function applyPatches(plugins: Record<string, ESLintPlugin>): void;
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/eslint/patches/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,cAAc,YAAY,CAAC;AAK3B;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,GAAG,IAAI,CAIxE"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { sonarjsPatch } from "./sonarjs.js";
|
|
2
|
+
export * from "./types.js";
|
|
3
|
+
// Registry of all custom plugin patches
|
|
4
|
+
const patches = [sonarjsPatch];
|
|
5
|
+
/**
|
|
6
|
+
* Orchestrates and applies all registered plugin overrides to the loaded
|
|
7
|
+
* plugins.
|
|
8
|
+
*
|
|
9
|
+
* @param plugins - A map of loaded ESLint plugin instances.
|
|
10
|
+
*/
|
|
11
|
+
export function applyPatches(plugins) {
|
|
12
|
+
for (const patch of patches) {
|
|
13
|
+
patch.apply(plugins);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/eslint/patches/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAG5C,cAAc,YAAY,CAAC;AAE3B,wCAAwC;AACxC,MAAM,OAAO,GAAG,CAAC,YAAY,CAAC,CAAC;AAE/B;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,OAAqC;IACjE,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;QAC7B,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACtB,CAAC;AACF,CAAC","sourcesContent":["import { sonarjsPatch } from \"./sonarjs.js\";\nimport type { ESLintPlugin } from \"./types.js\";\n\nexport * from \"./types.js\";\n\n// Registry of all custom plugin patches\nconst patches = [sonarjsPatch];\n\n/**\n * Orchestrates and applies all registered plugin overrides to the loaded\n * plugins.\n *\n * @param plugins - A map of loaded ESLint plugin instances.\n */\nexport function applyPatches(plugins: Record<string, ESLintPlugin>): void {\n\tfor (const patch of patches) {\n\t\tpatch.apply(plugins);\n\t}\n}\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ESLintPatch } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Patch for sonarjs/in-operator-type-error (S3785).
|
|
4
|
+
*
|
|
5
|
+
* The default rule uses a flat bitmask check on `type.flags` which causes:
|
|
6
|
+
*
|
|
7
|
+
* - False positives on unions of object types (ObjA | ObjB)
|
|
8
|
+
* - False positives on branded/intersection types (boolean & { brand: string })
|
|
9
|
+
*
|
|
10
|
+
* This patch replaces the rule's `create` method with a recursive type checker
|
|
11
|
+
* that correctly traverses union and intersection constituents.
|
|
12
|
+
*/
|
|
13
|
+
export declare const sonarjsPatch: ESLintPatch;
|
|
14
|
+
//# sourceMappingURL=sonarjs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sonarjs.d.ts","sourceRoot":"","sources":["../../../../src/eslint/patches/sonarjs.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACX,WAAW,EAGX,MAAM,YAAY,CAAC;AAEpB;;;;;;;;;;GAUG;AACH,eAAO,MAAM,YAAY,EAAE,WA2F1B,CAAC"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
/**
|
|
3
|
+
* Patch for sonarjs/in-operator-type-error (S3785).
|
|
4
|
+
*
|
|
5
|
+
* The default rule uses a flat bitmask check on `type.flags` which causes:
|
|
6
|
+
*
|
|
7
|
+
* - False positives on unions of object types (ObjA | ObjB)
|
|
8
|
+
* - False positives on branded/intersection types (boolean & { brand: string })
|
|
9
|
+
*
|
|
10
|
+
* This patch replaces the rule's `create` method with a recursive type checker
|
|
11
|
+
* that correctly traverses union and intersection constituents.
|
|
12
|
+
*/
|
|
13
|
+
export const sonarjsPatch = {
|
|
14
|
+
apply(plugins) {
|
|
15
|
+
const sonarjs = plugins.sonarjs;
|
|
16
|
+
if (!sonarjs?.rules) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const originalRule = sonarjs.rules["in-operator-type-error"];
|
|
20
|
+
if (!originalRule) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
sonarjs.rules["in-operator-type-error"] = {
|
|
24
|
+
...originalRule,
|
|
25
|
+
create(context) {
|
|
26
|
+
const services = context.sourceCode.parserServices;
|
|
27
|
+
if (!services?.program) {
|
|
28
|
+
return {};
|
|
29
|
+
}
|
|
30
|
+
const checker = services.program.getTypeChecker();
|
|
31
|
+
/**
|
|
32
|
+
* Recursively checks whether a TypeScript type is definitively
|
|
33
|
+
* primitive — i.e. it cannot safely be the right-hand operand of the
|
|
34
|
+
* `in` operator.
|
|
35
|
+
*
|
|
36
|
+
* - Unions: unsafe if _any_ constituent is primitive (could throw at
|
|
37
|
+
* runtime).
|
|
38
|
+
* - Intersections: unsafe only if _all_ constituents are primitive
|
|
39
|
+
* (object property on any constituent makes the runtime value an
|
|
40
|
+
* object, hence safe).
|
|
41
|
+
* - Leaf types: checked against the primitive TypeFlags bitmask.
|
|
42
|
+
*
|
|
43
|
+
* @param type - The TypeScript type to evaluate.
|
|
44
|
+
* @returns `true` if the type is definitely primitive, `false`
|
|
45
|
+
* otherwise.
|
|
46
|
+
*/
|
|
47
|
+
function isDefinitelyPrimitive(type) {
|
|
48
|
+
if (type.isUnion()) {
|
|
49
|
+
return type.types.some((t) => isDefinitelyPrimitive(t));
|
|
50
|
+
}
|
|
51
|
+
if (type.isIntersection()) {
|
|
52
|
+
return type.types.every((t) => isDefinitelyPrimitive(t));
|
|
53
|
+
}
|
|
54
|
+
return ((type.flags & ts.TypeFlags.StringLike) !== 0 ||
|
|
55
|
+
(type.flags & ts.TypeFlags.NumberLike) !== 0 ||
|
|
56
|
+
(type.flags & ts.TypeFlags.BooleanLike) !== 0 ||
|
|
57
|
+
(type.flags & ts.TypeFlags.Null) !== 0 ||
|
|
58
|
+
(type.flags & ts.TypeFlags.Undefined) !== 0 ||
|
|
59
|
+
(type.flags & ts.TypeFlags.BigIntLike) !== 0 ||
|
|
60
|
+
(type.flags & ts.TypeFlags.ESSymbol) !== 0 ||
|
|
61
|
+
(type.flags & ts.TypeFlags.UniqueESSymbol) !== 0);
|
|
62
|
+
}
|
|
63
|
+
return {
|
|
64
|
+
'BinaryExpression[operator="in"]'(node) {
|
|
65
|
+
const { right } = node;
|
|
66
|
+
const tsNode = services.esTreeNodeToTSNodeMap.get(right);
|
|
67
|
+
if (tsNode) {
|
|
68
|
+
const type = checker.getTypeAtLocation(tsNode);
|
|
69
|
+
if (isDefinitelyPrimitive(type)) {
|
|
70
|
+
context.report({
|
|
71
|
+
message: "TypeError can be thrown as this operand might have primitive type.",
|
|
72
|
+
node: right,
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
},
|
|
81
|
+
name: "sonarjs-S3785-patch",
|
|
82
|
+
};
|
|
83
|
+
//# sourceMappingURL=sonarjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sonarjs.js","sourceRoot":"","sources":["../../../../src/eslint/patches/sonarjs.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,YAAY,CAAC;AAQ5B;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,YAAY,GAAgB;IACxC,KAAK,CAAC,OAAqC;QAC1C,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;QAChC,IAAI,CAAC,OAAO,EAAE,KAAK,EAAE,CAAC;YACrB,OAAO;QACR,CAAC;QAED,MAAM,YAAY,GAAG,OAAO,CAAC,KAAK,CAAC,wBAAwB,CAAC,CAAC;QAC7D,IAAI,CAAC,YAAY,EAAE,CAAC;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GAAG,EAAE,CAAC,SAAS,CAAC,UAAU,CAAC,KAAK,CAAC;wBAC5C,CAAC,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC;wBAC1C,CAAC,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC,SAAS,CAAC,cAAc,CAAC,KAAK,CAAC,CAChD,CAAC;gBACH,CAAC;gBAUD,OAAO;oBACN,iCAAiC,CAAC,IAA0B;wBAC3D,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC;wBACvB,MAAM,MAAM,GAAG,QAAQ,CAAC,qBAAqB,CAAC,GAAG,CAChD,KAAkB,CAClB,CAAC;wBACF,IAAI,MAAM,EAAE,CAAC;4BACZ,MAAM,IAAI,GAAG,OAAO,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;4BAC/C,IAAI,qBAAqB,CAAC,IAAI,CAAC,EAAE,CAAC;gCACjC,OAAO,CAAC,MAAM,CAAC;oCACd,OAAO,EACN,oEAAoE;oCACrE,IAAI,EAAE,KAA6B;iCACnC,CAAC,CAAC;4BACJ,CAAC;wBACF,CAAC;oBACF,CAAC;iBACD,CAAC;YACH,CAAC;SACD,CAAC;IACH,CAAC;IAED,IAAI,EAAE,qBAAqB;CAC3B,CAAC","sourcesContent":["import type { Rule } from \"eslint\";\nimport ts from \"typescript\";\n\nimport type {\n\tESLintPatch,\n\tESLintPlugin,\n\tTypeAwareParserServices,\n} from \"./types.js\";\n\n/**\n * Patch for sonarjs/in-operator-type-error (S3785).\n *\n * The default rule uses a flat bitmask check on `type.flags` which causes:\n *\n * - False positives on unions of object types (ObjA | ObjB)\n * - False positives on branded/intersection types (boolean & { brand: string })\n *\n * This patch replaces the rule's `create` method with a recursive type checker\n * that correctly traverses union and intersection constituents.\n */\nexport const sonarjsPatch: ESLintPatch = {\n\tapply(plugins: Record<string, ESLintPlugin>): void {\n\t\tconst sonarjs = plugins.sonarjs;\n\t\tif (!sonarjs?.rules) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst originalRule = sonarjs.rules[\"in-operator-type-error\"];\n\t\tif (!originalRule) {\n\t\t\treturn;\n\t\t}\n\n\t\tsonarjs.rules[\"in-operator-type-error\"] = {\n\t\t\t...originalRule,\n\t\t\tcreate(context: Rule.RuleContext): Rule.RuleListener {\n\t\t\t\tconst services = context.sourceCode.parserServices as unknown as\n\t\t\t\t\t| TypeAwareParserServices\n\t\t\t\t\t| undefined;\n\t\t\t\tif (!services?.program) {\n\t\t\t\t\treturn {};\n\t\t\t\t}\n\n\t\t\t\tconst checker = services.program.getTypeChecker();\n\n\t\t\t\t/**\n\t\t\t\t * Recursively checks whether a TypeScript type is definitively\n\t\t\t\t * primitive — i.e. it cannot safely be the right-hand operand of the\n\t\t\t\t * `in` operator.\n\t\t\t\t *\n\t\t\t\t * - Unions: unsafe if _any_ constituent is primitive (could throw at\n\t\t\t\t * runtime).\n\t\t\t\t * - Intersections: unsafe only if _all_ constituents are primitive\n\t\t\t\t * (object property on any constituent makes the runtime value an\n\t\t\t\t * object, hence safe).\n\t\t\t\t * - Leaf types: checked against the primitive TypeFlags bitmask.\n\t\t\t\t *\n\t\t\t\t * @param type - The TypeScript type to evaluate.\n\t\t\t\t * @returns `true` if the type is definitely primitive, `false`\n\t\t\t\t * otherwise.\n\t\t\t\t */\n\t\t\t\tfunction isDefinitelyPrimitive(type: ts.Type): boolean {\n\t\t\t\t\tif (type.isUnion()) {\n\t\t\t\t\t\treturn type.types.some((t) => isDefinitelyPrimitive(t));\n\t\t\t\t\t}\n\t\t\t\t\tif (type.isIntersection()) {\n\t\t\t\t\t\treturn type.types.every((t) => isDefinitelyPrimitive(t));\n\t\t\t\t\t}\n\n\t\t\t\t\treturn (\n\t\t\t\t\t\t(type.flags & ts.TypeFlags.StringLike) !== 0 ||\n\t\t\t\t\t\t(type.flags & ts.TypeFlags.NumberLike) !== 0 ||\n\t\t\t\t\t\t(type.flags & ts.TypeFlags.BooleanLike) !== 0 ||\n\t\t\t\t\t\t(type.flags & ts.TypeFlags.Null) !== 0 ||\n\t\t\t\t\t\t(type.flags & ts.TypeFlags.Undefined) !== 0 ||\n\t\t\t\t\t\t(type.flags & ts.TypeFlags.BigIntLike) !== 0 ||\n\t\t\t\t\t\t(type.flags & ts.TypeFlags.ESSymbol) !== 0 ||\n\t\t\t\t\t\t(type.flags & ts.TypeFlags.UniqueESSymbol) !== 0\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\t// BinaryExpression node type is derived from Rule.NodeListener's own callback signature.\n\t\t\t\ttype BinaryExpressionNode =\n\t\t\t\t\tNonNullable<Rule.NodeListener[\"BinaryExpression\"]> extends (\n\t\t\t\t\t\tnode: infer N,\n\t\t\t\t\t) => void\n\t\t\t\t\t\t? N\n\t\t\t\t\t\t: never;\n\n\t\t\t\treturn {\n\t\t\t\t\t'BinaryExpression[operator=\"in\"]'(node: BinaryExpressionNode) {\n\t\t\t\t\t\tconst { right } = node;\n\t\t\t\t\t\tconst tsNode = services.esTreeNodeToTSNodeMap.get(\n\t\t\t\t\t\t\tright as Rule.Node,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif (tsNode) {\n\t\t\t\t\t\t\tconst type = checker.getTypeAtLocation(tsNode);\n\t\t\t\t\t\t\tif (isDefinitelyPrimitive(type)) {\n\t\t\t\t\t\t\t\tcontext.report({\n\t\t\t\t\t\t\t\t\tmessage:\n\t\t\t\t\t\t\t\t\t\t\"TypeError can be thrown as this operand might have primitive type.\",\n\t\t\t\t\t\t\t\t\tnode: right as unknown as Rule.Node,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t},\n\t\t};\n\t},\n\n\tname: \"sonarjs-S3785-patch\",\n};\n"]}
|