@o3r/eslint-plugin 10.0.0-next.9 → 11.0.0-next.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.
Files changed (35) hide show
  1. package/README.md +1 -1
  2. package/package.json +44 -29
  3. package/src/index.d.ts +1 -0
  4. package/src/index.js +34 -3
  5. package/src/public_api.d.ts +1 -0
  6. package/src/rules/json/json-dependency-versions-harmonize/json-dependency-versions-harmonize.d.ts +15 -0
  7. package/src/rules/json/json-dependency-versions-harmonize/json-dependency-versions-harmonize.js +123 -0
  8. package/src/rules/json/json-dependency-versions-harmonize/version-harmonize.d.ts +40 -0
  9. package/src/rules/json/json-dependency-versions-harmonize/version-harmonize.js +96 -0
  10. package/src/rules/json/utils.d.ts +39 -0
  11. package/src/rules/json/utils.js +60 -0
  12. package/src/rules/template/no-inner-html/no-inner-html.d.ts +5 -0
  13. package/src/rules/template/no-inner-html/no-inner-html.js +57 -0
  14. package/src/rules/template/template-async-number-limitation/template-async-number-limitation.d.ts +7 -0
  15. package/src/rules/{template-async-number-limitation → template/template-async-number-limitation}/template-async-number-limitation.js +4 -5
  16. package/src/rules/template/utils.d.ts +38 -0
  17. package/src/rules/{template-utils.js → template/utils.js} +0 -3
  18. package/src/rules/typescript/matching-configuration-name/matching-configuration-name.d.ts +5 -0
  19. package/src/rules/typescript/matching-configuration-name/matching-configuration-name.js +70 -0
  20. package/src/rules/typescript/no-folder-import-for-module/no-folder-import-for-module.d.ts +4 -0
  21. package/src/rules/{no-folder-import-for-module → typescript/no-folder-import-for-module}/no-folder-import-for-module.js +1 -1
  22. package/src/rules/typescript/no-multiple-type-configuration-property/no-multiple-type-configuration-property.d.ts +5 -0
  23. package/src/rules/typescript/no-multiple-type-configuration-property/no-multiple-type-configuration-property.js +71 -0
  24. package/src/rules/typescript/o3r-categories-tags/o3r-categories-tags.d.ts +7 -0
  25. package/src/rules/typescript/o3r-categories-tags/o3r-categories-tags.js +137 -0
  26. package/src/rules/typescript/o3r-widget-tags/o3r-widget-tags.d.ts +16 -0
  27. package/src/rules/typescript/o3r-widget-tags/o3r-widget-tags.js +255 -0
  28. package/src/rules/utils.d.ts +22 -0
  29. package/src/rules/utils.js +34 -1
  30. package/src/rules/yaml/utils.d.ts +22 -0
  31. package/src/rules/yaml/utils.js +42 -0
  32. package/src/rules/yaml/yarnrc-package-extensions-harmonize/yarnrc-package-extensions-harmonize.d.ts +12 -0
  33. package/src/rules/yaml/yarnrc-package-extensions-harmonize/yarnrc-package-extensions-harmonize.js +122 -0
  34. package/tsconfig.tsbuildinfo +1 -0
  35. package/schematics/ng-add/schema.json +0 -18
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  <h1 align="center">Otter eslint plugin</h1>
2
2
  <p align="center">
3
- <img src="https://raw.githubusercontent.com/AmadeusITGroup/otter/main/.attachments/otter.png" alt="Super cute Otter!" width="40%"/>
3
+ <img src="https://raw.githubusercontent.com/AmadeusITGroup/otter/main/assets/logo/otter.png" alt="Super cute Otter!" width="40%"/>
4
4
  </p>
5
5
 
