@o3r/eslint-config 11.6.0-prerelease.8

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.
Files changed (52) hide show
  1. package/LICENSE +26 -0
  2. package/README.md +38 -0
  3. package/collection.json +11 -0
  4. package/package.json +221 -0
  5. package/schematics/ng-add/eslint/index.d.ts +8 -0
  6. package/schematics/ng-add/eslint/index.d.ts.map +1 -0
  7. package/schematics/ng-add/eslint/index.js +92 -0
  8. package/schematics/ng-add/eslint/index.js.map +1 -0
  9. package/schematics/ng-add/eslint/templates/project/eslint.config.__extension__.template +10 -0
  10. package/schematics/ng-add/eslint/templates/project/eslint.local.config.__extension__.template +27 -0
  11. package/schematics/ng-add/eslint/templates/workspace/eslint.config.__extension__.template +67 -0
  12. package/schematics/ng-add/eslint/templates/workspace/eslint.local.config.__extension__.template +22 -0
  13. package/schematics/ng-add/eslint/templates/workspace/eslint.shared.config.__extension__.template +41 -0
  14. package/schematics/ng-add/index.d.ts +8 -0
  15. package/schematics/ng-add/index.d.ts.map +1 -0
  16. package/schematics/ng-add/index.js +128 -0
  17. package/schematics/ng-add/index.js.map +1 -0
  18. package/schematics/ng-add/schema.d.ts +10 -0
  19. package/schematics/ng-add/schema.d.ts.map +1 -0
  20. package/schematics/ng-add/schema.js +3 -0
  21. package/schematics/ng-add/schema.js.map +1 -0
  22. package/schematics/ng-add/schema.json +28 -0
  23. package/schematics/ng-add/tsconfig/index.d.ts +8 -0
  24. package/schematics/ng-add/tsconfig/index.d.ts.map +1 -0
  25. package/schematics/ng-add/tsconfig/index.js +25 -0
  26. package/schematics/ng-add/tsconfig/index.js.map +1 -0
  27. package/schematics/ng-add/tsconfig/templates/tsconfig.eslint.json.template +6 -0
  28. package/schematics/ng-add/vscode/index.d.ts +6 -0
  29. package/schematics/ng-add/vscode/index.d.ts.map +1 -0
  30. package/schematics/ng-add/vscode/index.js +35 -0
  31. package/schematics/ng-add/vscode/index.js.map +1 -0
  32. package/schematics/package.json +3 -0
  33. package/src/rules/base.cjs +17 -0
  34. package/src/rules/template/angular.cjs +27 -0
  35. package/src/rules/template/otter.cjs +20 -0
  36. package/src/rules/template.cjs +23 -0
  37. package/src/rules/typescript/comments.cjs +27 -0
  38. package/src/rules/typescript/eslint-angular.cjs +36 -0
  39. package/src/rules/typescript/eslint-typescript.cjs +145 -0
  40. package/src/rules/typescript/eslint.cjs +146 -0
  41. package/src/rules/typescript/import-newlines.cjs +23 -0
  42. package/src/rules/typescript/import.cjs +29 -0
  43. package/src/rules/typescript/jest.cjs +26 -0
  44. package/src/rules/typescript/jsdoc.cjs +53 -0
  45. package/src/rules/typescript/otter.cjs +24 -0
  46. package/src/rules/typescript/prefer-arrow.cjs +25 -0
  47. package/src/rules/typescript/sort-export-all.cjs +24 -0
  48. package/src/rules/typescript/stylistic.cjs +101 -0
  49. package/src/rules/typescript/unicorn.cjs +51 -0
  50. package/src/rules/typescript/unused-imports.cjs +20 -0
  51. package/src/rules/typescript.cjs +138 -0
  52. package/src/rules/utils.cjs +21 -0
