@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
@@ -0,0 +1,128 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ngAdd = void 0;
4
+ const path = require("node:path");
5
+ const schematics_1 = require("@angular-devkit/schematics");
6
+ const index_1 = require("./eslint/index");
7
+ const index_2 = require("./vscode/index");
8
+ const reportMissingSchematicsDep = (logger) => (reason) => {
9
+ logger.error(`[ERROR]: Adding @o3r/eslint-config has failed.
10
+ You need to install '@o3r/schematics' package to be able to use the eslint-config package. Please run 'ng add @o3r/schematics' .`);
11
+ throw reason;
12
+ };
13
+ const handleOtterEslintErrors = (projectName) => async (tree, context) => {
14
+ if (!projectName) {
15
+ return;
16
+ }
17
+ const { getWorkspaceConfig } = await Promise.resolve().then(() => require('@o3r/schematics'));
18
+ const workspace = getWorkspaceConfig(tree);
19
+ if (!workspace) {
20
+ return;
21
+ }
22
+ const workspaceProject = workspace.projects[projectName];
23
+ if (!workspaceProject) {
24
+ context.logger.warn('No project detected, linter task can not be added.');
25
+ return;
26
+ }
27
+ const projectRoot = workspaceProject.root;
28
+ const mainTsPath = path.posix.join(projectRoot, 'src/main.ts');
29
+ if (tree.exists(mainTsPath)) {
30
+ const mainTsContent = tree.readText(mainTsPath);
31
+ tree.overwrite(mainTsPath, '/* eslint-disable no-console -- console.error is used to log error in the browser while initializing the Angular application */\n' + mainTsContent);
32
+ }
33
+ const appComponentPath = path.posix.join(projectRoot, 'src/app/app.component.ts');
34
+ if (tree.exists(appComponentPath)) {
35
+ const appComponentContent = tree.readText(appComponentPath);
36
+ tree.overwrite(appComponentPath, appComponentContent.replace(/^(\s+)(title =)/m, '$1public $2'));
37
+ }
38
+ context.logger.warn('Linter errors may occur and should be fixed by hand or by running the linter with the option `--fix`.');
39
+ };
40
+ function ngAddFn(options) {
41
+ /* ng add rules */
42
+ return async (tree, context) => {
43
+ let installJestPlugin = false;
44
+ try {
45
+ require.resolve('jest');
46
+ installJestPlugin = true;
47
+ }
48
+ catch { }
49
+ const devDependenciesToInstall = [
50
+ '@eslint-community/eslint-plugin-eslint-comments',
51
+ '@eslint/js',
52
+ '@o3r/eslint-plugin',
53
+ '@stylistic/eslint-plugin',
54
+ '@typescript-eslint/parser',
55
+ '@typescript-eslint/utils',
56
+ '@typescript-eslint/types',
57
+ 'angular-eslint',
58
+ 'eslint',
59
+ 'eslint-import-resolver-node',
60
+ 'eslint-import-resolver-typescript',
61
+ 'eslint-plugin-import',
62
+ 'eslint-plugin-import-newlines',
63
+ ...(installJestPlugin ? ['eslint-plugin-jest'] : []),
64
+ 'eslint-plugin-jsdoc',
65
+ 'eslint-plugin-prefer-arrow',
66
+ // TODO: reactivate once https://github.com/nirtamir2/eslint-plugin-sort-export-all/issues/18 is fixed
67
+ // 'eslint-plugin-sort-export-all',
68
+ 'eslint-plugin-unicorn',
69
+ 'eslint-plugin-unused-imports',
70
+ 'globby',
71
+ 'globals',
72
+ 'jsonc-eslint-parser',
73
+ 'typescript-eslint',
74
+ // TODO could be removed once #2482 is fixed
75
+ 'yaml-eslint-parser',
76
+ ...(options.projectName ? ['@angular-eslint/builder'] : [])
77
+ ];
78
+ const { getExternalDependenciesVersionRange, setupDependencies, getWorkspaceConfig, getO3rPeerDeps, getProjectNewDependenciesTypes, getPackageInstallConfig } = await Promise.resolve().then(() => require('@o3r/schematics'));
79
+ const depsInfo = getO3rPeerDeps(path.resolve(__dirname, '..', '..', 'package.json'), true, /^@(?:o3r|ama-sdk)/);
80
+ const workspaceProject = options.projectName ? getWorkspaceConfig(tree)?.projects[options.projectName] : undefined;
81
+ const { NodeDependencyType } = await Promise.resolve().then(() => require('@schematics/angular/utility/dependencies'));
82
+ const packageJsonPath = path.resolve(__dirname, '..', '..', 'package.json');
83
+ const dependencies = depsInfo.o3rPeerDeps.reduce((acc, dep) => {
84
+ acc[dep] = {
85
+ inManifest: [{
86
+ range: `${options.exactO3rVersion ? '' : '~'}${depsInfo.packageVersion}`,
87
+ types: getProjectNewDependenciesTypes(workspaceProject)
88
+ }],
89
+ ngAddOptions: { exactO3rVersion: options.exactO3rVersion }
90
+ };
91
+ return acc;
92
+ }, getPackageInstallConfig(packageJsonPath, tree, options.projectName, true, !!options.exactO3rVersion));
93
+ Object.entries(getExternalDependenciesVersionRange(devDependenciesToInstall, packageJsonPath, context.logger))
94
+ .forEach(([dep, range]) => {
95
+ dependencies[dep] = {
96
+ inManifest: [{
97
+ range,
98
+ types: [NodeDependencyType.Dev]
99
+ }]
100
+ };
101
+ });
102
+ return () => (0, schematics_1.chain)([
103
+ setupDependencies({
104
+ projectName: options.projectName,
105
+ dependencies,
106
+ ngAddToRun: depsInfo.o3rPeerDeps
107
+ }),
108
+ index_2.updateVscode,
109
+ (0, index_1.updateEslintConfig)(__dirname),
110
+ options.projectName && workspaceProject?.root
111
+ ? (0, schematics_1.chain)([
112
+ (0, index_1.updateEslintConfig)(__dirname, options.projectName),
113
+ options.fix ? handleOtterEslintErrors(options.projectName) : (0, schematics_1.noop)()
114
+ ])
115
+ : (0, schematics_1.noop)()
116
+ ])(tree, context);
117
+ };
118
+ }
119
+ /**
120
+ * Add Otter eslint-config to an Angular Project
121
+ * @param options Options for the schematic
122
+ */
123
+ const ngAdd = (options) => async (_, { logger }) => {
124
+ const { createSchematicWithMetricsIfInstalled } = await Promise.resolve().then(() => require('@o3r/schematics')).catch(reportMissingSchematicsDep(logger));
125
+ return createSchematicWithMetricsIfInstalled(ngAddFn)(options);
126
+ };
127
+ exports.ngAdd = ngAdd;
128
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../schematics/ng-add/index.ts"],"names":[],"mappings":";;;AAAA,kCAAkC;AAClC,2DAMoC;AACpC,0CAEwB;AAIxB,0CAEwB;AAExB,MAAM,0BAA0B,GAAG,CAAC,MAA2C,EAAE,EAAE,CAAC,CAAC,MAAW,EAAE,EAAE;IAClG,MAAM,CAAC,KAAK,CAAC;iIACkH,CAAC,CAAC;IACjI,MAAM,MAAM,CAAC;AACf,CAAC,CAAC;AAEF,MAAM,uBAAuB,GAAG,CAAC,WAAmB,EAAQ,EAAE,CAAC,KAAK,EAAE,IAAU,EAAE,OAAyB,EAAE,EAAE;IAC7G,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,OAAO;IACT,CAAC;IACD,MAAM,EAAE,kBAAkB,EAAE,GAAG,2CAAa,iBAAiB,EAAC,CAAC;IAC/D,MAAM,SAAS,GAAG,kBAAkB,CAAC,IAAI,CAAC,CAAC;IAC3C,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,OAAO;IACT,CAAC;IACD,MAAM,gBAAgB,GAAG,SAAS,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;IAEzD,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACtB,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,oDAAoD,CAAC,CAAC;QAC1E,OAAO;IACT,CAAC;IACD,MAAM,WAAW,GAAG,gBAAgB,CAA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C,IAAA,iBAAI,GAAE;SACX,CAAC,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACpB,CAAC,CAAC;AACJ,CAAC;AAED;;;GAGG;AACI,MAAM,KAAK,GAAG,CAAC,OAA8B,EAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;IACrF,MAAM,EAAE,qCAAqC,EAAE,GAAG,MAAM,qCAAO,iBAAiB,GAAE,KAAK,CAAC,0BAA0B,CAAC,MAAM,CAAC,CAAC,CAAC;IAC5H,OAAO,qCAAqC,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC;AACjE,CAAC,CAAC;AAHW,QAAA,KAAK,SAGhB"}
@@ -0,0 +1,10 @@
1
+ import type { SchematicOptionObject } from '@o3r/schematics';
2
+ export interface NgAddSchematicsSchema extends SchematicOptionObject {
3
+ /** Project name */
4
+ projectName?: string | undefined;
5
+ /** Use a pinned version for otter packages */
6
+ exactO3rVersion?: boolean;
7
+ /** Fix known issues with our ESLint config after Otter application or library generation */
8
+ fix?: boolean;
9
+ }
10
+ //# sourceMappingURL=schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../schematics/ng-add/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EACtB,MAAM,iBAAiB,CAAC;AAEzB,MAAM,WAAW,qBAAsB,SAAQ,qBAAqB;IAClE,mBAAmB;IACnB,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,8CAA8C;IAC9C,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,4FAA4F;IAC5F,GAAG,CAAC,EAAE,OAAO,CAAC;CACf"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../schematics/ng-add/schema.ts"],"names":[],"mappings":""}
@@ -0,0 +1,28 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema",
3
+ "$id": "ngAddSchematicsSchema",
4
+ "title": "Add Otter eslint config",
5
+ "description": "ngAdd Otter eslint config",
6
+ "properties": {
7
+ "projectName": {
8
+ "type": "string",
9
+ "description": "Project name",
10
+ "$default": {
11
+ "$source": "projectName"
12
+ }
13
+ },
14
+ "exactO3rVersion": {
15
+ "type": "boolean",
16
+ "description": "Use a pinned version for otter packages",
17
+ "default": false
18
+ },
19
+ "fix": {
20
+ "type": "boolean",
21
+ "description": "Fix known issues with our ESLint config after Otter application or library generation",
22
+ "default": false
23
+ }
24
+ },
25
+ "additionalProperties": true,
26
+ "required": [
27
+ ]
28
+ }
@@ -0,0 +1,8 @@
1
+ import { type Rule } from '@angular-devkit/schematics';
2
+ /**
3
+ * Update or add tsconfig.eslint.json file
4
+ * @param rootPath
5
+ * @param projectTsConfig
6
+ */
7
+ export declare const updateOrAddTsconfigEslint: (rootPath: string, projectTsConfig?: string) => Rule;
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../schematics/ng-add/tsconfig/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAKL,KAAK,IAAI,EAGV,MAAM,4BAA4B,CAAC;AAEpC;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,aAAc,MAAM,+BAAiC,IAa1F,CAAC"}
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateOrAddTsconfigEslint = void 0;
4
+ const schematics_1 = require("@angular-devkit/schematics");
5
+ /**
6
+ * Update or add tsconfig.eslint.json file
7
+ * @param rootPath
8
+ * @param projectTsConfig
9
+ */
10
+ const updateOrAddTsconfigEslint = (rootPath, projectTsConfig = 'tsconfig') => async (tree) => {
11
+ const tsconfigPath = 'tsconfig.eslint.json';
12
+ if (tree.exists(tsconfigPath)) {
13
+ const tsconfig = tree.readJson(tsconfigPath);
14
+ tsconfig.include = (tsconfig.include || []).concat(`eslint*.config.*js`);
15
+ tree.overwrite(tsconfigPath, JSON.stringify(tsconfig, null, 2));
16
+ return () => tree;
17
+ }
18
+ const { getTemplateFolder } = await Promise.resolve().then(() => require('@o3r/schematics'));
19
+ return () => (0, schematics_1.mergeWith)((0, schematics_1.apply)((0, schematics_1.url)(getTemplateFolder(rootPath, __dirname)), [
20
+ (0, schematics_1.template)({ projectTsConfig }),
21
+ (0, schematics_1.renameTemplateFiles)()
22
+ ]), schematics_1.MergeStrategy.Overwrite);
23
+ };
24
+ exports.updateOrAddTsconfigEslint = updateOrAddTsconfigEslint;
25
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../schematics/ng-add/tsconfig/index.ts"],"names":[],"mappings":";;;AAIA,2DAQoC;AAEpC;;;;GAIG;AACI,MAAM,yBAAyB,GAAG,CAAC,QAAgB,EAAE,eAAe,GAAG,UAAU,EAAQ,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;IAChH,MAAM,YAAY,GAAG,sBAAsB,CAAC;IAC5C,IAAI,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,EAAE,CAAC;QAC9B,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAe,CAAC;QAC3D,QAAQ,CAAC,OAAO,GAAG,CAAC,QAAQ,CAAC,OAAoB,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAC;QACtF,IAAI,CAAC,SAAS,CAAC,YAAY,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QAChE,OAAO,GAAG,EAAE,CAAC,IAAI,CAAC;IACpB,CAAC;IACD,MAAM,EAAE,iBAAiB,EAAE,GAAG,2CAAa,iBAAiB,EAAC,CAAC;IAC9D,OAAO,GAAG,EAAE,CAAC,IAAA,sBAAS,EAAC,IAAA,kBAAK,EAAC,IAAA,gBAAG,EAAC,iBAAiB,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC,EAAE;QACxE,IAAA,qBAAQ,EAAC,EAAE,eAAe,EAAE,CAAC;QAC7B,IAAA,gCAAmB,GAAE;KACtB,CAAC,EAAE,0BAAa,CAAC,SAAS,CAAC,CAAC;AAC/B,CAAC,CAAC;AAbW,QAAA,yBAAyB,6BAapC"}
@@ -0,0 +1,6 @@
1
+ {
2
+ "extends": "./<%= projectTsConfig %>",
3
+ "include": [
4
+ "eslint*.config.*js"
5
+ ]
6
+ }
@@ -0,0 +1,6 @@
1
+ import { type Rule } from '@angular-devkit/schematics';
2
+ /**
3
+ * Update VSCode recommendations and settings
4
+ */
5
+ export declare const updateVscode: Rule;
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../schematics/ng-add/vscode/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAEL,KAAK,IAAI,EACV,MAAM,4BAA4B,CAAC;AAoCpC;;GAEG;AACH,eAAO,MAAM,YAAY,EAAE,IAwB1B,CAAC"}
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateVscode = void 0;
4
+ const schematics_1 = require("@angular-devkit/schematics");
5
+ /**
6
+ * Update VSCode recommendations and settings
7
+ */
8
+ const updateVscode = async () => {
9
+ const { addVsCodeRecommendations } = await Promise.resolve().then(() => require('@o3r/schematics'));
10
+ return (0, schematics_1.chain)([
11
+ addVsCodeRecommendations(['dbaeumer.vscode-eslint']),
12
+ (tree) => {
13
+ const vscodeSettingsPath = '.vscode/settings.json';
14
+ const settings = (tree.exists(vscodeSettingsPath) ? (tree.readJson(vscodeSettingsPath) || {}) : {});
15
+ settings['eslint.useFlatConfig'] = true;
16
+ settings['editor.defaultFormatter'] = 'dbaeumer.vscode-eslint';
17
+ settings['editor.foldingImportsByDefault'] = true;
18
+ settings['eslint.rules.customizations'] = [
19
+ { rule: '@stylistic/*', fixable: true, severity: 'off' },
20
+ { rule: '!@stylistic/*', fixable: true, severity: 'info' }
21
+ ];
22
+ settings['editor.codeActionsOnSave'] ||= {};
23
+ settings['editor.codeActionsOnSave']['source.fixAll.eslint'] = 'explicit';
24
+ if (tree.exists(vscodeSettingsPath)) {
25
+ tree.overwrite(vscodeSettingsPath, JSON.stringify(settings, null, 2));
26
+ }
27
+ else {
28
+ tree.create(vscodeSettingsPath, JSON.stringify(settings, null, 2));
29
+ }
30
+ return tree;
31
+ }
32
+ ]);
33
+ };
34
+ exports.updateVscode = updateVscode;
35
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../schematics/ng-add/vscode/index.ts"],"names":[],"mappings":";;;AAGA,2DAGoC;AAoCpC;;GAEG;AACI,MAAM,YAAY,GAAS,KAAK,IAAI,EAAE;IAC3C,MAAM,EAAE,wBAAwB,EAAE,GAAG,2CAAa,iBAAiB,EAAC,CAAC;IACrE,OAAO,IAAA,kBAAK,EAAC;QACX,wBAAwB,CAAC,CAAC,wBAAwB,CAAC,CAAC;QACpD,CAAC,IAAI,EAAE,EAAE;YACP,MAAM,kBAAkB,GAAG,uBAAuB,CAAC;YACnD,MAAM,QAAQ,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,kBAAkB,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAmB,CAAC;YACtH,QAAQ,CAAC,sBAAsB,CAAC,GAAG,IAAI,CAAC;YACxC,QAAQ,CAAC,yBAAyB,CAAC,GAAG,wBAAwB,CAAC;YAC/D,QAAQ,CAAC,gCAAgC,CAAC,GAAG,IAAI,CAAC;YAClD,QAAQ,CAAC,6BAA6B,CAAC,GAAG;gBACxC,EAAE,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE;gBACxD,EAAE,IAAI,EAAE,eAAe,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE;aAC3D,CAAC;YACF,QAAQ,CAAC,0BAA0B,CAAC,KAAK,EAAE,CAAC;YAC5C,QAAQ,CAAC,0BAA0B,CAAC,CAAC,sBAAsB,CAAC,GAAG,UAAU,CAAC;YAC1E,IAAI,IAAI,CAAC,MAAM,CAAC,kBAAkB,CAAC,EAAE,CAAC;gBACpC,IAAI,CAAC,SAAS,CAAC,kBAAkB,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;YACxE,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC,MAAM,CAAC,kBAAkB,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;YACrE,CAAC;YACD,OAAO,IAAI,CAAC;QACd,CAAC;KACF,CAAC,CAAC;AACL,CAAC,CAAC;AAxBW,QAAA,YAAY,gBAwBvB"}
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "commonjs"
3
+ }
@@ -0,0 +1,17 @@
1
+ 'use strict';
2
+ /**
3
+ * Get the @o3r plugin
4
+ * @param {import('@typescript-eslint/utils').TSESLint.FlatConfig.Plugin} plugin
5
+ * @returns {import('@typescript-eslint/utils').TSESLint.FlatConfig.Config} config
6
+ */
7
+ const base = (plugin) => ({
8
+ name: '@o3r/eslint-config/base',
9
+ languageOptions: {
10
+ sourceType: 'module'
11
+ },
12
+ plugins: {
13
+ '@o3r': plugin
14
+ }
15
+ });
16
+
17
+ module.exports = base;
@@ -0,0 +1,27 @@
1
+ 'use strict';
2
+ const angular = require('angular-eslint');
3
+ const { convertWarningsToErrors } = require('../utils.cjs');
4
+
5
+ /**
6
+ * @type {import('@typescript-eslint/utils').TSESLint.FlatConfig.ConfigArray}
7
+ */
8
+ const config = [
9
+ {
10
+ name: '@o3r/eslint-config/eslint-comments',
11
+ files: [
12
+ '**/*.html'
13
+ ],
14
+ rules: {
15
+ ...convertWarningsToErrors(angular.configs.templateRecommended),
16
+ ...convertWarningsToErrors(angular.configs.templateAccessibility),
17
+ '@angular-eslint/template/interactive-supports-focus': [
18
+ 'error',
19
+ {
20
+ allowList: ['ngbNavLink']
21
+ }
22
+ ]
23
+ }
24
+ }
25
+ ];
26
+
27
+ module.exports = config;
@@ -0,0 +1,20 @@
1
+ 'use strict';
2
+ const o3rBaseConfig = require('../base.cjs');
3
+
4
+ /**
5
+ * Get the @o3r template recommended rules
6
+ * @param {import('@typescript-eslint/utils').TSESLint.FlatConfig.Plugin} plugin
7
+ * @returns {import('@typescript-eslint/utils').TSESLint.FlatConfig.ConfigArray} config
8
+ */
9
+ const o3rTemplateRecommended = (plugin) => [
10
+ o3rBaseConfig(plugin),
11
+ {
12
+ name: '@o3r/eslint-config/template-recommended',
13
+ files: ['**/*.html'],
14
+ rules: {
15
+ '@o3r/template-async-number-limitation': 'error'
16
+ }
17
+ }
18
+ ];
19
+
20
+ module.exports = o3rTemplateRecommended;
@@ -0,0 +1,23 @@
1
+ 'use strict';
2
+ const o3r = require('@o3r/eslint-plugin');
3
+ const angular = require('angular-eslint');
4
+ const angularOverrideConfig = require('./template/angular.cjs');
5
+ const o3rConfig = require('./template/otter.cjs');
6
+
7
+ /**
8
+ * @type {import('@typescript-eslint/utils').TSESLint.FlatConfig.ConfigArray}
9
+ */
10
+ const configArray = [
11
+ ...angular.configs.templateRecommended.map((config) => ({
12
+ files: ['**/*.html'],
13
+ ...config
14
+ })),
15
+ ...angular.configs.templateAccessibility.map((config) => ({
16
+ files: ['**/*.html'],
17
+ ...config
18
+ })),
19
+ ...angularOverrideConfig,
20
+ ...o3rConfig(o3r)
21
+ ];
22
+
23
+ module.exports = configArray;
@@ -0,0 +1,27 @@
1
+ 'use strict';
2
+ const comments = require('@eslint-community/eslint-plugin-eslint-comments/configs');
3
+ const { convertWarningsToErrors } = require('../utils.cjs');
4
+
5
+ /**
6
+ * @type {import('@typescript-eslint/utils').TSESLint.FlatConfig.ConfigArray}
7
+ */
8
+ const config = [
9
+ {
10
+ name: '@o3r/eslint-config/eslint-comments',
11
+ files: [
12
+ '**/*.{c,m,}{t,j}s'
13
+ ],
14
+ rules: {
15
+ ...convertWarningsToErrors(comments.recommended),
16
+ '@eslint-community/eslint-comments/disable-enable-pair': 'off',
17
+ '@eslint-community/eslint-comments/require-description': [
18
+ 'error',
19
+ {
20
+ ignore: ['eslint-enable']
21
+ }
22
+ ]
23
+ }
24
+ }
25
+ ];
26
+
27
+ module.exports = config;
@@ -0,0 +1,36 @@
1
+ 'use strict';
2
+ const angular = require('angular-eslint');
3
+ const { convertWarningsToErrors } = require('../utils.cjs');
4
+
5
+ /**
6
+ * @type {import('@typescript-eslint/utils').TSESLint.FlatConfig.ConfigArray}
7
+ */
8
+ const config = [
9
+ {
10
+ name: '@o3r/eslint-config/angular-eslint',
11
+ // Same files as the ones asked by `typescript-eslint/eslint-recommended`
12
+ files: ['**/*.ts', '**/*.tsx', '**/*.mts', '**/*.cts'],
13
+ rules: {
14
+ ...convertWarningsToErrors(angular.configs.tsRecommended),
15
+ '@angular-eslint/component-selector': [
16
+ 'error',
17
+ {
18
+ type: 'element',
19
+ style: 'kebab-case'
20
+ }
21
+ ],
22
+ '@angular-eslint/directive-class-suffix': 'off',
23
+ '@angular-eslint/directive-selector': [
24
+ 'error',
25
+ {
26
+ type: 'attribute',
27
+ style: 'camelCase'
28
+ }
29
+ ],
30
+ '@angular-eslint/no-empty-lifecycle-method': 'off',
31
+ '@angular-eslint/no-input-rename': 'off'
32
+ }
33
+ }
34
+ ];
35
+
36
+ module.exports = config;
@@ -0,0 +1,145 @@
1
+ 'use strict';
2
+ const typescript = require('typescript-eslint');
3
+ const { convertWarningsToErrors } = require('../utils.cjs');
4
+
5
+ /**
6
+ * @type {import('@typescript-eslint/utils').TSESLint.FlatConfig.ConfigArray}
7
+ */
8
+ const config = [
9
+ {
10
+ name: '@o3r/eslint-config/typescript-eslint',
11
+ // Same files as the ones asked by `typescript-eslint/eslint-recommended`
12
+ files: ['**/*.ts', '**/*.tsx', '**/*.mts', '**/*.cts'],
13
+ rules: {
14
+ ...convertWarningsToErrors(typescript.configs.recommended),
15
+ ...convertWarningsToErrors(typescript.configs.recommendedTypeChecked),
16
+ '@typescript-eslint/adjacent-overload-signatures': 'error',
17
+ '@typescript-eslint/array-type': [
18
+ 'error',
19
+ {
20
+ default: 'array'
21
+ }
22
+ ],
23
+ '@typescript-eslint/consistent-type-assertions': 'error',
24
+ '@typescript-eslint/dot-notation': 'error',
25
+ '@typescript-eslint/explicit-member-accessibility': [
26
+ 'error',
27
+ {
28
+ accessibility: 'explicit',
29
+ overrides: {
30
+ constructors: 'off'
31
+ }
32
+ }
33
+ ],
34
+ '@typescript-eslint/explicit-module-boundary-types': 'off',
35
+ '@typescript-eslint/member-ordering': [
36
+ 'error',
37
+ {
38
+ default: [
39
+ 'static-field',
40
+ 'instance-field',
41
+ 'constructor',
42
+ 'decorated-method',
43
+ 'private-instance-method',
44
+ 'protected-instance-method',
45
+ 'public-instance-method'
46
+ ]
47
+ }
48
+ ],
49
+ '@typescript-eslint/naming-convention': [
50
+ 'error',
51
+ {
52
+ selector: 'default',
53
+ format: ['camelCase'],
54
+ leadingUnderscore: 'allow',
55
+ trailingUnderscore: 'allow'
56
+ },
57
+ {
58
+ selector: 'variable',
59
+ format: ['camelCase', 'UPPER_CASE'],
60
+ leadingUnderscore: 'allow',
61
+ trailingUnderscore: 'allow'
62
+ },
63
+ {
64
+ selector: 'memberLike',
65
+ modifiers: ['private'],
66
+ format: ['camelCase', 'UPPER_CASE'],
67
+ leadingUnderscore: 'allow'
68
+ },
69
+ {
70
+ selector: 'typeLike',
71
+ format: ['PascalCase']
72
+ },
73
+ {
74
+ selector: 'property',
75
+ modifiers: ['readonly'],
76
+ format: ['camelCase', 'UPPER_CASE'],
77
+ leadingUnderscore: 'allow'
78
+ },
79
+ {
80
+ selector: 'enumMember',
81
+ format: ['camelCase', 'UPPER_CASE']
82
+ },
83
+ {
84
+ selector: 'import',
85
+ format: ['camelCase', 'PascalCase']
86
+ },
87
+ {
88
+ selector: 'objectLiteralProperty',
89
+ format: null
90
+ },
91
+ {
92
+ selector: 'variable',
93
+ modifiers: ['destructured'],
94
+ format: null
95
+ }
96
+ ],
97
+ '@typescript-eslint/no-dupe-class-members': 'error',
98
+ '@typescript-eslint/no-empty-function': 'off',
99
+ '@typescript-eslint/no-empty-object-type': 'off',
100
+ '@typescript-eslint/no-explicit-any': 'off',
101
+ '@typescript-eslint/no-inferrable-types': 'error',
102
+ '@typescript-eslint/no-misused-promises': [
103
+ 'error',
104
+ {
105
+ checksVoidReturn: false
106
+ }
107
+ ],
108
+ '@typescript-eslint/no-namespace': 'off',
109
+ '@typescript-eslint/no-non-null-asserted-optional-chain': 'off',
110
+ '@typescript-eslint/no-non-null-assertion': 'off',
111
+ '@typescript-eslint/no-parameter-properties': 'off',
112
+ '@typescript-eslint/no-redeclare': 'error',
113
+ '@typescript-eslint/no-shadow': [
114
+ 'error',
115
+ {
116
+ hoist: 'all'
117
+ }
118
+ ],
119
+ '@typescript-eslint/no-use-before-define': 'off',
120
+ '@typescript-eslint/no-unused-vars': [
121
+ 'error',
122
+ {
123
+ argsIgnorePattern: '^_',
124
+ caughtErrors: 'none',
125
+ ignoreRestSiblings: true
126
+ }
127
+ ],
128
+ '@typescript-eslint/prefer-for-of': 'error',
129
+ '@typescript-eslint/prefer-function-type': 'error',
130
+ '@typescript-eslint/prefer-readonly': 'error',
131
+ '@typescript-eslint/prefer-regexp-exec': 'off',
132
+ '@typescript-eslint/triple-slash-reference': [
133
+ 'error',
134
+ {
135
+ path: 'always',
136
+ types: 'prefer-import',
137
+ lib: 'always'
138
+ }
139
+ ],
140
+ '@typescript-eslint/unified-signatures': 'error'
141
+ }
142
+ }
143
+ ];
144
+
145
+ module.exports = config;