@ms-cloudpack/eslint-plugin 0.3.15 → 0.4.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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createRule.d.ts","sourceRoot":"","sources":["../../src/utils/createRule.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,
|
|
1
|
+
{"version":3,"file":"createRule.d.ts","sourceRoot":"","sources":["../../src/utils/createRule.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAEhF,KAAK,QAAQ,CAAC,CAAC,IAAI;IAAE,CAAC,UAAU,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAE,CAAC;AAEtD;;;GAGG;AACH,MAAM,MAAM,gBAAgB,CAAC,WAAW,SAAS,MAAM,EAAE,UAAU,IAAI,IAAI,CAEzE,QAAQ,CAAC,QAAQ,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAC,EAChD,MAAM,GAAG,MAAM,GAAG,SAAS,CAC5B,GAAG;IACF,IAAI,EAAE,UAAU,CAAC;IAEjB,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC;IACpB,OAAO,CAAC,EAAE,oBAAoB,CAAC,WAAW,EAAE,UAAU,CAAC,EAAE,GAAG,IAAI,CAAC;CAClE,CAAC;AAEF,+CAA+C;AAC/C,MAAM,MAAM,oBAAoB,CAAC,WAAW,SAAS,MAAM,EAAE,UAAU,IAAI,IAAI,CAC7E,gBAAgB,CAAC,WAAW,EAAE,UAAU,CAAC,EACzC,SAAS,GAAG,MAAM,CACnB,CAAC;AAEF,2CAA2C;AAC3C,MAAM,MAAM,gBAAgB,CAAC,WAAW,SAAS,MAAM,EAAE,UAAU,IAAI,IAAI,CACzE,QAAQ,CAAC,gBAAgB,CAAC,WAAW,CAAC,EACtC,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;
|
|
4
|
-
//
|
|
5
|
-
// This file contains wrappers for rule creation and related types.
|
|
6
|
-
//
|
|
7
|
-
const utils_1 = require("@typescript-eslint/utils");
|
|
8
|
-
const baseCreateRule = utils_1.ESLintUtils.RuleCreator((name) => `https://www.npmjs.com/package/@ms-cloudpack/eslint-plugin#${name}`);
|
|
9
4
|
/**
|
|
10
5
|
* Create a lint rule, with strongly typed data in `context.report`.
|
|
11
6
|
* (This assumes all error/suggestion messages share a common data type.)
|
|
12
7
|
*/
|
|
13
8
|
function createRule(params) {
|
|
14
|
-
return
|
|
9
|
+
return {
|
|
15
10
|
...params,
|
|
11
|
+
meta: {
|
|
12
|
+
...params.meta,
|
|
13
|
+
docs: {
|
|
14
|
+
...params.meta.docs,
|
|
15
|
+
url: `https://www.npmjs.com/package/@ms-cloudpack/eslint-plugin#${params.name}`,
|
|
16
|
+
},
|
|
17
|
+
},
|
|
16
18
|
defaultOptions: [],
|
|
17
19
|
create: (context) => {
|
|
18
20
|
const contextCopy = { ...context };
|
|
@@ -25,7 +27,7 @@ function createRule(params) {
|
|
|
25
27
|
/* eslint-enable etc/no-deprecated */
|
|
26
28
|
return params.create(contextCopy);
|
|
27
29
|
},
|
|
28
|
-
}
|
|
30
|
+
};
|
|
29
31
|
}
|
|
30
32
|
exports.createRule = createRule;
|
|
31
33
|
//# sourceMappingURL=createRule.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createRule.js","sourceRoot":"","sources":["../../src/utils/createRule.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"createRule.js","sourceRoot":"","sources":["../../src/utils/createRule.ts"],"names":[],"mappings":";;;AAuEA;;;GAGG;AACH,SAAgB,UAAU,CACxB,MAA4D;IAE5D,OAAO;QACL,GAAG,MAAM;QACT,IAAI,EAAE;YACJ,GAAG,MAAM,CAAC,IAAI;YACd,IAAI,EAAE;gBACJ,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI;gBACnB,GAAG,EAAE,6DAA6D,MAAM,CAAC,IAAI,EAAE;aAChF;SACF;QACD,cAAc,EAAE,EAAE;QAClB,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE;YAClB,MAAM,WAAW,GAAG,EAAE,GAAG,OAAO,EAAE,CAAC;YAEnC,sDAAsD;YACtD,sCAAsC;YACtC,WAAW,CAAC,GAAG,KAAK,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;YACvC,WAAW,CAAC,QAAQ,KAAK,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC;YACjD,WAAW,CAAC,gBAAgB,KAAK,OAAO,CAAC,mBAAmB,EAAE,EAAE,CAAC;YACjE,WAAW,CAAC,UAAU,KAAK,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC;YACrD,qCAAqC;YAErC,OAAO,MAAM,CAAC,MAAM,CAAC,WAA6D,CAAC,CAAC;QACtF,CAAC;KACF,CAAC;AACJ,CAAC;AA3BD,gCA2BC","sourcesContent":["//\n// This file contains wrappers for rule creation and related types.\n//\nimport type { ESLintUtils, TSESLint, TSESTree } from '@typescript-eslint/utils';\n\ntype Writable<T> = { -readonly [K in keyof T]: T[K] };\n\n/**\n * Problem report descriptor with strongly typed error and suggestion data.\n * (This assumes all error/suggestion messages share a common data type.)\n */\nexport type ReportDescriptor<TMessageIds extends string, TErrorData> = Omit<\n // Make the descriptor writable for convenience (like conditionally adding a fix)\n Writable<TSESLint.ReportDescriptor<TMessageIds>>,\n 'data' | 'node' | 'suggest'\n> & {\n data: TErrorData;\n // have to re-declare `node` due to an oddity with union types (built-in ReportDescriptor is a union) and omit\n node: TSESTree.Node;\n suggest?: SuggestionDescriptor<TMessageIds, TErrorData>[] | null;\n};\n\n/** Fix suggestion with strongly typed data. */\nexport type SuggestionDescriptor<TMessageIds extends string, TErrorData> = Omit<\n ReportDescriptor<TMessageIds, TErrorData>,\n 'suggest' | 'node'\n>;\n\n/** Fix suggestion output (for testing). */\nexport type SuggestionOutput<TMessageIds extends string, TErrorData> = Omit<\n TSESLint.SuggestionOutput<TMessageIds>,\n 'data'\n> & { data?: TErrorData };\n\n/**\n * Rule context with strongly typed `report`.\n * (This assumes all error/suggestion messages share a common data type.)\n */\nexport type RuleContext<TOptions, TMessageIds extends string, TErrorData> = Omit<\n TSESLint.RuleContext<TMessageIds, TOptions[]>,\n 'report'\n> & {\n report: (descriptor: ReportDescriptor<TMessageIds, TErrorData>) => void;\n};\n\n/**\n * Rule info with better {@link RuleContext} type for the `create` function.\n * (This assumes all error/suggestion messages share a common data type.)\n */\ntype CreateRuleOptions<TOptions, TMessageIds extends string, TErrorData> = Omit<\n ESLintUtils.RuleWithMetaAndName<TOptions[], TMessageIds>,\n // Why remove defaultOptions (array): typescript-eslint merges this array with the original\n // options array and passes the merged array as the second argument to `create`. However,\n // this isn't reflected in the types, and its behavior is kind of weird (an empty `defaultOptions`\n // array will cause the provided options to be ignored). So remove it from the types\n // and fill in a default value in `createRule` instead.\n 'create' | 'defaultOptions'\n> & {\n create(this: void, context: Readonly<RuleContext<TOptions, TMessageIds, TErrorData>>): TSESLint.RuleListener;\n};\n\n/**\n * This exported alias is just to avoid an error when exporting the `rule` returned from `createRule`\n * (\"the inferred type of 'rule' cannot be named without a reference to ...\").\n */\nexport type RuleModule<TOptions, TMessageIds extends string> = ESLintUtils.RuleModule<\n TMessageIds,\n TOptions[],\n ESLintUtils.RuleListener\n>;\n\n/**\n * Create a lint rule, with strongly typed data in `context.report`.\n * (This assumes all error/suggestion messages share a common data type.)\n */\nexport function createRule<TOptions, TMessageIds extends string, TErrorData>(\n params: CreateRuleOptions<TOptions, TMessageIds, TErrorData>,\n): RuleModule<TOptions, TMessageIds> {\n return {\n ...params,\n meta: {\n ...params.meta,\n docs: {\n ...params.meta.docs,\n url: `https://www.npmjs.com/package/@ms-cloudpack/eslint-plugin#${params.name}`,\n },\n },\n defaultOptions: [],\n create: (context) => {\n const contextCopy = { ...context };\n\n // Fill in properties that were added in eslint 8.40.0\n /* eslint-disable etc/no-deprecated */\n contextCopy.cwd ??= context.getCwd?.();\n contextCopy.filename ??= context.getFilename?.();\n contextCopy.physicalFilename ??= context.getPhysicalFilename?.();\n contextCopy.sourceCode ??= context.getSourceCode?.();\n /* eslint-enable etc/no-deprecated */\n\n return params.create(contextCopy as RuleContext<TOptions, TMessageIds, TErrorData>);\n },\n };\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ms-cloudpack/eslint-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "A set of ESLint rules for Cloudpack",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -14,21 +14,28 @@
|
|
|
14
14
|
"test": "cloudpack-scripts test"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@rnx-kit/eslint-plugin": "^0.6.0",
|
|
18
|
-
"@typescript-eslint/eslint-plugin": "^6.21.0",
|
|
19
|
-
"@typescript-eslint/parser": "^6.21.0",
|
|
20
|
-
"@typescript-eslint/utils": "^6.21.0",
|
|
21
17
|
"resolve": "^1.22.0"
|
|
22
18
|
},
|
|
23
19
|
"peerDependencies": {
|
|
20
|
+
"@rnx-kit/eslint-plugin": "^0.6.0 || ^0.7.0",
|
|
21
|
+
"@typescript-eslint/eslint-plugin": "^6.0.0 || ^7.0.0",
|
|
22
|
+
"@typescript-eslint/parser": "^6.0.0 || ^7.0.0",
|
|
24
23
|
"eslint": ">=7.0.0"
|
|
25
24
|
},
|
|
25
|
+
"peerDependenciesMeta": {
|
|
26
|
+
"@rnx-kit/eslint-plugin": {
|
|
27
|
+
"optional": true
|
|
28
|
+
}
|
|
29
|
+
},
|
|
26
30
|
"devDependencies": {
|
|
27
|
-
"@
|
|
28
|
-
"@ms-cloudpack/
|
|
29
|
-
"@ms-cloudpack/
|
|
30
|
-
"@
|
|
31
|
-
"@
|
|
31
|
+
"@eslint/eslintrc": "^2.0.0",
|
|
32
|
+
"@ms-cloudpack/eslint-plugin-internal": "^0.0.1",
|
|
33
|
+
"@ms-cloudpack/scripts": "^0.0.1",
|
|
34
|
+
"@ms-cloudpack/test-utilities": "^0.5.0",
|
|
35
|
+
"@typescript-eslint/eslint-plugin": "^7.0.0",
|
|
36
|
+
"@typescript-eslint/parser": "^7.0.0",
|
|
37
|
+
"@typescript-eslint/rule-tester": "^7.0.0",
|
|
38
|
+
"@typescript-eslint/utils": "^7.0.0"
|
|
32
39
|
},
|
|
33
40
|
"files": [
|
|
34
41
|
"lib/**/!(*.test.*)"
|