@ms-cloudpack/eslint-plugin 0.6.1 → 0.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/README.md +47 -52
- package/package.json +12 -21
- package/lib/configs/classic.d.ts +0 -9
- package/lib/configs/classic.d.ts.map +0 -1
- package/lib/configs/classic.js +0 -32
- package/lib/configs/classic.js.map +0 -1
- package/lib/configs/flat.d.ts +0 -4
- package/lib/configs/flat.d.ts.map +0 -1
- package/lib/configs/flat.js +0 -24
- package/lib/configs/flat.js.map +0 -1
- package/lib/flat.d.mts +0 -12
- package/lib/flat.d.mts.map +0 -1
- package/lib/flat.mjs +0 -8
- package/lib/flat.mjs.map +0 -1
- package/lib/index.d.ts +0 -13
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js +0 -10
- package/lib/index.js.map +0 -1
- package/lib/plugin.d.ts +0 -6
- package/lib/plugin.d.ts.map +0 -1
- package/lib/plugin.js +0 -19
- package/lib/plugin.js.map +0 -1
- package/lib/rules/no-test-exports.d.ts +0 -18
- package/lib/rules/no-test-exports.d.ts.map +0 -1
- package/lib/rules/no-test-exports.js +0 -133
- package/lib/rules/no-test-exports.js.map +0 -1
- package/lib/rules/no-unsupported-imports.d.ts +0 -14
- package/lib/rules/no-unsupported-imports.d.ts.map +0 -1
- package/lib/rules/no-unsupported-imports.js +0 -174
- package/lib/rules/no-unsupported-imports.js.map +0 -1
- package/lib/utils/PackageJson.d.ts +0 -43
- package/lib/utils/PackageJson.d.ts.map +0 -1
- package/lib/utils/PackageJson.js +0 -4
- package/lib/utils/PackageJson.js.map +0 -1
- package/lib/utils/createRule.d.ts +0 -41
- package/lib/utils/createRule.d.ts.map +0 -1
- package/lib/utils/createRule.js +0 -32
- package/lib/utils/createRule.js.map +0 -1
- package/lib/utils/getImportPathLiteralNode.d.ts +0 -11
- package/lib/utils/getImportPathLiteralNode.d.ts.map +0 -1
- package/lib/utils/getImportPathLiteralNode.js +0 -44
- package/lib/utils/getImportPathLiteralNode.js.map +0 -1
- package/lib/utils/getPackageInfo.d.ts +0 -16
- package/lib/utils/getPackageInfo.d.ts.map +0 -1
- package/lib/utils/getPackageInfo.js +0 -60
- package/lib/utils/getPackageInfo.js.map +0 -1
- package/lib/utils/getRegexpsFromStrings.d.ts +0 -6
- package/lib/utils/getRegexpsFromStrings.d.ts.map +0 -1
- package/lib/utils/getRegexpsFromStrings.js +0 -11
- package/lib/utils/getRegexpsFromStrings.js.map +0 -1
- package/lib/utils/testExports/extractIdentifiersFromExport.d.ts +0 -6
- package/lib/utils/testExports/extractIdentifiersFromExport.d.ts.map +0 -1
- package/lib/utils/testExports/extractIdentifiersFromExport.js +0 -57
- package/lib/utils/testExports/extractIdentifiersFromExport.js.map +0 -1
- package/lib/utils/testExports/isIncludedIndexFile.d.ts +0 -10
- package/lib/utils/testExports/isIncludedIndexFile.d.ts.map +0 -1
- package/lib/utils/testExports/isIncludedIndexFile.js +0 -27
- package/lib/utils/testExports/isIncludedIndexFile.js.map +0 -1
- package/lib/utils/unsupportedImports/parseImportIfRelevant.d.ts +0 -19
- package/lib/utils/unsupportedImports/parseImportIfRelevant.d.ts.map +0 -1
- package/lib/utils/unsupportedImports/parseImportIfRelevant.js +0 -39
- package/lib/utils/unsupportedImports/parseImportIfRelevant.js.map +0 -1
- package/lib/utils/unsupportedImports/pathSatisfiesAnyExport.d.ts +0 -8
- package/lib/utils/unsupportedImports/pathSatisfiesAnyExport.d.ts.map +0 -1
- package/lib/utils/unsupportedImports/pathSatisfiesAnyExport.js +0 -37
- package/lib/utils/unsupportedImports/pathSatisfiesAnyExport.js.map +0 -1
- package/lib/utils/unsupportedImports/resolvePackageRoot.d.ts +0 -7
- package/lib/utils/unsupportedImports/resolvePackageRoot.d.ts.map +0 -1
- package/lib/utils/unsupportedImports/resolvePackageRoot.js +0 -48
- package/lib/utils/unsupportedImports/resolvePackageRoot.js.map +0 -1
package/README.md
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
`@ms-cloudpack/eslint-plugin` provides a shared config and custom rules to help encourage Cloudpack-friendly coding practices, specifically regarding imports and exports.
|
|
4
4
|
|
|
5
|
+
## Breaking changes in 0.7.0
|
|
6
|
+
|
|
7
|
+
As of 0.7.0, the plugin supports **flat config only.** Previous imports of `@ms-cloudpack/eslint-plugin/flat` should be updated to `@ms-cloudpack/eslint-plugin`.
|
|
8
|
+
|
|
9
|
+
Also, you must reference `@typescript-eslint` and `@rnx-kit` in your own config as described below.
|
|
10
|
+
|
|
5
11
|
## Included configs
|
|
6
12
|
|
|
7
13
|
This plugin includes the following configs:
|
|
@@ -20,26 +26,29 @@ This plugin includes the following configs:
|
|
|
20
26
|
|
|
21
27
|
### Using a config
|
|
22
28
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
29
|
+
(If you only want individual rules, see [enabling rules](#enabling-rules) below.)
|
|
30
|
+
|
|
31
|
+
Install peers: `@rnx-kit/eslint-plugin typescript-eslint typescript eslint`
|
|
32
|
+
|
|
33
|
+
If using a config **NOT requiring type checking**:
|
|
34
|
+
|
|
35
|
+
```js
|
|
36
|
+
import defineConfig from 'eslint/config';
|
|
37
|
+
import tseslint from 'typescript-eslint';
|
|
38
|
+
import cloudpack from '@ms-cloudpack/eslint-plugin';
|
|
39
|
+
import rnxKit from '@rnx-kit/eslint-plugin';
|
|
40
|
+
|
|
41
|
+
export default defineConfig(
|
|
42
|
+
// Reference any typescript-eslint config, which will define the @typescript-eslint plugin
|
|
43
|
+
tseslint.configs.base,
|
|
44
|
+
// Define the @rnx-kit plugin
|
|
45
|
+
{ plugins: { '@rnx-kit': rnxKit } },
|
|
46
|
+
// Reference the cloudpack plugin config
|
|
47
|
+
cloudpack.configs.recommended,
|
|
48
|
+
);
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
If using a config **requiring type checking**, see the instructions for [linting with type information](https://typescript-eslint.io/linting/typed-linting) and add that setup to the beginning of the config above.
|
|
43
52
|
|
|
44
53
|
## Included rules
|
|
45
54
|
|
|
@@ -53,38 +62,24 @@ This plugin includes the following configs:
|
|
|
53
62
|
|
|
54
63
|
### Enabling rules
|
|
55
64
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
import cloudpack from '@ms-cloudpack/eslint-plugin';
|
|
75
|
-
// If you're also extending a config, import from here instead:
|
|
76
|
-
// import cloudpack from '@ms-cloudpack/eslint-plugin/flat';
|
|
77
|
-
|
|
78
|
-
export default tseslint.config({
|
|
79
|
-
plugins: {
|
|
80
|
-
// Omit if extending a config (the configs already include this)
|
|
81
|
-
'@ms-cloudpack': cloudpack,
|
|
82
|
-
},
|
|
83
|
-
rules: {
|
|
84
|
-
'@ms-cloudpack/rule-name-here': 'error',
|
|
85
|
-
},
|
|
86
|
-
});
|
|
87
|
-
```
|
|
65
|
+
Install peers: `typescript-eslint eslint typescript`
|
|
66
|
+
|
|
67
|
+
Reference the plugin and enable the rules:
|
|
68
|
+
|
|
69
|
+
```js
|
|
70
|
+
import defineConfig from 'eslint/config';
|
|
71
|
+
import cloudpack from '@ms-cloudpack/eslint-plugin';
|
|
72
|
+
|
|
73
|
+
export default defineConfig({
|
|
74
|
+
plugins: {
|
|
75
|
+
// Omit if extending a config (the configs already include this)
|
|
76
|
+
'@ms-cloudpack': cloudpack,
|
|
77
|
+
},
|
|
78
|
+
rules: {
|
|
79
|
+
'@ms-cloudpack/rule-name-here': 'error',
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
```
|
|
88
83
|
|
|
89
84
|
### `no-test-exports`
|
|
90
85
|
|
package/package.json
CHANGED
|
@@ -1,19 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ms-cloudpack/eslint-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "A set of ESLint rules for Cloudpack",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"type": "
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"types": "./lib/index.d.ts",
|
|
11
|
-
"default": "./lib/index.js"
|
|
12
|
-
},
|
|
13
|
-
"./flat": {
|
|
14
|
-
"types": "./lib/flat.d.mts",
|
|
15
|
-
"import": "./lib/flat.mjs"
|
|
16
|
-
}
|
|
6
|
+
"type": "module",
|
|
7
|
+
"exports": "./src/index.ts",
|
|
8
|
+
"engines": {
|
|
9
|
+
"node": ">=22.18.0"
|
|
17
10
|
},
|
|
18
11
|
"scripts": {
|
|
19
12
|
"build:watch": "cloudpack-scripts build-watch",
|
|
@@ -24,14 +17,14 @@
|
|
|
24
17
|
"test": "cloudpack-scripts test"
|
|
25
18
|
},
|
|
26
19
|
"dependencies": {
|
|
20
|
+
"@typescript-eslint/utils": "^8.0.0",
|
|
27
21
|
"resolve": "^1.22.0"
|
|
28
22
|
},
|
|
29
23
|
"peerDependencies": {
|
|
30
|
-
"@rnx-kit/eslint-plugin": "^0.9.
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"eslint": "^8.0.0
|
|
34
|
-
"typescript": ">=5.0.0"
|
|
24
|
+
"@rnx-kit/eslint-plugin": "^0.9.9",
|
|
25
|
+
"eslint": "^8.0.0 || ^9.0.0 || ^10.0.0",
|
|
26
|
+
"typescript": ">=5.0.0",
|
|
27
|
+
"typescript-eslint": "^8.0.0"
|
|
35
28
|
},
|
|
36
29
|
"peerDependenciesMeta": {
|
|
37
30
|
"@rnx-kit/eslint-plugin": {
|
|
@@ -39,15 +32,13 @@
|
|
|
39
32
|
}
|
|
40
33
|
},
|
|
41
34
|
"devDependencies": {
|
|
42
|
-
"@ms-cloudpack/eslint-plugin-internal": "^0.0.1",
|
|
43
35
|
"@ms-cloudpack/scripts": "^0.0.1",
|
|
44
36
|
"@ms-cloudpack/test-utilities": "^0.5.0",
|
|
45
|
-
"@rnx-kit/eslint-plugin": "^0.9.
|
|
46
|
-
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
|
37
|
+
"@rnx-kit/eslint-plugin": "^0.9.9",
|
|
47
38
|
"@typescript-eslint/parser": "^8.0.0",
|
|
48
39
|
"@typescript-eslint/rule-tester": "^8.0.0",
|
|
49
|
-
"@typescript-eslint/utils": "^8.0.0",
|
|
50
40
|
"eslint": "^9.0.0",
|
|
41
|
+
"eslint-plugin-eslint-plugin": "^7.3.3",
|
|
51
42
|
"typescript": "~5.9.0"
|
|
52
43
|
},
|
|
53
44
|
"files": [
|
package/lib/configs/classic.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { TSESLint } from '@typescript-eslint/utils';
|
|
2
|
-
export type CloudpackClassicConfig = Required<Pick<TSESLint.ClassicConfig.Config, 'plugins' | 'rules'>>;
|
|
3
|
-
export declare const configs: {
|
|
4
|
-
recommended: Required<Pick<TSESLint.ClassicConfig.Config, "rules" | "plugins">>;
|
|
5
|
-
'recommended-requiring-type-checking': Required<Pick<TSESLint.ClassicConfig.Config, "rules" | "plugins">>;
|
|
6
|
-
onboarding: Required<Pick<TSESLint.ClassicConfig.Config, "rules" | "plugins">>;
|
|
7
|
-
'onboarding-requiring-type-checking': Required<Pick<TSESLint.ClassicConfig.Config, "rules" | "plugins">>;
|
|
8
|
-
};
|
|
9
|
-
//# sourceMappingURL=classic.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"classic.d.ts","sourceRoot":"","sources":["../../src/configs/classic.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAEzD,MAAM,MAAM,sBAAsB,GAAG,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,CAAC,CAAC;AA0BxG,eAAO,MAAM,OAAO;;;;;CAKnB,CAAC"}
|
package/lib/configs/classic.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.configs = void 0;
|
|
4
|
-
function makeConfig(level) {
|
|
5
|
-
return {
|
|
6
|
-
plugins: ['@ms-cloudpack', '@rnx-kit', '@typescript-eslint'],
|
|
7
|
-
rules: {
|
|
8
|
-
'@ms-cloudpack/no-unsupported-imports': level,
|
|
9
|
-
'@rnx-kit/no-const-enum': level,
|
|
10
|
-
'@rnx-kit/no-export-all': level,
|
|
11
|
-
},
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
function makeTypeCheckedConfig(level) {
|
|
15
|
-
const baseConfig = makeConfig(level);
|
|
16
|
-
return {
|
|
17
|
-
...baseConfig,
|
|
18
|
-
rules: {
|
|
19
|
-
...baseConfig.rules,
|
|
20
|
-
'@typescript-eslint/consistent-type-imports': level,
|
|
21
|
-
'@typescript-eslint/consistent-type-exports': level,
|
|
22
|
-
'@typescript-eslint/no-import-type-side-effects': level,
|
|
23
|
-
},
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
exports.configs = {
|
|
27
|
-
recommended: makeConfig('error'),
|
|
28
|
-
'recommended-requiring-type-checking': makeTypeCheckedConfig('error'),
|
|
29
|
-
onboarding: makeConfig('warn'),
|
|
30
|
-
'onboarding-requiring-type-checking': makeTypeCheckedConfig('warn'),
|
|
31
|
-
};
|
|
32
|
-
//# sourceMappingURL=classic.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"classic.js","sourceRoot":"","sources":["../../src/configs/classic.ts"],"names":[],"mappings":";;;AAIA,SAAS,UAAU,CAAC,KAAuB;IACzC,OAAO;QACL,OAAO,EAAE,CAAC,eAAe,EAAE,UAAU,EAAE,oBAAoB,CAAC;QAC5D,KAAK,EAAE;YACL,sCAAsC,EAAE,KAAK;YAC7C,wBAAwB,EAAE,KAAK;YAC/B,wBAAwB,EAAE,KAAK;SAChC;KACF,CAAC;AACJ,CAAC;AAED,SAAS,qBAAqB,CAAC,KAAuB;IACpD,MAAM,UAAU,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC;IACrC,OAAO;QACL,GAAG,UAAU;QACb,KAAK,EAAE;YACL,GAAG,UAAU,CAAC,KAAK;YACnB,4CAA4C,EAAE,KAAK;YACnD,4CAA4C,EAAE,KAAK;YACnD,gDAAgD,EAAE,KAAK;SACxD;KACF,CAAC;AACJ,CAAC;AAEY,QAAA,OAAO,GAAG;IACrB,WAAW,EAAE,UAAU,CAAC,OAAO,CAAC;IAChC,qCAAqC,EAAE,qBAAqB,CAAC,OAAO,CAAC;IACrE,UAAU,EAAE,UAAU,CAAC,MAAM,CAAC;IAC9B,oCAAoC,EAAE,qBAAqB,CAAC,MAAM,CAAC;CACpE,CAAC","sourcesContent":["import type { TSESLint } from '@typescript-eslint/utils';\n\nexport type CloudpackClassicConfig = Required<Pick<TSESLint.ClassicConfig.Config, 'plugins' | 'rules'>>;\n\nfunction makeConfig(level: 'error' | 'warn'): CloudpackClassicConfig {\n return {\n plugins: ['@ms-cloudpack', '@rnx-kit', '@typescript-eslint'],\n rules: {\n '@ms-cloudpack/no-unsupported-imports': level,\n '@rnx-kit/no-const-enum': level,\n '@rnx-kit/no-export-all': level,\n },\n };\n}\n\nfunction makeTypeCheckedConfig(level: 'error' | 'warn'): CloudpackClassicConfig {\n const baseConfig = makeConfig(level);\n return {\n ...baseConfig,\n rules: {\n ...baseConfig.rules,\n '@typescript-eslint/consistent-type-imports': level,\n '@typescript-eslint/consistent-type-exports': level,\n '@typescript-eslint/no-import-type-side-effects': level,\n },\n };\n}\n\nexport const configs = {\n recommended: makeConfig('error'),\n 'recommended-requiring-type-checking': makeTypeCheckedConfig('error'),\n onboarding: makeConfig('warn'),\n 'onboarding-requiring-type-checking': makeTypeCheckedConfig('warn'),\n};\n"]}
|
package/lib/configs/flat.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"flat.d.ts","sourceRoot":"","sources":["../../src/configs/flat.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,OAAO,IAAI,cAAc,EAA+B,MAAM,WAAW,CAAC;AACnF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAgBzD,eAAO,MAAM,OAAO,EAEf,GACF,CAAC,IAAI,MAAM,OAAO,cAAc,GAAG,QAAQ,CAAC,UAAU,CAAC,MAAM,GAC/D,CAAC"}
|
package/lib/configs/flat.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.configs = void 0;
|
|
4
|
-
// @ts-expect-error -- missing types but we know it's a plugin
|
|
5
|
-
const rnxKit = require("@rnx-kit/eslint-plugin");
|
|
6
|
-
const tseslint = require("@typescript-eslint/eslint-plugin");
|
|
7
|
-
const parser = require("@typescript-eslint/parser");
|
|
8
|
-
const plugin_1 = require("../plugin");
|
|
9
|
-
const classic_1 = require("./classic");
|
|
10
|
-
function makeFlatConfig(name, classicConfig) {
|
|
11
|
-
return {
|
|
12
|
-
name: `@ms-cloudpack/${name}`,
|
|
13
|
-
plugins: {
|
|
14
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
15
|
-
'@rnx-kit': rnxKit,
|
|
16
|
-
'@ms-cloudpack': plugin_1.basePlugin,
|
|
17
|
-
'@typescript-eslint': tseslint,
|
|
18
|
-
},
|
|
19
|
-
languageOptions: { parser },
|
|
20
|
-
rules: { ...classicConfig.rules },
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
exports.configs = Object.fromEntries(Object.entries(classic_1.configs).map(([name, classicConfig]) => [name, makeFlatConfig(name, classicConfig)]));
|
|
24
|
-
//# sourceMappingURL=flat.js.map
|
package/lib/configs/flat.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"flat.js","sourceRoot":"","sources":["../../src/configs/flat.ts"],"names":[],"mappings":";;;AAAA,8DAA8D;AAC9D,iDAAiD;AACjD,6DAA6D;AAC7D,oDAAoD;AACpD,sCAAuC;AACvC,uCAAmF;AAGnF,SAAS,cAAc,CAAC,IAAY,EAAE,aAAqC;IACzE,OAAO;QACL,IAAI,EAAE,iBAAiB,IAAI,EAAE;QAC7B,OAAO,EAAE;YACP,mEAAmE;YACnE,UAAU,EAAE,MAAM;YAClB,eAAe,EAAE,mBAAU;YAC3B,oBAAoB,EAAE,QAAQ;SAC/B;QACD,eAAe,EAAE,EAAE,MAAM,EAAE;QAC3B,KAAK,EAAE,EAAE,GAAG,aAAa,CAAC,KAAK,EAAE;KAClC,CAAC;AACJ,CAAC;AAEY,QAAA,OAAO,GAAG,MAAM,CAAC,WAAW,CACvC,MAAM,CAAC,OAAO,CAAC,iBAAc,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,aAAa,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,cAAc,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC,CAG3G,CAAC","sourcesContent":["// @ts-expect-error -- missing types but we know it's a plugin\nimport * as rnxKit from '@rnx-kit/eslint-plugin';\nimport * as tseslint from '@typescript-eslint/eslint-plugin';\nimport * as parser from '@typescript-eslint/parser';\nimport { basePlugin } from '../plugin';\nimport { configs as classicConfigs, type CloudpackClassicConfig } from './classic';\nimport type { TSESLint } from '@typescript-eslint/utils';\n\nfunction makeFlatConfig(name: string, classicConfig: CloudpackClassicConfig): TSESLint.FlatConfig.Config {\n return {\n name: `@ms-cloudpack/${name}`,\n plugins: {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n '@rnx-kit': rnxKit,\n '@ms-cloudpack': basePlugin,\n '@typescript-eslint': tseslint,\n },\n languageOptions: { parser },\n rules: { ...classicConfig.rules },\n };\n}\n\nexport const configs = Object.fromEntries(\n Object.entries(classicConfigs).map(([name, classicConfig]) => [name, makeFlatConfig(name, classicConfig)]),\n) as {\n [k in keyof typeof classicConfigs]: TSESLint.FlatConfig.Config;\n};\n"]}
|
package/lib/flat.d.mts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
declare const plugin: {
|
|
2
|
-
configs: {
|
|
3
|
-
recommended: import("@typescript-eslint/utils/ts-eslint").FlatConfig.Config;
|
|
4
|
-
'recommended-requiring-type-checking': import("@typescript-eslint/utils/ts-eslint").FlatConfig.Config;
|
|
5
|
-
onboarding: import("@typescript-eslint/utils/ts-eslint").FlatConfig.Config;
|
|
6
|
-
'onboarding-requiring-type-checking': import("@typescript-eslint/utils/ts-eslint").FlatConfig.Config;
|
|
7
|
-
};
|
|
8
|
-
meta: { [K in keyof import("@typescript-eslint/utils/ts-eslint").FlatConfig.PluginMeta]?: import("@typescript-eslint/utils/ts-eslint").FlatConfig.PluginMeta[K] | undefined; };
|
|
9
|
-
rules: Record<string, import("@typescript-eslint/utils/ts-eslint").LooseRuleDefinition>;
|
|
10
|
-
};
|
|
11
|
-
export default plugin;
|
|
12
|
-
//# sourceMappingURL=flat.d.mts.map
|
package/lib/flat.d.mts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"flat.d.mts","sourceRoot":"","sources":["../src/flat.mts"],"names":[],"mappings":"AAGA,QAAA,MAAM,MAAM;;;;;;;2FAK68J,CAAC;;CAFz9J,CAAC;AACF,eAAe,MAAM,CAAC"}
|
package/lib/flat.mjs
DELETED
package/lib/flat.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"flat.mjs","sourceRoot":"","sources":["../src/flat.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,MAAM,MAAM,GAAG;IACb,GAAG,UAAU;IACb,OAAO;CACR,CAAC;AACF,eAAe,MAAM,CAAC","sourcesContent":["import { configs } from './configs/flat.js';\nimport { basePlugin } from './plugin.js';\n\nconst plugin = {\n ...basePlugin,\n configs,\n};\nexport default plugin;\n"]}
|
package/lib/index.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
declare const plugin: {
|
|
2
|
-
/** DO NOT use these for flat config! Import from `@ms-cloudpack/eslint-plugin/flat` instead. */
|
|
3
|
-
configs: {
|
|
4
|
-
recommended: Required<Pick<import("@typescript-eslint/utils/ts-eslint").ClassicConfig.Config, "rules" | "plugins">>;
|
|
5
|
-
'recommended-requiring-type-checking': Required<Pick<import("@typescript-eslint/utils/ts-eslint").ClassicConfig.Config, "rules" | "plugins">>;
|
|
6
|
-
onboarding: Required<Pick<import("@typescript-eslint/utils/ts-eslint").ClassicConfig.Config, "rules" | "plugins">>;
|
|
7
|
-
'onboarding-requiring-type-checking': Required<Pick<import("@typescript-eslint/utils/ts-eslint").ClassicConfig.Config, "rules" | "plugins">>;
|
|
8
|
-
};
|
|
9
|
-
meta: { [K in keyof import("@typescript-eslint/utils/ts-eslint").FlatConfig.PluginMeta]?: import("@typescript-eslint/utils/ts-eslint").FlatConfig.PluginMeta[K] | undefined; };
|
|
10
|
-
rules: Record<string, import("@typescript-eslint/utils/ts-eslint").LooseRuleDefinition>;
|
|
11
|
-
};
|
|
12
|
-
export = plugin;
|
|
13
|
-
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,QAAA,MAAM,MAAM;IAEV,gGAAgG;;;;;;;2FAKwuJ,CAAC;;CAH10J,CAAC;AAEF,SAAS,MAAM,CAAC"}
|
package/lib/index.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
const classic_1 = require("./configs/classic");
|
|
3
|
-
const plugin_1 = require("./plugin");
|
|
4
|
-
const plugin = {
|
|
5
|
-
...plugin_1.basePlugin,
|
|
6
|
-
/** DO NOT use these for flat config! Import from `@ms-cloudpack/eslint-plugin/flat` instead. */
|
|
7
|
-
configs: classic_1.configs,
|
|
8
|
-
};
|
|
9
|
-
module.exports = plugin;
|
|
10
|
-
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,+CAA4C;AAC5C,qCAAsC;AAEtC,MAAM,MAAM,GAAG;IACb,GAAG,mBAAU;IACb,gGAAgG;IAChG,OAAO,EAAP,iBAAO;CACR,CAAC;AAEF,iBAAS,MAAM,CAAC","sourcesContent":["import { configs } from './configs/classic';\nimport { basePlugin } from './plugin';\n\nconst plugin = {\n ...basePlugin,\n /** DO NOT use these for flat config! Import from `@ms-cloudpack/eslint-plugin/flat` instead. */\n configs,\n};\n// This export format is required for ESLint plugins\nexport = plugin;\n"]}
|
package/lib/plugin.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { TSESLint } from '@typescript-eslint/utils';
|
|
2
|
-
/**
|
|
3
|
-
* Plugin metadata and rules. Omits the configs to avoid circular dependencies.
|
|
4
|
-
*/
|
|
5
|
-
export declare const basePlugin: Required<Pick<TSESLint.FlatConfig.Plugin, 'meta' | 'rules'>>;
|
|
6
|
-
//# sourceMappingURL=plugin.d.ts.map
|
package/lib/plugin.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AASzD;;GAEG;AACH,eAAO,MAAM,UAAU,EAAE,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,CAMnF,CAAC"}
|
package/lib/plugin.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.basePlugin = void 0;
|
|
4
|
-
const fs = require("fs");
|
|
5
|
-
const path = require("path");
|
|
6
|
-
const no_test_exports_1 = require("./rules/no-test-exports");
|
|
7
|
-
const no_unsupported_imports_1 = require("./rules/no-unsupported-imports");
|
|
8
|
-
const { name, version } = JSON.parse(fs.readFileSync(path.resolve(__dirname, '../package.json'), 'utf8'));
|
|
9
|
-
/**
|
|
10
|
-
* Plugin metadata and rules. Omits the configs to avoid circular dependencies.
|
|
11
|
-
*/
|
|
12
|
-
exports.basePlugin = {
|
|
13
|
-
meta: { name, version },
|
|
14
|
-
rules: {
|
|
15
|
-
'no-test-exports': no_test_exports_1.rule,
|
|
16
|
-
'no-unsupported-imports': no_unsupported_imports_1.rule,
|
|
17
|
-
},
|
|
18
|
-
};
|
|
19
|
-
//# sourceMappingURL=plugin.js.map
|
package/lib/plugin.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":";;;AAAA,yBAAyB;AACzB,6BAA6B;AAE7B,6DAAgE;AAChE,2EAA8E;AAE9E,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,iBAAiB,CAAC,EAAE,MAAM,CAAC,CAGvG,CAAC;AAEF;;GAEG;AACU,QAAA,UAAU,GAAiE;IACtF,IAAI,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE;IACvB,KAAK,EAAE;QACL,iBAAiB,EAAE,sBAAa;QAChC,wBAAwB,EAAE,6BAAoB;KAC/C;CACF,CAAC","sourcesContent":["import * as fs from 'fs';\nimport * as path from 'path';\nimport type { TSESLint } from '@typescript-eslint/utils';\nimport { rule as noTestExports } from './rules/no-test-exports';\nimport { rule as noUnsupportedImports } from './rules/no-unsupported-imports';\n\nconst { name, version } = JSON.parse(fs.readFileSync(path.resolve(__dirname, '../package.json'), 'utf8')) as {\n name: string;\n version: string;\n};\n\n/**\n * Plugin metadata and rules. Omits the configs to avoid circular dependencies.\n */\nexport const basePlugin: Required<Pick<TSESLint.FlatConfig.Plugin, 'meta' | 'rules'>> = {\n meta: { name, version },\n rules: {\n 'no-test-exports': noTestExports,\n 'no-unsupported-imports': noUnsupportedImports,\n },\n};\n"]}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/** Rule options as specified in the config */
|
|
2
|
-
export type RuleOptions = {
|
|
3
|
-
testPathPatterns?: string[];
|
|
4
|
-
testExportNamePatterns?: string[];
|
|
5
|
-
maxDepth?: number;
|
|
6
|
-
};
|
|
7
|
-
export declare const defaultTestPaths: RegExp[];
|
|
8
|
-
export declare const defaultMaxDepth: number;
|
|
9
|
-
/** Error message IDs corresponding to `rule.meta.messages` */
|
|
10
|
-
export type MessageIds = 'invalidPath' | 'invalidName';
|
|
11
|
-
/** Error data `{{substitutions}}` used in messages */
|
|
12
|
-
export type ErrorData = {
|
|
13
|
-
extension: string;
|
|
14
|
-
invalidPath?: string;
|
|
15
|
-
invalidName?: string;
|
|
16
|
-
};
|
|
17
|
-
export declare const rule: import("../utils/createRule").RuleModule<RuleOptions, MessageIds>;
|
|
18
|
-
//# sourceMappingURL=no-test-exports.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"no-test-exports.d.ts","sourceRoot":"","sources":["../../src/rules/no-test-exports.ts"],"names":[],"mappings":"AAQA,8CAA8C;AAC9C,MAAM,MAAM,WAAW,GAAG;IACxB,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC5B,sBAAsB,CAAC,EAAE,MAAM,EAAE,CAAC;IAClC,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAaF,eAAO,MAAM,gBAAgB,EAAE,MAAM,EAKpC,CAAC;AAGF,eAAO,MAAM,eAAe,QAAW,CAAC;AAExC,8DAA8D;AAC9D,MAAM,MAAM,UAAU,GAAG,aAAa,GAAG,aAAa,CAAC;AAEvD,sDAAsD;AACtD,MAAM,MAAM,SAAS,GAAG;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAIF,eAAO,MAAM,IAAI,mEA+Ef,CAAC"}
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.rule = exports.defaultMaxDepth = exports.defaultTestPaths = void 0;
|
|
4
|
-
const path = require("path");
|
|
5
|
-
const getImportPathLiteralNode_1 = require("../utils/getImportPathLiteralNode");
|
|
6
|
-
const extractIdentifiersFromExport_1 = require("../utils/testExports/extractIdentifiersFromExport");
|
|
7
|
-
const getRegexpsFromStrings_1 = require("../utils/getRegexpsFromStrings");
|
|
8
|
-
const isIncludedIndexFile_1 = require("../utils/testExports/isIncludedIndexFile");
|
|
9
|
-
const createRule_1 = require("../utils/createRule");
|
|
10
|
-
exports.defaultTestPaths = [
|
|
11
|
-
// Only match lowercase mock|test|fixture at the beginning of an import path segment to avoid false positives
|
|
12
|
-
/\/(__)?(mock|test|fixture)/,
|
|
13
|
-
/\.(mock|test|fixture)s?(\.\w+)?$/,
|
|
14
|
-
/Mock|Test|Fixture/,
|
|
15
|
-
];
|
|
16
|
-
// Only match lowercase mock|test|fixture at the beginning of an export name to avoid false positives
|
|
17
|
-
const defaultTestExportNames = [/^(mock|test|fixture)/, /Mock|Test|Fixture/];
|
|
18
|
-
exports.defaultMaxDepth = Infinity;
|
|
19
|
-
const separateFileMessage = 'use a separate file such as index.mock.{{extension}} instead';
|
|
20
|
-
exports.rule = (0, createRule_1.createRule)({
|
|
21
|
-
name: 'no-test-exports',
|
|
22
|
-
meta: {
|
|
23
|
-
type: 'problem',
|
|
24
|
-
docs: {
|
|
25
|
-
description: 'ban test, mock, and fixture exports from index files',
|
|
26
|
-
},
|
|
27
|
-
messages: {
|
|
28
|
-
invalidPath: 'Contents of test-related path "{{invalidPath}}" should not be referenced from an index file; ' +
|
|
29
|
-
separateFileMessage,
|
|
30
|
-
invalidName: '"{{invalidName}}" appears to be test-related and should not be exported from an index file; ' +
|
|
31
|
-
separateFileMessage,
|
|
32
|
-
},
|
|
33
|
-
schema: [
|
|
34
|
-
{
|
|
35
|
-
type: 'object',
|
|
36
|
-
properties: {
|
|
37
|
-
testPathPatterns: {
|
|
38
|
-
type: 'array',
|
|
39
|
-
description: 'Ban exports from these paths (regex) from index files. Use "..." to include the default paths.',
|
|
40
|
-
items: { type: 'string' },
|
|
41
|
-
},
|
|
42
|
-
testExportNamePatterns: {
|
|
43
|
-
type: 'array',
|
|
44
|
-
description: 'Ban exports with these names (regex) from index files. Use "..." to include the default names.',
|
|
45
|
-
items: { type: 'string' },
|
|
46
|
-
},
|
|
47
|
-
maxDepth: {
|
|
48
|
-
type: 'number',
|
|
49
|
-
description: 'Maximum depth of index file (0-indexed; default Infinity)',
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
additionalProperties: false,
|
|
53
|
-
},
|
|
54
|
-
],
|
|
55
|
-
},
|
|
56
|
-
create: (ruleContext) => {
|
|
57
|
-
const options = ruleContext.options[0] || {};
|
|
58
|
-
const testPathPatterns = (0, getRegexpsFromStrings_1.getRegexpsFromStrings)(options.testPathPatterns, exports.defaultTestPaths);
|
|
59
|
-
const testExportNamePatterns = (0, getRegexpsFromStrings_1.getRegexpsFromStrings)(options.testExportNamePatterns, defaultTestExportNames);
|
|
60
|
-
const maxDepth = options.maxDepth ?? exports.defaultMaxDepth;
|
|
61
|
-
const extension = path.extname(ruleContext.filename).slice(1);
|
|
62
|
-
if (!(0, isIncludedIndexFile_1.isIncludedIndexFile)({ filename: ruleContext.filename, ignorePaths: testPathPatterns, maxDepth })) {
|
|
63
|
-
return {};
|
|
64
|
-
}
|
|
65
|
-
const context = { ruleContext, testExportNamePatterns, testPathPatterns, extension };
|
|
66
|
-
return {
|
|
67
|
-
// import foo from 'foo'
|
|
68
|
-
// import * as foo from 'foo'
|
|
69
|
-
// import { foo } from 'foo'
|
|
70
|
-
// import { foo as bar } from 'foo'
|
|
71
|
-
// import 'foo'
|
|
72
|
-
ImportDeclaration: (node) => checkNode(context, node),
|
|
73
|
-
// import foo = require('foo')
|
|
74
|
-
TSImportEqualsDeclaration: (node) => {
|
|
75
|
-
// Skip "export import foo = require('foo')" because that will be handled by ExportNamedDeclaration
|
|
76
|
-
if (node.parent.type !== 'ExportNamedDeclaration') {
|
|
77
|
-
checkNode(context, node);
|
|
78
|
-
}
|
|
79
|
-
},
|
|
80
|
-
// export { foo }
|
|
81
|
-
// export { foo } from 'foo'
|
|
82
|
-
// export { foo as bar } from 'foo'
|
|
83
|
-
// export import foo = require('foo')
|
|
84
|
-
// export const foo = 'foo';
|
|
85
|
-
// and other exported declarations
|
|
86
|
-
ExportNamedDeclaration: (node) => checkNode(context, node),
|
|
87
|
-
// export * from 'foo'
|
|
88
|
-
// export * as foo from 'foo'
|
|
89
|
-
ExportAllDeclaration: (node) => checkNode(context, node),
|
|
90
|
-
};
|
|
91
|
-
},
|
|
92
|
-
});
|
|
93
|
-
/** Check an import or export node for violations. */
|
|
94
|
-
function checkNode(context, node) {
|
|
95
|
-
const hasInvalidPath = checkInvalidPath(context, node);
|
|
96
|
-
// Invalid path errors take precedence, to avoid spamming errors.
|
|
97
|
-
if (!hasInvalidPath && (node.type === 'ExportAllDeclaration' || node.type === 'ExportNamedDeclaration')) {
|
|
98
|
-
checkInvalidName(context, node);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Check an import or export for invalid paths.
|
|
103
|
-
* Returns true if a violation was found.
|
|
104
|
-
*/
|
|
105
|
-
function checkInvalidPath(context, node) {
|
|
106
|
-
const { ruleContext, testPathPatterns, extension } = context;
|
|
107
|
-
// If there's an import path, check it
|
|
108
|
-
const { importPath, pathNode } = (0, getImportPathLiteralNode_1.getImportPathLiteralNode)(node) || {};
|
|
109
|
-
if (importPath && pathNode && testPathPatterns.some((re) => re.test(importPath))) {
|
|
110
|
-
ruleContext.report({
|
|
111
|
-
node: pathNode,
|
|
112
|
-
messageId: 'invalidPath',
|
|
113
|
-
data: { extension, invalidPath: importPath },
|
|
114
|
-
});
|
|
115
|
-
return true;
|
|
116
|
-
}
|
|
117
|
-
return false;
|
|
118
|
-
}
|
|
119
|
-
/** Check an export for invalid names. */
|
|
120
|
-
function checkInvalidName(context, node) {
|
|
121
|
-
const { ruleContext, testExportNamePatterns, extension } = context;
|
|
122
|
-
const ids = (0, extractIdentifiersFromExport_1.extractIdentifiersFromExport)(node);
|
|
123
|
-
for (const id of ids) {
|
|
124
|
-
if (testExportNamePatterns.some((re) => re.test(id.name))) {
|
|
125
|
-
ruleContext.report({
|
|
126
|
-
node: id,
|
|
127
|
-
messageId: 'invalidName',
|
|
128
|
-
data: { extension, invalidName: id.name },
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
//# sourceMappingURL=no-test-exports.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"no-test-exports.js","sourceRoot":"","sources":["../../src/rules/no-test-exports.ts"],"names":[],"mappings":";;;AACA,6BA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AC;IAE/C,KAAK,MAAM,EAAE,IAAI,GAAG,EAAE,CAAC;QACrB,IAAI,sBAAsB,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC;YAC1D,WAAW,CAAC,MAAM,CAAC;gBACjB,IAAI,EAAE,EAAE;gBACR,SAAS,EAAE,aAAa;gBACxB,IAAI,EAAE,EAAE,SAAS,EAAE,WAAW,EAAE,EAAE,CAAC,IAAI,EAAE;aAC1C,CAAC,CAAC;QACL,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["import type { TSESTree } from '@typescript-eslint/utils';\nimport * as path from 'path';\nimport { getImportPathLiteralNode, type ImportLikeNode } from '../utils/getImportPathLiteralNode';\nimport { extractIdentifiersFromExport } from '../utils/testExports/extractIdentifiersFromExport';\nimport { getRegexpsFromStrings } from '../utils/getRegexpsFromStrings';\nimport { isIncludedIndexFile } from '../utils/testExports/isIncludedIndexFile';\nimport { type RuleContext, createRule } from '../utils/createRule';\n\n/** Rule options as specified in the config */\nexport type RuleOptions = {\n testPathPatterns?: string[];\n testExportNamePatterns?: string[];\n maxDepth?: number;\n};\n\ntype Context = {\n /** Original rule context */\n ruleContext: RuleContext<RuleOptions, MessageIds, ErrorData>;\n /** Processed test path patterns */\n testPathPatterns: RegExp[];\n /** Processed test export name patterns */\n testExportNamePatterns: RegExp[];\n /** Current filename extension (no leading .) */\n extension: string;\n};\n\nexport const defaultTestPaths: RegExp[] = [\n // Only match lowercase mock|test|fixture at the beginning of an import path segment to avoid false positives\n /\\/(__)?(mock|test|fixture)/,\n /\\.(mock|test|fixture)s?(\\.\\w+)?$/,\n /Mock|Test|Fixture/,\n];\n// Only match lowercase mock|test|fixture at the beginning of an export name to avoid false positives\nconst defaultTestExportNames: RegExp[] = [/^(mock|test|fixture)/, /Mock|Test|Fixture/];\nexport const defaultMaxDepth = Infinity;\n\n/** Error message IDs corresponding to `rule.meta.messages` */\nexport type MessageIds = 'invalidPath' | 'invalidName';\n\n/** Error data `{{substitutions}}` used in messages */\nexport type ErrorData = {\n extension: string;\n invalidPath?: string;\n invalidName?: string;\n};\n\nconst separateFileMessage = 'use a separate file such as index.mock.{{extension}} instead';\n\nexport const rule = createRule<RuleOptions, MessageIds, ErrorData>({\n name: 'no-test-exports',\n meta: {\n type: 'problem',\n docs: {\n description: 'ban test, mock, and fixture exports from index files',\n },\n messages: {\n invalidPath:\n 'Contents of test-related path \"{{invalidPath}}\" should not be referenced from an index file; ' +\n separateFileMessage,\n invalidName:\n '\"{{invalidName}}\" appears to be test-related and should not be exported from an index file; ' +\n separateFileMessage,\n },\n schema: [\n {\n type: 'object',\n properties: {\n testPathPatterns: {\n type: 'array',\n description:\n 'Ban exports from these paths (regex) from index files. Use \"...\" to include the default paths.',\n items: { type: 'string' },\n },\n testExportNamePatterns: {\n type: 'array',\n description:\n 'Ban exports with these names (regex) from index files. Use \"...\" to include the default names.',\n items: { type: 'string' },\n },\n maxDepth: {\n type: 'number',\n description: 'Maximum depth of index file (0-indexed; default Infinity)',\n },\n },\n additionalProperties: false,\n },\n ],\n },\n create: (ruleContext) => {\n const options = ruleContext.options[0] || {};\n const testPathPatterns = getRegexpsFromStrings(options.testPathPatterns, defaultTestPaths);\n const testExportNamePatterns = getRegexpsFromStrings(options.testExportNamePatterns, defaultTestExportNames);\n const maxDepth = options.maxDepth ?? defaultMaxDepth;\n const extension = path.extname(ruleContext.filename).slice(1);\n\n if (!isIncludedIndexFile({ filename: ruleContext.filename, ignorePaths: testPathPatterns, maxDepth })) {\n return {};\n }\n\n const context: Context = { ruleContext, testExportNamePatterns, testPathPatterns, extension };\n\n return {\n // import foo from 'foo'\n // import * as foo from 'foo'\n // import { foo } from 'foo'\n // import { foo as bar } from 'foo'\n // import 'foo'\n ImportDeclaration: (node) => checkNode(context, node),\n // import foo = require('foo')\n TSImportEqualsDeclaration: (node) => {\n // Skip \"export import foo = require('foo')\" because that will be handled by ExportNamedDeclaration\n if (node.parent.type !== 'ExportNamedDeclaration') {\n checkNode(context, node);\n }\n },\n // export { foo }\n // export { foo } from 'foo'\n // export { foo as bar } from 'foo'\n // export import foo = require('foo')\n // export const foo = 'foo';\n // and other exported declarations\n ExportNamedDeclaration: (node) => checkNode(context, node),\n // export * from 'foo'\n // export * as foo from 'foo'\n ExportAllDeclaration: (node) => checkNode(context, node),\n };\n },\n});\n\n/** Check an import or export node for violations. */\nfunction checkNode(\n context: Context,\n node: Exclude<ImportLikeNode, TSESTree.CallExpression | TSESTree.ImportExpression>,\n): void {\n const hasInvalidPath = checkInvalidPath(context, node);\n // Invalid path errors take precedence, to avoid spamming errors.\n if (!hasInvalidPath && (node.type === 'ExportAllDeclaration' || node.type === 'ExportNamedDeclaration')) {\n checkInvalidName(context, node);\n }\n}\n\n/**\n * Check an import or export for invalid paths.\n * Returns true if a violation was found.\n */\nfunction checkInvalidPath(\n context: Context,\n node: Exclude<ImportLikeNode, TSESTree.CallExpression | TSESTree.ImportExpression>,\n): boolean {\n const { ruleContext, testPathPatterns, extension } = context;\n\n // If there's an import path, check it\n const { importPath, pathNode } = getImportPathLiteralNode(node) || {};\n\n if (importPath && pathNode && testPathPatterns.some((re) => re.test(importPath))) {\n ruleContext.report({\n node: pathNode,\n messageId: 'invalidPath',\n data: { extension, invalidPath: importPath },\n });\n return true;\n }\n\n return false;\n}\n\n/** Check an export for invalid names. */\nfunction checkInvalidName(\n context: Context,\n node: TSESTree.ExportAllDeclaration | TSESTree.ExportNamedDeclaration,\n): void {\n const { ruleContext, testExportNamePatterns, extension } = context;\n\n const ids = extractIdentifiersFromExport(node);\n\n for (const id of ids) {\n if (testExportNamePatterns.some((re) => re.test(id.name))) {\n ruleContext.report({\n node: id,\n messageId: 'invalidName',\n data: { extension, invalidName: id.name },\n });\n }\n }\n}\n"]}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/** Rule options as specified in the config */
|
|
2
|
-
export type RuleOptions = {
|
|
3
|
-
ignorePatterns?: string[];
|
|
4
|
-
debug?: boolean;
|
|
5
|
-
};
|
|
6
|
-
export type ErrorMessageIds = 'noExports' | 'noExportsLocal' | 'notExported' | 'notExportedLocal';
|
|
7
|
-
export type SuggestMessageIds = 'useTopLevel';
|
|
8
|
-
export type MessageIds = ErrorMessageIds | SuggestMessageIds;
|
|
9
|
-
export type ErrorData = {
|
|
10
|
-
packageName: string;
|
|
11
|
-
subPath?: string;
|
|
12
|
-
};
|
|
13
|
-
export declare const rule: import("../utils/createRule").RuleModule<RuleOptions, MessageIds>;
|
|
14
|
-
//# sourceMappingURL=no-unsupported-imports.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"no-unsupported-imports.d.ts","sourceRoot":"","sources":["../../src/rules/no-unsupported-imports.ts"],"names":[],"mappings":"AAQA,8CAA8C;AAC9C,MAAM,MAAM,WAAW,GAAG;IACxB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC;AAUF,MAAM,MAAM,eAAe,GAAG,WAAW,GAAG,gBAAgB,GAAG,aAAa,GAAG,kBAAkB,CAAC;AAClG,MAAM,MAAM,iBAAiB,GAAG,aAAa,CAAC;AAC9C,MAAM,MAAM,UAAU,GAAG,eAAe,GAAG,iBAAiB,CAAC;AAE7D,MAAM,MAAM,SAAS,GAAG;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAYF,eAAO,MAAM,IAAI,mEAiEf,CAAC"}
|