@spinnaker/eslint-plugin 2025.0.5 → 2025.1.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/base.config.js
CHANGED
|
@@ -18,7 +18,7 @@ module.exports = {
|
|
|
18
18
|
'@spinnaker/ng-no-module-export': 2,
|
|
19
19
|
'@spinnaker/ng-no-require-angularjs': 2,
|
|
20
20
|
'@spinnaker/ng-no-require-module-deps': 2,
|
|
21
|
-
'@spinnaker/ng-strictdi':
|
|
21
|
+
'@spinnaker/ng-strictdi': 'off', // TODO: this rule seems to be broken, needs to be rewritten to avoid an error
|
|
22
22
|
'@spinnaker/prefer-promise-like': 1,
|
|
23
23
|
'@spinnaker/react2angular-with-error-boundary': 2,
|
|
24
24
|
'@spinnaker/rest-prefer-static-strings-in-initializer': 2,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spinnaker/eslint-plugin",
|
|
3
|
-
"version": "2025.0
|
|
3
|
+
"version": "2025.1.0",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"publishConfig": {
|
|
@@ -24,18 +24,18 @@
|
|
|
24
24
|
"@types/jest": "^26.0.24",
|
|
25
25
|
"@types/lodash": "^4.14.165",
|
|
26
26
|
"@types/node": "^16.4.13",
|
|
27
|
-
"@typescript-eslint/parser": "
|
|
28
|
-
"@typescript-eslint/types": "
|
|
29
|
-
"eslint": "
|
|
27
|
+
"@typescript-eslint/parser": "5.59.8",
|
|
28
|
+
"@typescript-eslint/types": "5.59.8",
|
|
29
|
+
"eslint": "7.32.0",
|
|
30
30
|
"fast-glob": "^3.2.7",
|
|
31
31
|
"jest": "^27.0.6",
|
|
32
32
|
"prettier": "*",
|
|
33
|
-
"typescript": "
|
|
33
|
+
"typescript": "5.0.4"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
|
-
"@typescript-eslint/eslint-plugin": "
|
|
37
|
-
"@typescript-eslint/parser": "
|
|
38
|
-
"eslint": "7.
|
|
36
|
+
"@typescript-eslint/eslint-plugin": "5.59.8",
|
|
37
|
+
"@typescript-eslint/parser": "5.59.8",
|
|
38
|
+
"eslint": "7.32.0",
|
|
39
39
|
"eslint-config-prettier": "6.12.0",
|
|
40
40
|
"eslint-plugin-react-hooks": "4.1.2"
|
|
41
41
|
},
|
|
@@ -48,8 +48,9 @@
|
|
|
48
48
|
],
|
|
49
49
|
"jest": {
|
|
50
50
|
"testPathIgnorePatterns": [
|
|
51
|
-
"<rootDir>/template"
|
|
51
|
+
"<rootDir>/template",
|
|
52
|
+
"<rootDir>/rules/ng-strictdi.spec.ts"
|
|
52
53
|
]
|
|
53
54
|
},
|
|
54
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "ed6c0f8929f68fcb6295c4d56c4bfbdec8d21ce6"
|
|
55
56
|
}
|
package/rules/api-deprecation.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type { Rule } from 'eslint';
|
|
|
2
2
|
import type { CallExpression, ImportDeclaration, ImportSpecifier, MemberExpression, Node } from 'estree';
|
|
3
3
|
import * as _ from 'lodash/fp';
|
|
4
4
|
|
|
5
|
+
import { getImportName } from '../utils/ast';
|
|
5
6
|
import {
|
|
6
7
|
getCallChain,
|
|
7
8
|
getCallingIdentifier,
|
|
@@ -171,7 +172,7 @@ function reportAPIDeprecatedUseREST(node: Node, context: Rule.RuleContext, callC
|
|
|
171
172
|
.reduce((acc, x) => acc.concat(x), []) as ImportSpecifier[]; //flatten
|
|
172
173
|
|
|
173
174
|
const apiImport = importSpecifiers.find((specifier) => {
|
|
174
|
-
return specifier.imported && specifier.imported
|
|
175
|
+
return specifier.imported && getImportName(specifier.imported) === 'API';
|
|
175
176
|
});
|
|
176
177
|
|
|
177
178
|
return context.report({
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Rule } from 'eslint';
|
|
2
2
|
import type { ImportDeclaration, ImportSpecifier } from 'estree';
|
|
3
|
+
import { getImportName } from '../utils/ast';
|
|
3
4
|
|
|
4
5
|
const migratedPresentationModules = ['Icon', 'IconNames', 'Illustration', 'IllustrationName'];
|
|
5
6
|
|
|
@@ -38,9 +39,9 @@ const addImportToPresentation = (
|
|
|
38
39
|
|
|
39
40
|
// Use the alias if it is available in the old import specifier.
|
|
40
41
|
const importSpecifierText =
|
|
41
|
-
importSpecifierNode.local.name === importSpecifierNode.imported
|
|
42
|
-
? importSpecifierNode.imported
|
|
43
|
-
: `${importSpecifierNode.imported
|
|
42
|
+
importSpecifierNode.local.name === getImportName(importSpecifierNode.imported)
|
|
43
|
+
? getImportName(importSpecifierNode.imported)
|
|
44
|
+
: `${getImportName(importSpecifierNode.imported)} as ${importSpecifierNode.local.name}`;
|
|
44
45
|
|
|
45
46
|
// Check if @spinnaker/presentation is already imported.
|
|
46
47
|
const spinnakerPresentationImport = sourceCode.ast.body.find(
|
|
@@ -76,10 +77,10 @@ const rule = (context: Rule.RuleContext) => {
|
|
|
76
77
|
return {
|
|
77
78
|
ImportSpecifier(node: ImportSpecifier & Rule.NodeParentExtension) {
|
|
78
79
|
if (
|
|
79
|
-
migratedPresentationModules.includes(node.imported
|
|
80
|
+
migratedPresentationModules.includes(getImportName(node.imported)) &&
|
|
80
81
|
(node.parent as ImportDeclaration).source.value === '@spinnaker/core'
|
|
81
82
|
) {
|
|
82
|
-
const message = `${node.imported
|
|
83
|
+
const message = `${getImportName(node.imported)} must be imported from @spinnaker/presentation`;
|
|
83
84
|
const fix = (fixer) => moveImportToPresentation(context, node, fixer);
|
|
84
85
|
context.report({
|
|
85
86
|
node,
|
package/rules/import-sort.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Rule } from 'eslint';
|
|
2
2
|
import type { ImportDeclaration, ImportDefaultSpecifier, ImportNamespaceSpecifier, ImportSpecifier } from 'estree';
|
|
3
|
+
import { getImportName } from '../utils/ast';
|
|
3
4
|
|
|
4
5
|
const CSS_IMPORT = /\.(css|less|scss|sass)$/;
|
|
5
6
|
const MODULE_PATH_REGEX = /[./]*(.*)$/;
|
|
@@ -58,7 +59,7 @@ const sortImportSpecifiers = (importDeclaration: ImportDeclaration) => {
|
|
|
58
59
|
return importDeclaration;
|
|
59
60
|
}
|
|
60
61
|
|
|
61
|
-
importSpecifiers.sort((a, b) => a.imported.
|
|
62
|
+
importSpecifiers.sort((a, b) => getImportName(a.imported).localeCompare(getImportName(b.imported)));
|
|
62
63
|
|
|
63
64
|
importDeclaration.specifiers = [defaultSpecifier, namespaceSpecifier, ...importSpecifiers].filter(
|
|
64
65
|
(specifier) => !!specifier,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Rule } from 'eslint';
|
|
2
2
|
import type { FunctionExpression, ImportDeclaration, ImportSpecifier } from 'estree';
|
|
3
3
|
|
|
4
|
+
import { getImportName } from '../utils/ast';
|
|
4
5
|
import { getProgram } from '../utils/utils';
|
|
5
6
|
|
|
6
7
|
const ruleModule: Rule.RuleModule = {
|
|
@@ -46,7 +47,7 @@ const ruleModule: Rule.RuleModule = {
|
|
|
46
47
|
.reduce((acc, x) => acc.concat(x), []);
|
|
47
48
|
|
|
48
49
|
const mockHttpClientImport = importSpecifiers.find((specifier) => {
|
|
49
|
-
return specifier.imported && specifier.imported
|
|
50
|
+
return specifier.imported && getImportName(specifier.imported) === 'mockHttpClient';
|
|
50
51
|
});
|
|
51
52
|
|
|
52
53
|
return context.report({
|
package/utils/ast.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Identifier, Literal } from 'estree';
|
|
2
|
+
|
|
3
|
+
export function getImportName(node: Identifier | Literal): string {
|
|
4
|
+
if (node.type === 'Identifier') {
|
|
5
|
+
return node.name;
|
|
6
|
+
}
|
|
7
|
+
if (node.type === 'Literal' && typeof node.value === 'string') {
|
|
8
|
+
return node.value;
|
|
9
|
+
}
|
|
10
|
+
return '';
|
|
11
|
+
}
|