6
6
  This package is an [Otter Framework Module](https://github.com/AmadeusITGroup/otter/tree/main/docs/core/MODULE.md).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@o3r/eslint-plugin",
3
- "version": "10.0.0-next.9",
3
+ "version": "11.0.0-next.0",
4
4
  "description": "The module provides in-house eslint plugins to use in your own eslint configuration.",
5
5
  "main": "./src/public_api.js",
6
6
  "keywords": [
@@ -17,55 +17,69 @@
17
17
  "build": "yarn nx build eslint-plugin",
18
18
  "postbuild": "patch-package-json-main",
19
19
  "prepare:publish": "prepare-publish ./dist",
20
- "prepare:build:builders": "yarn cpy 'schematics/**/*.json' dist/schematics && yarn cpy 'collection.json' dist",
20
+ "prepare:build:builders": "yarn cpy './collection.json' dist",
21
21
  "build:builders": "tsc -b tsconfig.builders.json --pretty && yarn generate-cjs-manifest"
22
22
  },
23
23
  "dependencies": {
24
24
  "@typescript-eslint/experimental-utils": "^5.3.0",
25
+ "globby": "^11.1.0",
26
+ "semver": "^7.5.2",
25
27
  "tslib": "^2.5.3"
26
28
  },
27
29
  "peerDependenciesMeta": {
28
30
  "@angular-eslint/template-parser": {
29
31
  "optional": true
32
+ },
33
+ "jsonc-eslint-parser": {
34
+ "optional": true
35
+ },
36
+ "yaml-eslint-parser": {
37
+ "optional": true
30
38
  }
31
39
  },
32
40
  "peerDependencies": {
33
- "@angular-eslint/template-parser": "~16.1.0",
34
- "@angular-eslint/utils": "~16.1.0",
35
- "@angular/compiler": "~16.2.0",
36
- "@typescript-eslint/eslint-plugin": "^5.9.0",
37
- "@typescript-eslint/parser": "^5.9.0",
38
- "eslint": "^8.22.0"
41
+ "@angular-eslint/template-parser": "~17.1.0",
42
+ "@angular-eslint/utils": "~17.1.0",
43
+ "@angular/compiler": "~17.0.2",
44
+ "@typescript-eslint/eslint-plugin": "^6.11.0",
45
+ "@typescript-eslint/parser": "^6.11.0",
46
+ "eslint": "^8.22.0",
47
+ "jsonc-eslint-parser": "~2.4.0",
48
+ "yaml-eslint-parser": "^1.2.2"
39
49
  },
40
50
  "devDependencies": {
41
- "@angular-devkit/core": "~16.2.0",
42
- "@angular-devkit/schematics": "~16.2.0",
43
- "@angular-eslint/eslint-plugin": "~16.1.0",
44
- "@angular-eslint/template-parser": "~16.1.0",
45
- "@angular-eslint/utils": "~16.1.0",
46
- "@angular/compiler": "~16.2.0",
47
- "@babel/core": "~7.22.0",
48
- "@babel/preset-typescript": "~7.22.0",
51
+ "@angular-devkit/core": "~17.0.3",
52
+ "@angular-devkit/schematics": "~17.0.3",
53
+ "@angular-eslint/eslint-plugin": "~17.1.0",
54
+ "@angular-eslint/template-parser": "~17.1.0",
55
+ "@angular-eslint/utils": "~17.1.0",
56
+ "@angular/compiler": "~17.0.4",
57
+ "@babel/core": "~7.23.0",
58
+ "@babel/preset-typescript": "~7.23.0",
49
59
  "@compodoc/compodoc": "^1.1.19",
50
- "@nx/jest": "~16.8.0",
51
- "@o3r/build-helpers": "^10.0.0-next.9",
52
- "@o3r/eslint-plugin": "^10.0.0-next.9",
60
+ "@nx/eslint-plugin": "~17.1.1",
61
+ "@nx/jest": "~17.1.1",
62
+ "@o3r/build-helpers": "^11.0.0-next.0",
53
63
  "@types/jest": "~29.5.2",
54
- "@types/node": "^18.0.0",
55
- "@typescript-eslint/eslint-plugin": "^5.59.9",
56
- "@typescript-eslint/parser": "^5.59.9",
57
- "cpy-cli": "^4.2.0",
64
+ "@types/node": "^20.0.0",
65
+ "@types/semver": "^7.3.13",
66
+ "@typescript-eslint/eslint-plugin": "6.11.0",
67
+ "@typescript-eslint/parser": "^6.11.0",
68
+ "cpy-cli": "^5.0.0",
58
69
  "eslint": "^8.42.0",
59
- "eslint-plugin-jest": "~27.2.3",
60
- "eslint-plugin-jsdoc": "~46.8.0",
70
+ "eslint-plugin-jest": "~27.6.0",
71
+ "eslint-plugin-jsdoc": "~48.0.0",
61
72
  "eslint-plugin-prefer-arrow": "~1.2.3",
62
- "eslint-plugin-unicorn": "^47.0.0",
73
+ "eslint-plugin-unicorn": "^50.0.0",
63
74
  "jest": "~29.7.0",
64
75
  "jest-junit": "~16.0.0",
65
- "nx": "~16.8.0",
76
+ "jsonc-eslint-parser": "~2.4.0",
77
+ "nx": "~17.1.1",
66
78
  "rimraf": "^5.0.1",
67
79
  "ts-jest": "~29.1.1",
68
- "typescript": "~5.1.6"
80
+ "type-fest": "^4.3.1",
81
+ "typescript": "~5.2.2",
82
+ "yaml-eslint-parser": "^1.2.2"
69
83
  },
70
84
  "schematics": "./collection.json",
71
85
  "type": "commonjs",
@@ -132,5 +146,6 @@
132
146
  ],