package/LICENSE ADDED
@@ -0,0 +1,26 @@
1
+ Copyright Amadeus SAS
2
+
3
+ Redistribution and use in source and binary forms, with or without modification,
4
+ are permitted provided that the following conditions are met:
5
+
6
+ 1. Redistributions of source code must retain the above copyright notice, this
7
+ list of conditions and the following disclaimer.
8
+
9
+ 2. Redistributions in binary form must reproduce the above copyright notice,
10
+ this list of conditions and the following disclaimer in the documentation and/or
11
+ other materials provided with the distribution.
12
+
13
+ 3. Neither the name of the copyright holder nor the names of its contributors
14
+ may be used to endorse or promote products derived from this software without
15
+ specific prior written permission.
16
+
17
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
21
+ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
24
+ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package/README.md ADDED
@@ -0,0 +1,38 @@
1
+ <h1 align="center">Otter ESLint config</h1>
2
+ <p align="center">
3
+ <img src="https://raw.githubusercontent.com/AmadeusITGroup/otter/main/assets/logo/otter.png" alt="Super cute Otter!" width="40%"/>
4
+ </p>
5
+
6
+ This package is an [Otter Framework Module](https://github.com/AmadeusITGroup/otter/tree/main/docs/core/MODULE.md).
7
+ <br />
8
+ <br />
9
+
10
+ ## Description
11
+
12
+ [![Stable Version](https://img.shields.io/npm/v/@o3r/eslint-config?style=for-the-badge)](https://www.npmjs.com/package/@o3r/eslint-config)
13
+ [![Bundle Size](https://img.shields.io/bundlephobia/min/@o3r/eslint-config?color=green&style=for-the-badge)](https://www.npmjs.com/package/@o3r/eslint-config)
14
+
15
+ Recommended ESLint configuration for an Otter project with [ESLint FlatConfig](https://eslint.org/blog/2022/08/new-config-system-part-2/).
16
+
17
+ ## How to install
18
+
19
+ ```shell
20
+ ng add @o3r/eslint-config
21
+ ```
22
+
23
+ ## How to use
24
+
25
+ Example of configuration:
26
+ ```javascript
27
+ import o3rConfig from '@o3r/eslint-config';
28
+
29
+ export default [
30
+ ...o3rConfig,
31
+ {
32
+ name: 'my-project-rules',
33
+ rules: {
34
+ // ...
35
+ }
36
+ }
37
+ ];
38
+ ```
@@ -0,0 +1,11 @@
1
+ {
2
+ "$schema": "https://raw.githubusercontent.com/angular/angular-cli/main/packages/angular_devkit/schematics/collection-schema.json",
3
+ "schematics": {
4
+ "ng-add": {
5
+ "description": "Add Otter eslint-config to the project.",
6
+ "factory": "./schematics/ng-add/index#ngAdd",
7
+ "schema": "./schematics/ng-add/schema.json",
8
+ "aliases": ["install", "i"]
9
+ }
10
+ }
11
+ }
package/package.json ADDED
@@ -0,0 +1,221 @@
1
+ {
2
+ "name": "@o3r/eslint-config",
3
+ "version": "11.6.0-prerelease.8",
4
+ "publishConfig": {
5
+ "access": "public"
6
+ },
7
+ "description": "Recommended eslint v9+ configuration for Otter project",
8
+ "main": "./src/rules/typescript.cjs",
9
+ "exports": {
10
+ "./package.json": {
11
+ "default": "./package.json"
12
+ },
13
+ ".": {
14
+ "default": "./src/rules/typescript.cjs"
15
+ },
16
+ "./typescript": {
17
+ "default": "./src/rules/typescript.cjs"
18
+ },
19
+ "./template": {
20
+ "default": "./src/rules/template.cjs"
21
+ }
22
+ },
23
+ "keywords": [
24
+ "eslint",
25
+ "otter",
26
+ "amadeus",
27
+ "linter",
28
+ "otter-module"
29
+ ],
30
+ "scripts": {
31
+ "build": "yarn cpy package.json dist && yarn cpy src dist && yarn postbuild",
32
+ "postbuild": "patch-package-json-main",
33
+ "prepare:publish": "prepare-publish ./dist",
34
+ "prepare:build:builders": "yarn cpy 'schematics/**/*.json' 'schematics/**/templates/**' dist/schematics && yarn cpy 'collection.json' dist",
35
+ "build:builders": "tsc -b tsconfig.builders.json --pretty && yarn generate-cjs-manifest"
36
+ },
37
+ "peerDependencies": {
38
+ "@angular-devkit/core": "~18.2.0",
39
+ "@angular-devkit/schematics": "~18.2.0",
40
+ "@angular-eslint/builder": "~18.4.0",
41
+ "@angular/compiler": "~18.2.0",
42
+ "@eslint-community/eslint-plugin-eslint-comments": "^4.4.0",
43
+ "@eslint/js": ">=8.57.0 <9.15.0",
44
+ "@o3r/eslint-plugin": "^11.6.0-prerelease.8",
45
+ "@o3r/schematics": "^11.6.0-prerelease.8",
46
+ "@schematics/angular": "~18.2.0",
47
+ "@stylistic/eslint-plugin": "^2.7.0",
48
+ "@typescript-eslint/parser": "^8.0.0",
49
+ "@typescript-eslint/types": "^8.0.0",
50
+ "@typescript-eslint/utils": "^8.0.0",
51
+ "angular-eslint": "^18.4.0",
52
+ "eslint": ">=8.57.0 <9.15.0",
53
+ "eslint-import-resolver-node": "^0.3.4",
54
+ "eslint-import-resolver-typescript": "^3.6.3",
55
+ "eslint-plugin-import": "^2.31.0",
56
+ "eslint-plugin-import-newlines": "^1.4.0",
57
+ "eslint-plugin-jest": "^28.0.0",
58
+ "eslint-plugin-jsdoc": "^48.11.0 || ^49.0.0 || ^50.0.0",
59
+ "eslint-plugin-prefer-arrow": "^1.2.2",
60
+ "eslint-plugin-unicorn": "^54.0.0 || ^55.0.0 || ^56.0.0",
61
+ "eslint-plugin-unused-imports": "^4.1.4",
62
+ "globals": "^15.9.0",
63
+ "globby": "^11.1.0",
64
+ "jest": "~29.7.0",
65
+ "jsonc-eslint-parser": "~2.4.0",
66
+ "ts-node": "~10.9.2",
67
+ "typescript": "~5.5.4",
68
+ "typescript-eslint": "^8.0.0"
69
+ },
70
+ "devDependencies": {
71
+ "@angular-devkit/core": "~18.2.0",
72
+ "@angular-devkit/schematics": "~18.2.0",
73
+ "@angular/compiler": "~18.2.0",
74
+ "@eslint-community/eslint-plugin-eslint-comments": "^4.4.0",
75
+ "@eslint/js": "~9.14.0",
76
+ "@nx/eslint-plugin": "~19.5.0",
77
+ "@o3r/build-helpers": "^11.6.0-prerelease.8",
78
+ "@o3r/eslint-plugin": "^11.6.0-prerelease.8",
79
+ "@o3r/schematics": "^11.6.0-prerelease.8",
80
+ "@o3r/test-helpers": "^11.6.0-prerelease.8",
81
+ "@schematics/angular": "~18.2.0",
82
+ "@stylistic/eslint-plugin": "~2.7.0",
83
+ "@types/eslint__js": "^8.42.3",
84
+ "@types/jest": "~29.5.2",
85
+ "@types/node": "^20.0.0",
86
+ "@typescript-eslint/parser": "~8.12.2",
87
+ "angular-eslint": "~18.4.0",
88
+ "cpy-cli": "^5.0.0",
89
+ "eslint": "~9.14.0",
90
+ "eslint-import-resolver-node": "^0.3.9",
91
+ "eslint-import-resolver-typescript": "^3.6.3",
92
+ "eslint-plugin-import": "^2.31.0",
93
+ "eslint-plugin-import-newlines": "^1.4.0",
94
+ "eslint-plugin-jest": "~28.8.0",
95
+ "eslint-plugin-jsdoc": "~50.2.0",
96
+ "eslint-plugin-prefer-arrow": "~1.2.3",
97
+ "eslint-plugin-unicorn": "^56.0.0",
98
+ "eslint-plugin-unused-imports": "^4.1.4",
99
+ "globals": "^15.9.0",
100
+ "jest": "~29.7.0",
101
+ "jest-junit": "~16.0.0",
102
+ "jsonc-eslint-parser": "~2.4.0",
103
+ "nx": "~19.5.0",
104
+ "pid-from-port": "^1.1.3",
105
+ "rxjs": "^7.8.1",
106
+ "semver": "^7.5.2",
107
+ "ts-jest": "~29.2.0",
108
+ "ts-node": "~10.9.2",
109
+ "tslib": "^2.6.2",
110
+ "typescript": "~5.5.4",
111
+ "typescript-eslint": "~8.12.2"
112
+ },
113
+ "peerDependenciesMeta": {
114
+ "@angular-devkit/core": {
115
+ "optional": true
116
+ },
117
+ "@angular-devkit/schematics": {
118
+ "optional": true
119
+ },
120
+ "@angular-eslint/builder": {
121
+ "optional": true
122
+ },
123
+ "@angular/compiler": {
124
+ "optional": true
125
+ },
126
+ "@o3r/schematics": {
127
+ "optional": true
128
+ },
129
+ "@schematics/angular": {
130
+ "optional": true
131
+ },
132
+ "@typescript-eslint/types": {
133
+ "optional": true
134
+ },
135
+ "@typescript-eslint/utils": {
136
+ "optional": true
137
+ },
138
+ "eslint-plugin-jest": {
139
+ "optional": true
140
+ },
141
+ "globby": {
142
+ "optional": true
143
+ },
144
+ "jest": {
145
+ "optional": true
146
+ },
147
+ "typescript": {
148
+ "optional": true
149
+ }
150
+ },
151
+ "schematics": "./collection.json",
152
+ "contributors": [
153
+ {
154
+ "name": "Yannick Adam",
155
+ "url": "https://github.com/yannickadam",
156
+ "email": "yannickadam@users.noreply.github.com"
157
+ },
158
+ {
159
+ "name": "Kilian Panot",
160
+ "url": "https://github.com/kpanot",
161
+ "email": "kpanot@users.noreply.github.com"
162
+ },
163
+ {
164
+ "name": "Jeremy Bourgeois",
165
+ "url": "https://github.com/jbourgeois-1A",
166
+ "email": "jbourgeois-1A@users.noreply.github.com"
167
+ },
168
+ {
169
+ "name": "Pierre Henri Ginoux",
170
+ "url": "https://github.com/pginoux-1A",
171
+ "email": "pginoux-1A@users.noreply.github.com"
172
+ },
173
+ {
174
+ "name": "Mircea Vasile Rednic",
175
+ "url": "https://github.com/mrednic-1A",
176
+ "email": "mrednic-1A@users.noreply.github.com"
177
+ },
178
+ {
179
+ "name": "Stephane Dalle",
180
+ "url": "https://github.com/sdalle-1A",
181
+ "email": "sdalle-1A@users.noreply.github.com"
182
+ },
183
+ {
184
+ "name": "Nicolas Hoffmann",
185
+ "url": "https://github.com/nhoffmann-1A",
186
+ "email": "nhoffmann-1A@users.noreply.github.com"
187
+ },
188
+ {
189
+ "name": "Victor Scaiceanu",
190
+ "url": "https://github.com/vscaiceanu-1a",
191
+ "email": "vscaiceanu-1A@users.noreply.github.com"
192
+ },
193
+ {
194
+ "name": "Florian Paul",
195
+ "url": "https://github.com/fpaul-1A",
196
+ "email": "fpaul-1A@users.noreply.github.com"
197
+ },
198
+ {
199
+ "name": "Corinne Paulve",
200
+ "url": "https://github.com/cpaulve-1A",
201
+ "email": "cpaulve-1A@users.noreply.github.com"
202
+ },
203
+ {
204
+ "name": "Matthieu Crouzet",
205
+ "url": "https://github.com/matthieu-crouzet",
206
+ "email": "matthieu-crouzet@users.noreply.github.com"
207
+ },
208
+ {
209
+ "name": "Salome Do",
210
+ "url": "https://github.com/sdo-1A",
211
+ "email": "sdo-1A@users.noreply.github.com"
212
+ }
213
+ ],
214
+ "bugs": "https://github.com/AmadeusITGroup/otter/issues",
215
+ "repository": {
216
+ "type": "git",
217
+ "url": "git+https://github.com/AmadeusITGroup/otter.git"
218
+ },
219
+ "license": "BSD-3-Clause",
220
+ "homepage": "https://amadeusitgroup.github.io/otter/"
221
+ }
@@ -0,0 +1,8 @@
1
+ import { type Rule } from '@angular-devkit/schematics';
2
+ /**
3
+ * Update ESLint Config
4
+ * @param rootPath
5
+ * @param projectName
6
+ */
7
+ export declare const updateEslintConfig: (rootPath: string, projectName?: string) => Rule;
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../schematics/ng-add/eslint/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAQL,KAAK,IAAI,EAGV,MAAM,4BAA4B,CAAC;AAqCpC;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,aAAc,MAAM,gBAAgB,MAAM,KAAG,IA4D3E,CAAC"}
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateEslintConfig = void 0;
4
+ const path = require("node:path");
5
+ const core_1 = require("@angular-devkit/core");
6
+ const schematics_1 = require("@angular-devkit/schematics");
7
+ const index_1 = require("../tsconfig/index");
8
+ const editAngularJson = (projectName, extension) => async (tree, context) => {
9
+ let workspace = null;
10
+ try {
11
+ const { getWorkspaceConfig } = await Promise.resolve().then(() => require('@o3r/schematics'));
12
+ workspace = getWorkspaceConfig(tree);
13
+ }
14
+ catch {
15
+ context.logger.warn(`No @o3r/schematics installed, we could not detect the workspace. The linter task for ${projectName} can not be added.`);
16
+ }
17
+ const workspaceProject = workspace?.projects[projectName];
18
+ if (!workspaceProject) {
19
+ context.logger.warn(`No project detected, the linter task for ${projectName} can not be added.`);
20
+ return;
21
+ }
22
+ workspaceProject.architect ||= {};
23
+ workspaceProject.architect.lint ||= {
24
+ builder: '@angular-eslint/builder:lint',
25
+ options: {
26
+ eslintConfig: `${workspaceProject.root}/eslint.config.${extension}`,
27
+ lintFilePatterns: [
28
+ `${workspaceProject.sourceRoot || path.posix.join(workspaceProject.root, 'src')}/**/*.ts`
29
+ ]
30
+ }
31
+ };
32
+ workspace.projects[projectName] = workspaceProject;
33
+ tree.overwrite('/angular.json', JSON.stringify(workspace, null, 2));
34
+ };
35
+ /**
36
+ * Update ESLint Config
37
+ * @param rootPath
38
+ * @param projectName
39
+ */
40
+ const updateEslintConfig = (rootPath, projectName) => async (tree, context) => {
41
+ const { findFilesInTree, getTemplateFolder, getWorkspaceConfig } = await Promise.resolve().then(() => require('@o3r/schematics'));
42
+ const workspace = getWorkspaceConfig(tree);
43
+ const workspaceProject = workspace?.projects[projectName || ''];
44
+ const projectRootPath = workspaceProject?.root || '.';
45
+ const workingDir = tree.getDir(projectRootPath);
46
+ const eslintConfigFiles = findFilesInTree(workingDir, (file) => /eslint.config.[cm]?js/.test(file));
47
+ if (eslintConfigFiles.length > 1) {
48
+ context.logger.warn('Unable to add the "@o3r/eslint-config" recommendation because several ESLint config file detected.\n'
49
+ + eslintConfigFiles.map((file) => `\t- ${file.path.toString()}`).join('\n'));
50
+ return;
51
+ }
52
+ const templateOptions = {
53
+ extension: 'mjs',
54
+ codeBeforeConfig: '',
55
+ codeAfterConfig: '',
56
+ oldConfig: '',
57
+ relativePathToRoot: path.posix.relative(projectRootPath, '.'),
58
+ packageName: tree.readJson(workingDir.file((0, core_1.fragment)('package.json'))?.path || 'package.json').name,
59
+ detectedTsConfigs: findFilesInTree(workingDir, (f) => /tsconfig\..*\.json/.test(f)).map((entry) => path.basename(entry.path)).concat('tsconfig.eslint.json'),
60
+ isApp: workspaceProject?.projectType === 'application'
61
+ };
62
+ if (eslintConfigFiles.length === 1) {
63
+ const file = eslintConfigFiles[0];
64
+ const filePath = file.path.toString();
65
+ const fileContent = file.content.toString();
66
+ const extension = path.extname(filePath);
67
+ const regexp = extension === 'mjs' ? /export\s+default\s+[^;]*;/ : /module.exports\s*=\s*[^;]*;/;
68
+ const [codeBeforeConfig, codeAfterConfig] = fileContent.split(regexp);
69
+ if (!codeAfterConfig) {
70
+ context.logger.warn(`Unable to add the "@o3r/eslint-config" recommendation because no ESLint config detected in ${filePath}`);
71
+ return;
72
+ }
73
+ const oldConfig = fileContent.match(regexp)[1];
74
+ templateOptions.extension = extension;
75
+ templateOptions.codeBeforeConfig = codeBeforeConfig;
76
+ templateOptions.codeAfterConfig = codeAfterConfig;
77
+ templateOptions.oldConfig = oldConfig;
78
+ tree.delete(filePath);
79
+ }
80
+ return (0, schematics_1.chain)([
81
+ projectName ? editAngularJson(projectName, templateOptions.extension) : (0, schematics_1.noop)(),
82
+ (0, schematics_1.applyToSubtree)(projectRootPath, [
83
+ (0, index_1.updateOrAddTsconfigEslint)(rootPath),
84
+ (0, schematics_1.mergeWith)((0, schematics_1.apply)((0, schematics_1.url)(getTemplateFolder(rootPath, __dirname, `./templates/${projectRootPath === '.' ? 'workspace' : 'project'}`)), [
85
+ (0, schematics_1.template)(templateOptions),
86
+ (0, schematics_1.renameTemplateFiles)()
87
+ ]), schematics_1.MergeStrategy.Overwrite)
88
+ ])
89
+ ]);
90
+ };
91
+ exports.updateEslintConfig = updateEslintConfig;
92
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../schematics/ng-add/eslint/index.ts"],"names":[],"mappings":";;;AAAA,kCAAkC;AAClC,+CAG8B;AAC9B,2DAWoC;AAIpC,6CAE2B;AAE3B,MAAM,eAAe,GAAG,CAAC,WAAmB,EAAE,SAAiB,EAAQ,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE;IAChG,IAAI,SAAS,GAA2B,IAAI,CAAC;IAC7C,IAAI,CAAC;QACH,MAAM,EAAE,kBAAkB,EAAE,GAAG,2CAAa,iBAAiB,EAAC,CAAC;QAC/D,SAAS,GAAG,kBAAkB,CAAC,IAAI,CAAC,CAAC;IACvC,CAAC;I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AC,iBAAiB,CAAC,QAAQ,EAAE,SAAS,EAAE,eAAe,eAAe,KAAK,GAAG,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,EAAE;gBAC/H,IAAA,qBAAQ,EAAC,eAAe,CAAC;gBACzB,IAAA,gCAAmB,GAAE;aACtB,CAAC,EAAE,0BAAa,CAAC,SAAS,CAAC;SAC7B,CACF;KACF,CAAC,CAAC;AACL,CAAC,CAAC;AA5DW,QAAA,kBAAkB,sBA4D7B"}
@@ -0,0 +1,10 @@
1
+ <% if (extension === 'mjs') { %>import local from './eslint.local.config.mjs';
2
+ import shared from '<%= relativePathToRoot %>/eslint.shared.config.mjs';
3
+ <% } else { %>const local = require('./eslint.local.config.<%= extension %>');
4
+ const shared = require('<%= relativePathToRoot %>/eslint.shared.config.<%= extension %>');
5
+ <% } %>
6
+
7
+ <%= extension === 'mjs' ? 'export default' : 'module.exports =' %> [
8
+ ...shared,
9
+ ...local
10
+ ];
@@ -0,0 +1,27 @@
1
+ <% if (extension === 'mjs') { %>import { dirname } from 'node:path';
2
+ import { fileURLToPath } from 'node:url';
3
+ <% if (isApp) {
4
+ %>import globals from 'globals';<%
5
+ } %>
6
+ const __filename = fileURLToPath(import.meta.url);
7
+ // __dirname is not defined in ES module scope
8
+ const __dirname = dirname(__filename);
9
+ <% } else if (isApp) { %>const globals = require('globals');
10
+ <% } %>
11
+ <%= extension === 'mjs' ? 'export default' : 'module.exports =' %> [
12
+ {
13
+ name: '<%= packageName %>/projects',
14
+ languageOptions: {
15
+ sourceType: 'module',
16
+ parserOptions: {
17
+ tsconfigRootDir: __dirname,
18
+ project: [
19
+ <%= detectedTsConfigs.map((tsconfig) => ` '${tsconfig}'`).join(',\n') %>
20
+ ]
21
+ }<% if (isApp) { %>,
22
+ globals: {
23
+ ...globals.browser
24
+ }<% } %>
25
+ }
26
+ }
27
+ ];
@@ -0,0 +1,67 @@
1
+ <% if (extension === 'mjs') { %>import {
2
+ dirname,
3
+ posix,
4
+ relative,
5
+ sep
6
+ } from 'node:path';
7
+ import {
8
+ fileURLToPath,
9
+ pathToFileURL
10
+ } from 'node:url';
11
+ import shared from './eslint.shared.config.mjs';
12
+ import {
13
+ sync
14
+ } from 'globby';
15
+
16
+ const __filename = fileURLToPath(import.meta.url);
17
+ // __dirname is not defined in ES module scope
18
+ const __dirname = dirname(__filename);
19
+ <% } else { %>
20
+ const { dirname, posix, relative, sep } = require('node:path');
21
+ const { sync } = require('globby');
22
+ const shared = require('./eslint.shared.config.<%= extension %>');
23
+ <% } %>
24
+
25
+ /**
26
+ * Add a prefix to a path glob
27
+ * @param {string} prefix
28
+ * @param {string | undefined} pathGlob
29
+ * @returns {string}
30
+ */
31
+ const addPrefix = (prefix, pathGlob = '**/*') => pathGlob.replace(/^(!?)(\.?\/)?/, `$1${prefix}/`).replaceAll(sep, posix.sep).replace(/^\//, '');
32
+
33
+ /**
34
+ * Merge ESLint config
35
+ * @param {string | string[]} globs List of globs to find ESLint config path
36
+ * @returns {Promise<import('@typescript-eslint/utils').TSESLint.FlatConfig.ConfigArray>}
37
+ */
38
+ const mergeESLintConfigs = async (globs) => {
39
+ const localConfigFiles = sync(globs, { absolute: true });
40
+ /** @type {import('@typescript-eslint/utils').TSESLint.FlatConfig.ConfigArray} */
41
+ let localConfigs = [];
42
+ for (const localConfigFile of localConfigFiles) {
43
+ const module = await import(pathToFileURL(localConfigFile));
44
+ const moduleConfig = await (module.default ?? module);
45
+ /** @type {import('@typescript-eslint/utils').TSESLint.FlatConfig.ConfigArray} */
46
+ const configArray = Array.isArray(moduleConfig) ? moduleConfig : [moduleConfig];
47
+ const directory = relative(__dirname, dirname(localConfigFile));
48
+ localConfigs = localConfigs.concat(
49
+ configArray.map((config) => ({
50
+ ...config,
51
+ files: (config.files || ['**/*']).flat().map((pathGlob) => addPrefix(directory, pathGlob)),
52
+ ...(
53
+ config.ignores
54
+ ? { ignores: config.ignores.map((pathGlob) => addPrefix(directory, pathGlob)) }
55
+ : {}
56
+ )
57
+ }))
58
+ );
59
+ }
60
+
61
+ return [
62
+ ...shared,
63
+ ...localConfigs
64
+ ];
65
+ };
66
+
67
+ <%= extension === 'mjs' ? 'export default' : 'module.exports =' %> mergeESLintConfigs('**/eslint.local.config.mjs');
@@ -0,0 +1,22 @@
1
+ <% if (extension === 'mjs') { %>import { dirname } from 'node:path';
2
+ import { fileURLToPath } from 'node:url';
3
+
4
+ const __filename = fileURLToPath(import.meta.url);
5
+ // __dirname is not defined in ES module scope
6
+ const __dirname = dirname(__filename);
7
+
8
+ <% } %><%= codeBeforeConfig %><%= extension === 'mjs' ? 'export default' : 'module.exports =' %> [
9
+ {
10
+ name: '<%= packageName %>/projects',
11
+ languageOptions: {
12
+ sourceType: 'commonjs',
13
+ parserOptions: {
14
+ tsconfigRootDir: __dirname,
15
+ project: [
16
+ <%= detectedTsConfigs.map((tsconfig) => ` '${tsconfig}'`).join(',\n') %>
17
+ ]
18
+ }
19
+ }
20
+ }
21
+ ].concat(<%= oldConfig %>);
22
+ <%= codeAfterConfig %>
@@ -0,0 +1,41 @@
1
+ <% if (extension === 'mjs') { %>import o3rConfig from '@o3r/eslint-config';
2
+ import o3rTemplate from '@o3r/eslint-config/template';
3
+ <% } else { %>const o3rConfig = require('@o3r/eslint-config');
4
+ const o3rTemplate = require('@o3r/eslint-config/template');
5
+ <% } %>
6
+
7
+ <%= extension === 'mjs' ? 'export default' : 'module.exports =' %> [
8
+ ...o3rConfig,
9
+ ...o3rTemplate,
10
+ {
11
+ name: '<%= packageName %>/report-unused-disable-directives',
12
+ linterOptions: {
13
+ reportUnusedDisableDirectives: 'error'
14
+ }
15
+ },
16
+ {
17
+ name: '<%= packageName %>/settings',
18
+ settings: {
19
+ 'import/resolver': {
20
+ node: true,
21
+ typescript: {
22
+ project: [
23
+ <%= detectedTsConfigs.map((tsconfig) => ` '${tsconfig}'`).join(',\n') %>
24
+ ]
25
+ }
26
+ }
27
+ }
28
+ }<% if (extension === 'mjs') { %>,
29
+ {
30
+ name: '<%= packageName %>/eslint-config',
31
+ files: ['**/eslint*.config.mjs'],
32
+ rules: {
33
+ 'no-underscore-dangle': [
34
+ 'error',
35
+ {
36
+ allow: ['__filename', '__dirname']
37
+ }
38
+ ]
39
+ }
40
+ }<% } %>
41
+ ];
@@ -0,0 +1,8 @@
1
+ import { type Rule } from '@angular-devkit/schematics';
2
+ import type { NgAddSchematicsSchema } from './schema';
3
+ /**
4
+ * Add Otter eslint-config to an Angular Project
5
+ * @param options Options for the schematic
6
+ */
7
+ export declare const ngAdd: (options: NgAddSchematicsSchema) => Rule;
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../schematics/ng-add/index.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,IAAI,EAGV,MAAM,4BAA4B,CAAC;AAIpC,OAAO,KAAK,EACV,qBAAqB,EACtB,MAAM,UAAU,CAAC;AAiIlB;;;GAGG;AACH,eAAO,MAAM,KAAK,YAAa,qBAAqB,KAAG,IAGtD,CAAC"}