@skyux-sdk/eslint-schematics 12.8.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 ADDED
@@ -0,0 +1 @@
1
+ # @skyux-sdk/eslint-schematics
@@ -0,0 +1,10 @@
1
+ {
2
+ "$schema": "../../../node_modules/@angular-devkit/schematics/collection-schema.json",
3
+ "schematics": {
4
+ "ng-add": {
5
+ "description": "Add @skyux-sdk/eslint-schematics to your project.",
6
+ "factory": "./src/schematics/ng-add/ng-add.schematic",
7
+ "schema": "./src/schematics/ng-add/schema.json"
8
+ }
9
+ }
10
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "schematics": {
3
+ "noop": {
4
+ "version": "12.8.0",
5
+ "factory": "./src/schematics/migrations/noop/noop.schematic",
6
+ "description": "Update skyux-eslint dependencies"
7
+ }
8
+ }
9
+ }
package/package.json ADDED
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "@skyux-sdk/eslint-schematics",
3
+ "version": "12.8.0",
4
+ "author": "Blackbaud, Inc.",
5
+ "description": "SKY UX ESLint schematics for Angular CLI projects",
6
+ "keywords": [
7
+ "blackbaud",
8
+ "skyux"
9
+ ],
10
+ "license": "MIT",
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "git+https://github.com/blackbaud/skyux.git"
14
+ },
15
+ "bugs": {
16
+ "url": "https://github.com/blackbaud/skyux/issues"
17
+ },
18
+ "homepage": "https://github.com/blackbaud/skyux#readme",
19
+ "schematics": "./collection.json",
20
+ "ng-add": {
21
+ "save": "devDependencies"
22
+ },
23
+ "ng-update": {
24
+ "packageGroupName": "@skyux-sdk/eslint-schematics",
25
+ "migrations": "./migrations.json",
26
+ "packageGroup": {
27
+ "skyux-eslint": "12.8.0"
28
+ }
29
+ },
30
+ "peerDependencies": {
31
+ "@angular/cli": "^19.2.8"
32
+ },
33
+ "dependencies": {
34
+ "semver": "7.7.1",
35
+ "tslib": "^2.8.1"
36
+ },
37
+ "types": "./src/index.d.ts",
38
+ "main": "./src/index.js",
39
+ "type": "commonjs"
40
+ }
@@ -0,0 +1,2 @@
1
+ import { Rule } from '@angular-devkit/schematics';
2
+ export default function (): Rule;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = default_1;
4
+ function default_1() {
5
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
6
+ return () => { };
7
+ }
8
+ //# sourceMappingURL=noop.schematic.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"noop.schematic.js","sourceRoot":"","sources":["../../../../../../../../libs/sdk/eslint-schematics/src/schematics/migrations/noop/noop.schematic.ts"],"names":[],"mappings":";;AAEA,4BAGC;AAHD;IACE,gEAAgE;IAChE,OAAO,GAAG,EAAE,GAAE,CAAC,CAAC;AAClB,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { Rule } from '@angular-devkit/schematics';
2
+ /**
3
+ * Adds `skyux-eslint` to an existing `angular-eslint` config file.
4
+ */
5
+ export default function ngAdd(): Rule;
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = ngAdd;
4
+ const tslib_1 = require("tslib");
5
+ const cli_1 = require("@angular/cli");
6
+ const dependencies_1 = require("@schematics/angular/utility/dependencies");
7
+ const semver_1 = tslib_1.__importDefault(require("semver"));
8
+ const ESLINT_CONFIG_EXTENDS_REGEXP = /(?<=extends:\s*\[)[^\]]*(?=])/g;
9
+ const MODULE_EXPORTS_REGEXP = /\nmodule\.exports/;
10
+ function getRootEslintConfigFilePath(tree) {
11
+ if (!(0, dependencies_1.getPackageJsonDependency)(tree, 'angular-eslint')) {
12
+ throw new Error("The package 'angular-eslint' is not installed. " +
13
+ `Run 'ng add angular-eslint@${cli_1.VERSION.major}' and try this command again.\n` +
14
+ 'See: https://github.com/angular-eslint/angular-eslint#quick-start');
15
+ }
16
+ const eslintDependency = (0, dependencies_1.getPackageJsonDependency)(tree, 'eslint');
17
+ const eslintMajorVersion = eslintDependency && semver_1.default.minVersion(eslintDependency.version)?.major;
18
+ if (eslintMajorVersion && eslintMajorVersion < 9) {
19
+ throw new Error("The 'skyux-eslint' package requires eslint version 9.");
20
+ }
21
+ let foundFile;
22
+ tree.getDir('/').visit((filePath) => {
23
+ if (foundFile) {
24
+ return;
25
+ }
26
+ if (filePath.match(/^\/\.eslintrc/)) {
27
+ throw new Error("The 'skyux-eslint' package does not support ESLint's legacy config. " +
28
+ 'Migrate to ESLint\'s "flat" config and try the command again.');
29
+ }
30
+ if (filePath.match(/^\/eslint\.config\.(js|mjs|cjs)$/)) {
31
+ foundFile = filePath;
32
+ }
33
+ });
34
+ if (!foundFile) {
35
+ throw new Error('A compatible ESLint config file could not be found.');
36
+ }
37
+ return foundFile;
38
+ }
39
+ /**
40
+ * Adds `skyux-eslint` to an existing `angular-eslint` config file.
41
+ */
42
+ function ngAdd() {
43
+ return (tree) => {
44
+ const configFile = getRootEslintConfigFilePath(tree);
45
+ const contents = tree.readText(configFile);
46
+ const recorder = tree.beginUpdate(configFile);
47
+ const exportsMatch = MODULE_EXPORTS_REGEXP.exec(contents);
48
+ if (exportsMatch) {
49
+ recorder.insertLeft(exportsMatch.index, 'const skyux = require("skyux-eslint");\n');
50
+ }
51
+ const statements = [
52
+ 'skyux.configs.templateRecommended',
53
+ 'skyux.configs.tsRecommended',
54
+ ];
55
+ contents.match(ESLINT_CONFIG_EXTENDS_REGEXP)?.forEach((element) => {
56
+ recorder.insertRight(contents.indexOf(element) + element.length, `${' '.repeat(2)}...${statements.pop()},\n${' '.repeat(4)}`);
57
+ });
58
+ tree.commitUpdate(recorder);
59
+ };
60
+ }
61
+ //# sourceMappingURL=ng-add.schematic.js.map
@@ -0,0 +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":";;AAuDA,wBA8BC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AED;;GAEG;AACH,SAAwB,KAAK;IAC3B,OAAO,CAAC,IAAI,EAAE,EAAE;QACd,MAAM,UAAU,GAAG,2BAA2B,CAAC,IAAI,CAAC,CAAC;QAErD,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;QAC3C,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;QAE9C,MAAM,YAAY,GAAG,qBAAqB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAE1D,IAAI,YAAY,EAAE,CAAC;YACjB,QAAQ,CAAC,UAAU,CACjB,YAAY,CAAC,KAAK,EAClB,0CAA0C,CAC3C,CAAC;QACJ,CAAC;QAED,MAAM,UAAU,GAAG;YACjB,mCAAmC;YACnC,6BAA6B;SAC9B,CAAC;QAEF,QAAQ,CAAC,KAAK,CAAC,4BAA4B,CAAC,EAAE,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YAChE,QAAQ,CAAC,WAAW,CAClB,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,MAAM,EAC1C,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAC5D,CAAC;QACJ,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;IAC9B,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,5 @@
1
+ {
2
+ "$schema": "http://json-schema.org/schema",
3
+ "type": "object",
4
+ "properties": {}
5
+ }
@@ -0,0 +1,15 @@
1
+ import { SchematicTestRunner, UnitTestTree } from '@angular-devkit/schematics/testing';
2
+ /**
3
+ * Creates a new Angular CLI application.
4
+ */
5
+ export declare function createTestApp(runner: SchematicTestRunner, appOptions: {
6
+ setupEslint?: boolean;
7
+ projectName: string;
8
+ }): Promise<UnitTestTree>;
9
+ /**
10
+ * Create a test workspace with a library as the default project.
11
+ */
12
+ export declare function createTestLibrary(runner: SchematicTestRunner, libOptions: {
13
+ setupEslint?: boolean;
14
+ projectName: string;
15
+ }): Promise<UnitTestTree>;
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createTestApp = createTestApp;
4
+ exports.createTestLibrary = createTestLibrary;
5
+ const cli_1 = require("@angular/cli");
6
+ /**
7
+ * Creates a new Angular CLI application.
8
+ */
9
+ async function createTestApp(runner, appOptions) {
10
+ const tree = await runner.runExternalSchematic('@schematics/angular', 'ng-new', {
11
+ directory: '/',
12
+ name: appOptions.projectName,
13
+ routing: true,
14
+ strict: true,
15
+ style: 'scss',
16
+ version: cli_1.VERSION.major,
17
+ });
18
+ if (appOptions.setupEslint) {
19
+ await runner.runExternalSchematic('angular-eslint', 'ng-add', {}, tree);
20
+ }
21
+ return tree;
22
+ }
23
+ /**
24
+ * Create a test workspace with a library as the default project.
25
+ */
26
+ async function createTestLibrary(runner, libOptions) {
27
+ const tree = await runner.runExternalSchematic('@schematics/angular', 'ng-new', {
28
+ directory: '/',
29
+ name: `${libOptions.projectName}-workspace`,
30
+ createApplication: false,
31
+ strict: true,
32
+ version: cli_1.VERSION.major,
33
+ });
34
+ if (libOptions.setupEslint) {
35
+ await runner.runExternalSchematic('angular-eslint', 'ng-add', {}, tree);
36
+ }
37
+ await runner.runExternalSchematic('@schematics/angular', 'library', {
38
+ name: libOptions.projectName,
39
+ }, tree);
40
+ // Create a "showcase" application for library projects.
41
+ await runner.runExternalSchematic('@schematics/angular', 'application', {
42
+ name: `${libOptions.projectName}-showcase`,
43
+ }, tree);
44
+ if (libOptions.setupEslint) {
45
+ await runner.runExternalSchematic('angular-eslint', 'add-eslint-to-project', {
46
+ project: libOptions.projectName,
47
+ }, tree);
48
+ await runner.runExternalSchematic('angular-eslint', 'add-eslint-to-project', {
49
+ project: `${libOptions.projectName}-showcase`,
50
+ }, tree);
51
+ }
52
+ return tree;
53
+ }
54
+ //# sourceMappingURL=scaffold.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scaffold.js","sourceRoot":"","sources":["../../../../../../../libs/sdk/eslint-schematics/src/schematics/testing/scaffold.ts"],"names":[],"mappings":";;AASA,sCAyBC;AAKD,8CA+DC;AAlGD,sCAAuC;AAEvC;;GAEG;AACI,KAAK,UAAU,aAAa,CACjC,MAA2B,EAC3B,UAGC;IAED,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,oBAAoB,CAC5C,qBAAqB,EACrB,QAAQ,EACR;QACE,SAAS,EAAE,GAAG;QACd,IAAI,EAAE,UAAU,CAAC,WAAW;QAC5B,OAAO,EAAE,IAAI;QACb,MAAM,EAAE,IAAI;QACZ,KAAK,EAAE,MAAM;QACb,OAAO,EAAE,aAAO,CAAC,KAAK;KACvB,CACF,CAAC;IAEF,IAAI,UAAU,CAAC,WAAW,EAAE,CAAC;QAC3B,MAAM,MAAM,CAAC,oBAAoB,CAAC,gBAAgB,EAAE,QAAQ,EAAE,EAAE,EAAE,IAAI,CAAC,CAAC;IAC1E,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;GAEG;AACI,KAAK,UAAU,iBAAiB,CACrC,MAA2B,EAC3B,UAGC;IAED,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,oBAAoB,CAC5C,qBAAqB,EACrB,QAAQ,EACR;QACE,SAAS,EAAE,GAAG;QACd,IAAI,EAAE,GAAG,UAAU,CAAC,WAAW,YAAY;QAC3C,iBAAiB,EAAE,KAAK;QACxB,MAAM,EAAE,IAAI;QACZ,OAAO,EAAE,aAAO,CAAC,KAAK;KACvB,CACF,CAAC;IAEF,IAAI,UAAU,CAAC,WAAW,EAAE,CAAC;QAC3B,MAAM,MAAM,CAAC,oBAAoB,CAAC,gBAAgB,EAAE,QAAQ,EAAE,EAAE,EAAE,IAAI,CAAC,CAAC;IAC1E,CAAC;IAED,MAAM,MAAM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