133
147
  "bugs": "https://github.com/AmadeusITGroup/otter/issues",
134
148
  "repository": "https://github.com/AmadeusITGroup/otter",
135
- "license": "BSD-3-Clause"
149
+ "license": "BSD-3-Clause",
150
+ "homepage": "https://amadeusitgroup.github.io/otter/"
136
151
  }
package/src/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export {};
package/src/index.js CHANGED
@@ -1,19 +1,40 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  /* eslint-disable @typescript-eslint/naming-convention */
4
- const no_folder_import_for_module_1 = require("./rules/no-folder-import-for-module/no-folder-import-for-module");
5
- const template_async_number_limitation_1 = require("./rules/template-async-number-limitation/template-async-number-limitation");
4
+ const no_folder_import_for_module_1 = require("./rules/typescript/no-folder-import-for-module/no-folder-import-for-module");
5
+ const o3r_widget_tags_1 = require("./rules/typescript/o3r-widget-tags/o3r-widget-tags");
6
+ const no_inner_html_1 = require("./rules/template/no-inner-html/no-inner-html");
7
+ const template_async_number_limitation_1 = require("./rules/template/template-async-number-limitation/template-async-number-limitation");
8
+ const json_dependency_versions_harmonize_1 = require("./rules/json/json-dependency-versions-harmonize/json-dependency-versions-harmonize");
9
+ const yarnrc_package_extensions_harmonize_1 = require("./rules/yaml/yarnrc-package-extensions-harmonize/yarnrc-package-extensions-harmonize");
10
+ const matching_configuration_name_1 = require("./rules/typescript/matching-configuration-name/matching-configuration-name");
11
+ const no_multiple_type_configuration_property_1 = require("./rules/typescript/no-multiple-type-configuration-property/no-multiple-type-configuration-property");
12
+ const o3r_categories_tags_1 = require("./rules/typescript/o3r-categories-tags/o3r-categories-tags");
6
13
  module.exports = {
7
14
  rules: {
8
15
  'no-folder-import-for-module': no_folder_import_for_module_1.default,
9
- 'template-async-number-limitation': template_async_number_limitation_1.default
16
+ 'no-inner-html': no_inner_html_1.default,
17
+ 'template-async-number-limitation': template_async_number_limitation_1.default,
18
+ 'o3r-widget-tags': o3r_widget_tags_1.default,
19
+ 'json-dependency-versions-harmonize': json_dependency_versions_harmonize_1.default,
20
+ 'matching-configuration-name': matching_configuration_name_1.default,
21
+ 'yarnrc-package-extensions-harmonize': yarnrc_package_extensions_harmonize_1.default,
22
+ 'no-multiple-type-configuration-property': no_multiple_type_configuration_property_1.default,
23
+ 'o3r-categories-tags': o3r_categories_tags_1.default
10
24
  },
11
25
  configs: {
12
26
  '@o3r/no-folder-import-for-module': 'error',
27
+ '@o3r/o3r-categories-tags': 'error',
28
+ '@o3r/json-dependency-versions-harmonize': 'error',
29
+ '@o3r/no-multiple-type-configuration-property': 'error',
13
30
  '@o3r/template-async-number-limitation': 'warn',
31
+ '@o3r/matching-configuration-name': 'warn',
14
32
  recommended: {
15
33
  rules: {
34
+ '@o3r/matching-configuration-name': 'error',
35
+ '@o3r/no-multiple-type-configuration-property': 'error',
16
36
  '@o3r/no-folder-import-for-module': 'error',
37
+ '@o3r/o3r-categories-tags': 'error',
17
38
  '@o3r/template-async-number-limitation': 'off'
18
39
  }
19
40
  },
@@ -22,6 +43,16 @@ module.exports = {
22
43
  '@o3r/no-folder-import-for-module': 'error',
23
44
  '@o3r/template-async-number-limitation': 'warn'
24
45
  }
46
+ },
47
+ 'json-recommended': {
48
+ rules: {
49
+ '@o3r/json-dependency-versions-harmonize': 'error'
50
+ }
51
+ },
52
+ 'yarn-recommended': {
53
+ rules: {
54
+ '@o3r/yarnrc-package-extensions-harmonize': 'error'
55
+ }
25
56
  }
26
57
  }
