@skyux-sdk/eslint-schematics 12.8.0 → 12.10.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/migrations.json
CHANGED
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@skyux-sdk/eslint-schematics",
|
3
|
-
"version": "12.
|
3
|
+
"version": "12.10.0",
|
4
4
|
"author": "Blackbaud, Inc.",
|
5
5
|
"description": "SKY UX ESLint schematics for Angular CLI projects",
|
6
6
|
"keywords": [
|
@@ -24,7 +24,7 @@
|
|
24
24
|
"packageGroupName": "@skyux-sdk/eslint-schematics",
|
25
25
|
"migrations": "./migrations.json",
|
26
26
|
"packageGroup": {
|
27
|
-
"skyux-eslint": "12.
|
27
|
+
"skyux-eslint": "12.10.0"
|
28
28
|
}
|
29
29
|
},
|
30
30
|
"peerDependencies": {
|
@@ -6,7 +6,19 @@ const cli_1 = require("@angular/cli");
|
|
6
6
|
const dependencies_1 = require("@schematics/angular/utility/dependencies");
|
7
7
|
const semver_1 = tslib_1.__importDefault(require("semver"));
|
8
8
|
const ESLINT_CONFIG_EXTENDS_REGEXP = /(?<=extends:\s*\[)[^\]]*(?=])/g;
|
9
|
-
|
9
|
+
function needsComma(contents) {
|
10
|
+
const len = contents.length;
|
11
|
+
for (let i = len; i > -1; i--) {
|
12
|
+
// Starting at the end of the string, find the first non-whitespace character
|
13
|
+
// and check if it's a comma. If it is, we don't need to insert one.
|
14
|
+
const maybeComma = contents.at(i);
|
15
|
+
if (maybeComma !== undefined && maybeComma.match(/[^\s]/)) {
|
16
|
+
return maybeComma !== ',';
|
17
|
+
}
|
18
|
+
}
|
19
|
+
/* istanbul ignore next: safety check */
|
20
|
+
return true;
|
21
|
+
}
|
10
22
|
function getRootEslintConfigFilePath(tree) {
|
11
23
|
if (!(0, dependencies_1.getPackageJsonDependency)(tree, 'angular-eslint')) {
|
12
24
|
throw new Error("The package 'angular-eslint' is not installed. " +
|
@@ -18,9 +30,9 @@ function getRootEslintConfigFilePath(tree) {
|
|
18
30
|
if (eslintMajorVersion && eslintMajorVersion < 9) {
|
19
31
|
throw new Error("The 'skyux-eslint' package requires eslint version 9.");
|
20
32
|
}
|
21
|
-
let
|
33
|
+
let configFile;
|
22
34
|
tree.getDir('/').visit((filePath) => {
|
23
|
-
if (
|
35
|
+
if (configFile) {
|
24
36
|
return;
|
25
37
|
}
|
26
38
|
if (filePath.match(/^\/\.eslintrc/)) {
|
@@ -28,32 +40,40 @@ function getRootEslintConfigFilePath(tree) {
|
|
28
40
|
'Migrate to ESLint\'s "flat" config and try the command again.');
|
29
41
|
}
|
30
42
|
if (filePath.match(/^\/eslint\.config\.(js|mjs|cjs)$/)) {
|
31
|
-
|
43
|
+
configFile = filePath;
|
32
44
|
}
|
33
45
|
});
|
34
|
-
if (!
|
46
|
+
if (!configFile) {
|
35
47
|
throw new Error('A compatible ESLint config file could not be found.');
|
36
48
|
}
|
37
|
-
|
49
|
+
const isEsm = tree.readText(configFile).includes('export default ');
|
50
|
+
return { configFile, isEsm };
|
38
51
|
}
|
39
52
|
/**
|
40
53
|
* Adds `skyux-eslint` to an existing `angular-eslint` config file.
|
41
54
|
*/
|
42
55
|
function ngAdd() {
|
43
56
|
return (tree) => {
|
44
|
-
const configFile = getRootEslintConfigFilePath(tree);
|
57
|
+
const { configFile, isEsm } = getRootEslintConfigFilePath(tree);
|
45
58
|
const contents = tree.readText(configFile);
|
59
|
+
const importStatement = isEsm
|
60
|
+
? 'import skyux from "skyux-eslint";\n'
|
61
|
+
: 'const skyux = require("skyux-eslint");\n';
|
62
|
+
if (contents.includes(importStatement)) {
|
63
|
+
return;
|
64
|
+
}
|
46
65
|
const recorder = tree.beginUpdate(configFile);
|
47
|
-
const
|
66
|
+
const exportsRegexp = isEsm ? /\nexport default / : /\nmodule\.exports/;
|
67
|
+
const exportsMatch = exportsRegexp.exec(contents);
|
48
68
|
if (exportsMatch) {
|
49
|
-
recorder.insertLeft(exportsMatch.index,
|
69
|
+
recorder.insertLeft(exportsMatch.index, importStatement);
|
50
70
|
}
|
51
71
|
const statements = [
|
52
72
|
'skyux.configs.templateRecommended',
|
53
73
|
'skyux.configs.tsRecommended',
|
54
74
|
];
|
55
75
|
contents.match(ESLINT_CONFIG_EXTENDS_REGEXP)?.forEach((element) => {
|
56
|
-
recorder.insertRight(contents.indexOf(element) + element.length, `${' '.repeat(2)}...${statements.pop()},\n${' '.repeat(4)}`);
|
76
|
+
recorder.insertRight(contents.indexOf(element) + element.length, `${needsComma(element) ? ',' : ''}${' '.repeat(2)}...${statements.pop()},\n${' '.repeat(4)}`);
|
57
77
|
});
|
58
78
|
tree.commitUpdate(recorder);
|
59
79
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ng-add.schematic.js","sourceRoot":"","sources":["../../../../../../../libs/sdk/eslint-schematics/src/schematics/ng-add/ng-add.schematic.ts"],"names":[],"mappings":";;
|
1
|
+
{"version":3,"file":"ng-add.schematic.js","sourceRoot":"","sources":["../../../../../../../libs/sdk/eslint-schematics/src/schematics/ng-add/ng-add.schematic.ts"],"names":[],"mappings":";;AA2EA,wBAoCC;;AA9GD,sCAAuC;AACvC,2EAAoF;AAEpF,4DAA4B;AAE5B,MAAM,4BAA4B,GAAG,gCAAgC,CAAC;AAEtE,SAAS,UAAU,CAAC,QAAgB;IAClC,MAAM,GAAG,GAAG,QAAQ,CAAC,MAAM,CAAC;IAE5B,KAAK,IAAI,CAAC,GAAG,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC9B,6EAA6E;QAC7E,oEAAoE;QACpE,MAAM,UAAU,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QAClC,IAAI,UAAU,KAAK,SAAS,IAAI,UAAU,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;YAC1D,OAAO,UAAU,KAAK,GAAG,CAAC;QAC5B,CAAC;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