27
58
  };
@@ -0,0 +1 @@
1
+ export * from './index';
@@ -0,0 +1,15 @@
1
+ interface Options {
2
+ /** List of package name to ignore when determining the dependencies versions */
3
+ ignoredPackages: string[];
4
+ /** List of dependencies to ignore */
5
+ ignoredDependencies: string[];
6
+ /** List of dependency types to update */
7
+ dependencyTypes: string[];
8
+ /**
9
+ * Enforce to align the version of the dependencies with the latest range.
10
+ * If not set, the version will be aligned with the latest range if the latest range is not intersected with the current range.
11
+ */
12
+ alignPeerDependencies: boolean;
13
+ }
14
+ declare const _default: import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleModule<"error" | "versionUpdate", [Options, ...any[]], any>;
15
+ export default _default;
@@ -0,0 +1,123 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const path = require("node:path");
4
+ const semver = require("semver");
5
+ const utils_1 = require("../../utils");
6
+ const utils_2 = require("../utils");
7
+ const version_harmonize_1 = require("./version-harmonize");
8
+ const defaultOptions = [{
9
+ ignoredDependencies: [],
10
+ dependencyTypes: ['optionalDependencies', 'dependencies', 'devDependencies', 'peerDependencies', 'generatorDependencies'],
11
+ alignPeerDependencies: false,
12
+ ignoredPackages: []
13
+ }];
14
+ exports.default = (0, utils_1.createRule)({
15
+ name: 'json-dependency-versions-harmonize',
16
+ meta: {
17
+ hasSuggestions: true,
18
+ type: 'problem',
19
+ docs: {
20
+ description: 'Ensure that the package dependency versions are aligned with the other package of the workspace.',
21
+ recommended: 'error'
22
+ },
23
+ schema: [
24
+ {
25
+ type: 'object',
26
+ properties: {
27
+ alignPeerDependencies: {
28
+ type: 'boolean',
29
+ description: 'Enforce to align the version of the dependencies with the latest range.'
30
+ },
31
+ dependencyTypes: {
32
+ type: 'array',
33
+ description: 'List of dependency types to update',
34
+ default: defaultOptions[0].dependencyTypes,
35
+ items: {
36
+ type: 'string'
37
+ }
38
+ },
39
+ ignoredDependencies: {
40
+ type: 'array',
41
+ description: 'List of dependencies to ignore',
42
+ items: {
43
+ type: 'string'
44
+ }
45
+ },
46
+ ignoredPackages: {
47
+ type: 'array',
48
+ description: 'List of package name to ignore when determining the dependencies versions',
49
+ items: {
50
+ type: 'string'
51
+ }
52
+ }
53
+ },
54
+ additionalProperties: false
55
+ }
56
+ ],
57
+ messages: {
58
+ versionUpdate: 'Set version {{version}}',
59
+ error: '{{depName}} should be updated to version {{version}} (from: {{packageJsonFile}})'
60
+ },
61
+ fixable: 'code'
62
+ },
63
+ defaultOptions,
64
+ create: (context, [options]) => {
65
+ const parserServices = (0, utils_2.getJsoncParserServices)(context);
66
+ const dirname = path.dirname(context.getFilename());
67
+ const workspace = (0, version_harmonize_1.findWorkspacePackageJsons)(dirname);
68
+ const bestRanges = workspace && (0, version_harmonize_1.getBestRanges)(options.dependencyTypes, workspace.packages.filter(({ content }) => !content.name || !options.ignoredPackages.includes(content.name)));
69
+ const ignoredDependencies = options.ignoredDependencies.map((dep) => new RegExp(dep.replace(/[.+?^${}()|[\]\\]/g, '\\$&').replace(/\*/g, '.*')));
70
+ if (parserServices.isJSON) {
71
+ return {
72
+ // eslint-disable-next-line @typescript-eslint/naming-convention
73
+ 'JSONExpressionStatement': (node) => {
74
+ if (node.expression.type === 'JSONObjectExpression') {
75
+ const deps = node.expression.properties
76
+ .filter(({ key }) => options.dependencyTypes.includes(key.type === 'JSONLiteral' ? key.value.toString() : key.name));
77
+ if (deps.length > 0 && bestRanges) {
78
+ deps
79
+ .map((depGroup) => depGroup.value)
80
+ .filter((depGroup) => depGroup.type === 'JSONObjectExpression')
81
+ .forEach((depGroup) => {
82
+ depGroup.properties.forEach((dep) => {
83
+ const name = dep.key.type === 'JSONLiteral' ? dep.key.value.toString() : dep.key.name;
84
+ if (ignoredDependencies.some((ignore) => ignore.test(name))) {
85
+ return;
86
+ }
87
+ const range = dep.value.type === 'JSONLiteral' ? dep.value.value : (dep.value.type === 'JSONIdentifier' ? dep.value.name : undefined);
88
+ const bestRange = (0, version_harmonize_1.getBestRange)(range, bestRanges[name]?.range);
89
+ if (bestRange && bestRange !== range) {
90
+ if (!options.alignPeerDependencies && depGroup.parent.type === 'JSONProperty' && range &&
91
+ (depGroup.parent.key.type === 'JSONLiteral' ? depGroup.parent.key.value.toString() : depGroup.parent.key.name) === 'peerDependencies' &&
92
+ semver.subset(bestRange, range)) {
93
+ return;
94
+ }
95
+ context.report({
96
+ loc: dep.value.loc,
97
+ messageId: 'error',
98
+ data: {
99
+ depName: name,
100
+ version: bestRange,
101
+ packageJsonFile: bestRanges[name].path
102
+ },
103
+ fix: (fixer) => fixer.replaceTextRange(dep.value.range, `"${bestRange}"`),
104
+ suggest: [
105
+ {
106
+ messageId: 'versionUpdate',
107
+ data: {
108
+ version: bestRange
109
+ },
110
+ fix: (fixer) => fixer.replaceTextRange(dep.value.range, `"${bestRange}"`)
111
+ }
112
+ ]
113
+ });
114
+ }
115
+ });
116
+ });
117
+ }
118
+ }
119
+ }
120
+ };
121
+ }
122
+ }
123
+ });
@@ -0,0 +1,40 @@
1
+ import type { PackageJson } from 'type-fest';
2
+ /** List of packages information resulting of a package.json discovery */
3
+ export interface PackageProperty {
4
+ /** List of package.json file information */
5
+ packages: {
6
+ /** Parsed package.json content */
7
+ content: PackageJson;
8
+ /** Path to the file */
9
+ path: string;
10
+ /** Determine if the package.json has a workspace information */
11
+ isWorkspace?: boolean;
12
+ }[];
13
+ /** Determine if the package.json collection is the result of a default strategy (in the case no matching workspace has been found) */
14
+ hasDefaulted?: boolean;
15
+ }
16
+ /** Range discovered for a given dependency */
17
+ export interface RangeInformation {
18
+ /** Range as specified in the package.json dependencies */
19
+ range: string;
20
+ /** Path to the original package.json */
21
+ path: string;
22
+ }
23
+ /**
24
+ * Find the closest package.json file containing workspace definition in the parent directories
25
+ * @param directory Current directory to search for
26
+ * @param rootDir First directory of the recursion
27
+ */
28
+ export declare const findWorkspacePackageJsons: (directory: string, rootDir?: string) => PackageProperty | undefined;
29
+ /**
30
+ * Compare and return the best range in the both given onces
31
+ * @param currentRange Current range in the memory stack
32
+ * @param range Range to compare the current one to
33
+ */
34
+ export declare const getBestRange: (currentRange?: string, range?: string) => string | undefined;
35
+ /**
36
+ * Retrieve the best ranges for each dependencies in the given package.json files
37
+ * @param dependencyTypes Type of dependency files to analyze
38
+ * @param packages List of the package.json files
39
+ */
40
+ export declare const getBestRanges: (dependencyTypes: string[], packages: PackageProperty['packages']) => Record<string, RangeInformation>;
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getBestRanges = exports.getBestRange = exports.findWorkspacePackageJsons = void 0;
4
+ const semver = require("semver");
5
+ const node_fs_1 = require("node:fs");
6
+ const node_path_1 = require("node:path");
7
+ const globby_1 = require("globby");
8
+ /**
9
+ * Find the closest package.json file containing workspace definition in the parent directories
10
+ * @param directory Current directory to search for
11
+ * @param rootDir First directory of the recursion
12
+ */
13
+ const findWorkspacePackageJsons = (directory, rootDir) => {
14
+ const parentFolder = (0, node_path_1.dirname)(directory);
15
+ rootDir ||= directory;
16
+ if (parentFolder === directory) {
17
+ return undefined;
18
+ }
19
+ const packageJsonPath = (0, node_path_1.resolve)(directory, 'package.json');
20
+ const content = (0, node_fs_1.existsSync)(packageJsonPath) && JSON.parse((0, node_fs_1.readFileSync)(packageJsonPath, { encoding: 'utf-8' }));
21
+ if (!content || !content.workspaces) {
22
+ return (0, exports.findWorkspacePackageJsons)(parentFolder, rootDir);
23
+ }
24
+ const packagePaths = (0, globby_1.sync)((Array.isArray(content.workspaces) ? content.workspaces : content.workspaces.packages || []).map((f) => node_path_1.posix.join(f, 'package.json')), { cwd: directory, onlyFiles: false, absolute: true });
25
+ const isPackageWorkspace = packagePaths.some((workspacePath) => (0, node_path_1.normalize)(workspacePath) === rootDir);
26
+ const getPackages = () => ([
27
+ { content, path: packageJsonPath, isWorkspace: true },
28
+ ...packagePaths.map((subPackageJsonPath) => ({ content: JSON.parse((0, node_fs_1.readFileSync)(subPackageJsonPath, { encoding: 'utf-8' })), path: subPackageJsonPath }))
29
+ ]);
30
+ if (isPackageWorkspace) {
31
+ return {
32
+ packages: getPackages()
33
+ };
34
+ }
35
+ else { // In case we discover a workspace for which the package is not part of
36
+ const parent = (0, exports.findWorkspacePackageJsons)(parentFolder, rootDir);
37
+ if (!parent || parent.hasDefaulted) {
38
+ return {
39
+ hasDefaulted: true,
40
+ packages: getPackages()
41
+ };
42
+ }
43
+ }
44
+ };
45
+ exports.findWorkspacePackageJsons = findWorkspacePackageJsons;
46
+ /**
47
+ * Compare and return the best range in the both given onces
48
+ * @param currentRange Current range in the memory stack
49
+ * @param range Range to compare the current one to
50
+ */
51
+ const getBestRange = (currentRange, range) => {
52
+ if (!range || !semver.validRange(range)) {
53
+ return currentRange && semver.validRange(currentRange) ? currentRange : undefined;
54
+ }
55
+ if (!currentRange || !semver.validRange(currentRange)) {
56
+ return range;
57
+ }
58
+ if (currentRange !== range) {
59
+ const minVersion = semver.minVersion(range);
60
+ const currentMinVersion = semver.minVersion(currentRange);
61
+ if (semver.gt(minVersion, currentMinVersion)) {
62
+ return range;
63
+ }
64
+ else if (semver.eq(minVersion, currentMinVersion) && semver.subset(range, currentRange)) {
65
+ return range;
66
+ }
67
+ }
68
+ return currentRange;
69
+ };
70
+ exports.getBestRange = getBestRange;
71
+ /**
72
+ * Retrieve the best ranges for each dependencies in the given package.json files
73
+ * @param dependencyTypes Type of dependency files to analyze
74
+ * @param packages List of the package.json files
75
+ */
76
+ const getBestRanges = (dependencyTypes, packages) => {
77
+ return packages.reduce((acc, pck) => {
78
+ dependencyTypes.forEach((depType) => {
79
+ const dependencies = pck.content[depType];
80
+ if (dependencies) {
81
+ Object.entries(dependencies).forEach(([depName, range]) => {
82
+ if (!acc[depName]) {
83
+ if (range) {
84
+ acc[depName] = { range, path: (0, node_path_1.normalize)(pck.path) };
85
+ }
86
+ }
87
+ else if ((0, exports.getBestRange)(acc[depName].range, range) !== acc[depName].range) {
88
+ acc[depName] = { range: range, path: (0, node_path_1.normalize)(pck.path) };
89
+ }
90
+ });
91
+ }
92
+ });
93
+ return acc;
94
+ }, {});
95
+ };
96
+ exports.getBestRanges = getBestRanges;
@@ -0,0 +1,39 @@
1
+ import { ParserServices, TSESLint } from '@typescript-eslint/experimental-utils';
2
+ import type { AST } from 'jsonc-eslint-parser';
3
+ /** Basic interface for the Parser Services object provided by jsonc-eslint-parser */
4
+ interface JsoncParserServices extends ParserServices {
5
+ isJSON: boolean;
6
+ }
7
+ /**
8
+ * Determine if jsonc-eslint-parser is used
9
+ * @param parserServices Parser services object
10
+ */
11
+ export declare function isJsoncParserServices(parserServices: any): parserServices is JsoncParserServices;
12
+ /**
13
+ *
14
+ * @param node
15
+ * @param node.type
16
+ */
17
+ export declare function isProperty(node?: {
18
+ type: string;
19
+ }): node is AST.JSONProperty;
20
+ /**
21
+ *
22
+ * @param node
23
+ * @param node.type
24
+ */
25
+ export declare function isObjectExpression(node?: {
26
+ type: string;
27
+ }): node is AST.JSONObjectExpression;
28
+ /**
29
+ * Retrieve the json parser services object or throw if the invalid parser is used
30
+ * @param context Rule context
31
+ */
32
+ export declare function getJsoncParserServices(context: Readonly<TSESLint.RuleContext<string, readonly unknown[]>>): JsoncParserServices;
33
+ /**
34
+ * Utility for rule authors to ensure that their rule is correctly being used with jsonc-eslint-parser
35
+ * If jsonc-eslint-parser is not the configured parser when the function is invoked it will throw
36
+ * @param context
37
+ */
38
+ export declare function ensureJsoncParser(context: Readonly<TSESLint.RuleContext<string, readonly unknown[]>>): void;
39
+ export {};
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ensureJsoncParser = exports.getJsoncParserServices = exports.isObjectExpression = exports.isProperty = exports.isJsoncParserServices = void 0;
4
+ /**
5
+ * Determine if jsonc-eslint-parser is used
6
+ * @param parserServices Parser services object
7
+ */
8
+ function isJsoncParserServices(parserServices) {
9
+ return !!parserServices && typeof parserServices.isJSON !== undefined;
10
+ }
11
+ exports.isJsoncParserServices = isJsoncParserServices;
12
+ /**
13
+ *
14
+ * @param node
15
+ * @param node.type
16
+ */
17
+ function isProperty(node) {
18
+ return !!node && node.type !== 'JSONProperty';
19
+ }
20
+ exports.isProperty = isProperty;
21
+ /**
22
+ *
23
+ * @param node
24
+ * @param node.type
25
+ */
26
+ function isObjectExpression(node) {
27
+ return !!node && node.type !== 'JSONObjectExpression';
28
+ }
29
+ exports.isObjectExpression = isObjectExpression;
30
+ /**
31
+ * Retrieve the json parser services object or throw if the invalid parser is used
32
+ * @param context Rule context
33
+ */
34
+ function getJsoncParserServices(context) {
35
+ const parserService = context.parserServices;
36
+ if (!isJsoncParserServices(parserService)) {
37
+ /*
38
+ * The user needs to have configured "parser" in their eslint config and set it
39
+ * to jsonc-eslint-parser
40
+ */
41
+ throw new Error('You have used a rule which requires \'jsonc-eslint-parser\' to be used as the \'parser\' in your ESLint config.');
42
+ }
43
+ return parserService;
44
+ }
45
+ exports.getJsoncParserServices = getJsoncParserServices;
46
+ /**
47
+ * Utility for rule authors to ensure that their rule is correctly being used with jsonc-eslint-parser
48
+ * If jsonc-eslint-parser is not the configured parser when the function is invoked it will throw
49
+ * @param context
50
+ */
51
+ function ensureJsoncParser(context) {
52
+ if (!(context.parserServices)) {
53
+ /*
54
+ * The user needs to have configured "parser" in their eslint config and set it
55
+ * to jsonc-eslint-parser
56
+ */
57
+ throw new Error('You have used a rule which requires \'jsonc-eslint-parser\' to be used as the \'parser\' in your ESLint config.');
58
+ }
59
+ }
60
+ exports.ensureJsoncParser = ensureJsoncParser;
@@ -0,0 +1,5 @@
1
+ /** Rule Name */
2
+ export declare const name = "no-inner-html";
3
+ type Messages = 'error' | 'fix';
4
+ declare const _default: import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleModule<Messages, [], import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleListener>;
5
+ export default _default;
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.name = void 0;
4
+ const utils_1 = require("../utils");
5
+ const utils_2 = require("../../utils");
6
+ /** Rule Name */
7
+ exports.name = 'no-inner-html';
8
+ exports.default = (0, utils_2.createRule)({
9
+ name: exports.name,
10
+ defaultOptions: [],
11
+ meta: {
12
+ type: 'problem',
13
+ hasSuggestions: true,
14
+ docs: {
15
+ description: 'Ensures that your template does not use innerHTML',
16
+ recommended: 'warn'
17
+ },
18
+ schema: [],
19
+ messages: {
20
+ error: 'Unexpected use of innerHTML',
21
+ fix: 'Replace innerHTML by innerText'
22
+ },
23
+ fixable: 'code'
24
+ },
25
+ create: (context) => {
26
+ // To throw error if use without @angular-eslint/template-parser
27
+ (0, utils_1.getTemplateParserServices)(context);
28
+ return {
29
+ // eslint-disable-next-line @typescript-eslint/naming-convention
30
+ 'Element$1': (node) => {
31
+ const innerHTMLAttribute = node.attributes.find((a) => /innerHTML/i.test(a.name));
32
+ if (innerHTMLAttribute && innerHTMLAttribute.keySpan) {
33
+ context.report({
34
+ messageId: 'error',
35
+ loc: {
36
+ column: innerHTMLAttribute.keySpan.start.col,
37
+ line: innerHTMLAttribute.keySpan.start.line,
38
+ end: {
39
+ column: innerHTMLAttribute.keySpan.end.col,
40
+ line: innerHTMLAttribute.keySpan.end.line
41
+ },
42
+ start: {
43
+ column: innerHTMLAttribute.keySpan.start.col,
44
+ line: innerHTMLAttribute.keySpan.start.line
45
+ }
46
+ },
47
+ fix: (fixer) => fixer.replaceTextRange([innerHTMLAttribute.keySpan.start.offset, innerHTMLAttribute.keySpan.end.offset], 'innerText'),
48
+ suggest: [{
49
+ messageId: 'fix',
50
+ fix: (fixer) => fixer.replaceTextRange([innerHTMLAttribute.keySpan.start.offset, innerHTMLAttribute.keySpan.end.offset], 'innerText')
51
+ }]
52
+ });
53
+ }
54
+ }
55
+ };
56
+ }
57
+ });
@@ -0,0 +1,7 @@
1
+ interface Options {
2
+ maximumAsyncOnTag: number;
3
+ }
4
+ /** Rule Name */
5
+ export declare const name = "template-async-number-limitation";
6
+ declare const _default: import("@typescript-eslint/utils/dist/ts-eslint/Rule").RuleModule<"tooManyAsyncOnTag", [Options, ...any[]], any>;
7
+ export default _default;