@o3r/eslint-plugin 11.6.0-prerelease.6 → 11.6.0-prerelease.60

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. package/package.json +31 -31
  2. package/schematics/ng-add/index.d.ts.map +1 -1
  3. package/src/index.js +20 -6
  4. package/src/public_api.d.ts +3 -0
  5. package/src/public_api.js +1 -0
  6. package/src/rules/json/json-dependency-versions-harmonize/json-dependency-versions-harmonize.d.ts +3 -2
  7. package/src/rules/json/json-dependency-versions-harmonize/json-dependency-versions-harmonize.js +60 -60
  8. package/src/rules/json/json-dependency-versions-harmonize/version-harmonize.js +1 -1
  9. package/src/rules/json/utils.js +2 -2
  10. package/src/rules/template/no-inner-html/no-inner-html.d.ts +1 -1
  11. package/src/rules/template/no-inner-html/no-inner-html.js +30 -31
  12. package/src/rules/template/template-async-number-limitation/template-async-number-limitation.d.ts +2 -2
  13. package/src/rules/template/template-async-number-limitation/template-async-number-limitation.js +24 -24
  14. package/src/rules/template/utils.js +3 -3
  15. package/src/rules/typescript/matching-configuration-name/matching-configuration-name.d.ts +1 -1
  16. package/src/rules/typescript/matching-configuration-name/matching-configuration-name.js +40 -40
  17. package/src/rules/typescript/no-folder-import-for-module/no-folder-import-for-module.d.ts +1 -1
  18. package/src/rules/typescript/no-folder-import-for-module/no-folder-import-for-module.js +28 -24
  19. package/src/rules/typescript/no-multiple-type-configuration-property/no-multiple-type-configuration-property.d.ts +1 -1
  20. package/src/rules/typescript/no-multiple-type-configuration-property/no-multiple-type-configuration-property.js +3 -5
  21. package/src/rules/typescript/o3r-categories-tags/o3r-categories-tags.d.ts +1 -1
  22. package/src/rules/typescript/o3r-categories-tags/o3r-categories-tags.js +82 -82
  23. package/src/rules/typescript/o3r-restriction-key-tags/o3r-restriction-key-tags.d.ts +8 -0
  24. package/src/rules/typescript/o3r-restriction-key-tags/o3r-restriction-key-tags.js +130 -0
  25. package/src/rules/typescript/o3r-widget-tags/o3r-widget-tags.d.ts +1 -1
  26. package/src/rules/typescript/o3r-widget-tags/o3r-widget-tags.js +142 -142
  27. package/src/rules/utils.d.ts +1 -1
  28. package/src/rules/utils.js +4 -7
  29. package/src/rules/yaml/utils.js +2 -2
  30. package/src/rules/yaml/yarnrc-package-extensions-harmonize/yarnrc-package-extensions-harmonize.d.ts +2 -2
  31. package/src/rules/yaml/yarnrc-package-extensions-harmonize/yarnrc-package-extensions-harmonize.js +19 -14
  32. package/tsconfig.build.tsbuildinfo +1 -0
  33. package/tsconfig.tsbuildinfo +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@o3r/eslint-plugin",
3
- "version": "11.6.0-prerelease.6",
3
+ "version": "11.6.0-prerelease.60",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -18,13 +18,14 @@
18
18
  "nx": "nx",
19
19
  "ng": "yarn nx",
20
20
  "build": "yarn nx build eslint-plugin",
21
+ "build:builders": "tsc -b tsconfig.builders.json --pretty && yarn generate-cjs-manifest",
22
+ "build:source": "tsc -b tsconfig.build.json --pretty && yarn cpy ./package.json dist",
21
23
  "postbuild": "patch-package-json-main",
22
24
  "prepare:publish": "prepare-publish ./dist",
23
- "prepare:build:builders": "yarn cpy 'schematics/**/*.json' 'schematics/**/templates/**' dist/schematics && yarn cpy './collection.json' dist",
24
- "build:builders": "tsc -b tsconfig.builders.json --pretty && yarn generate-cjs-manifest"
25
+ "prepare:build:builders": "yarn cpy 'schematics/**/*.json' 'schematics/**/templates/**' dist/schematics && yarn cpy './collection.json' dist"
25
26
  },
26
27
  "dependencies": {
27
- "@typescript-eslint/utils": "^7.14.1",
28
+ "@typescript-eslint/utils": "~8.18.0",
28
29
  "globby": "^11.1.0",
29
30
  "semver": "^7.5.2",
30
31
  "tslib": "^2.6.2",
@@ -45,62 +46,61 @@
45
46
  }
46
47
  },
47
48
  "peerDependencies": {
48
- "@angular-devkit/schematics": "~18.2.0",
49
- "@angular-eslint/template-parser": "~18.3.0",
50
- "@angular-eslint/test-utils": "~18.3.0",
51
- "@angular/compiler": "~18.2.0",
52
- "@stylistic/eslint-plugin-ts": "~2.4.0",
53
- "@typescript-eslint/eslint-plugin": "^7.0.1",
54
- "@typescript-eslint/parser": "^7.14.1",
55
- "@typescript-eslint/rule-tester": "^7.11.0",
56
- "eslint": "^8.57.0",
57
- "jsonc-eslint-parser": "~2.4.0",
49
+ "@angular-devkit/schematics": "^18.2.0",
50
+ "@angular-eslint/template-parser": "^18.4.0",
51
+ "@angular-eslint/test-utils": "^18.4.0",
52
+ "@angular/compiler": "^18.2.0",
53
+ "eslint": ">=8.57.0 <9.15.0",
54
+ "jsonc-eslint-parser": "^2.4.0",
58
55
  "yaml-eslint-parser": "^1.2.2"
59
56
  },
60
57
  "devDependencies": {
61
58
  "@angular-devkit/core": "~18.2.0",
62
59
  "@angular-devkit/schematics": "~18.2.0",
63
- "@angular-eslint/eslint-plugin": "~18.3.0",
64
- "@angular-eslint/template-parser": "~18.3.0",
65
- "@angular-eslint/test-utils": "~18.3.0",
60
+ "@angular-eslint/test-utils": "~18.4.0",
66
61
  "@angular/compiler": "~18.2.0",
67
62
  "@babel/core": "~7.26.0",
68
63
  "@babel/preset-typescript": "~7.26.0",
69
64
  "@compodoc/compodoc": "^1.1.19",
65
+ "@eslint-community/eslint-plugin-eslint-comments": "^4.4.0",
70
66
  "@eslint/eslintrc": "^3.0.0",
71
- "@nx/eslint-plugin": "~19.5.0",
72
- "@nx/jest": "~19.5.0",
73
- "@o3r/build-helpers": "^11.6.0-prerelease.6",
74
- "@o3r/test-helpers": "^11.6.0-prerelease.6",
75
- "@stylistic/eslint-plugin-ts": "~2.4.0",
67
+ "@nx/eslint-plugin": "~19.8.0",
68
+ "@nx/jest": "~19.8.0",
69
+ "@o3r/build-helpers": "^11.6.0-prerelease.60",
70
+ "@o3r/eslint-config": "^11.6.0-prerelease.60",
71
+ "@o3r/test-helpers": "^11.6.0-prerelease.60",
72
+ "@stylistic/eslint-plugin": "~2.7.0",
76
73
  "@types/eslint": "~9.6.0",
77
74
  "@types/jest": "~29.5.2",
78
75
  "@types/node": "^20.0.0",
79
76
  "@types/semver": "^7.3.13",
80
- "@typescript-eslint/eslint-plugin": "^7.14.1",
81
- "@typescript-eslint/parser": "^7.14.1",
82
- "@typescript-eslint/rule-tester": "^7.14.1",
77
+ "@typescript-eslint/parser": "~8.18.0",
78
+ "@typescript-eslint/rule-tester": "~8.18.0",
79
+ "angular-eslint": "~18.4.0",
83
80
  "cpy-cli": "^5.0.0",
84
- "eslint": "^8.57.0",
81
+ "eslint": "~9.14.0",
82
+ "eslint-plugin-import": "^2.31.0",
83
+ "eslint-plugin-import-newlines": "^1.4.0",
85
84
  "eslint-plugin-jest": "~28.8.0",
86
- "eslint-plugin-jsdoc": "~48.11.0",
85
+ "eslint-plugin-jsdoc": "~50.2.0",
87
86
  "eslint-plugin-prefer-arrow": "~1.2.3",
88
- "eslint-plugin-unicorn": "^54.0.0",
87
+ "eslint-plugin-unicorn": "^56.0.0",
88
+ "eslint-plugin-unused-imports": "^4.1.4",
89
+ "globals": "^15.9.0",
89
90
  "jest": "~29.7.0",
90
91
  "jest-junit": "~16.0.0",
91
92
  "jsonc-eslint-parser": "~2.4.0",
92
- "nx": "~19.5.0",
93
+ "nx": "~19.8.0",
93
94
  "pid-from-port": "^1.1.3",
94
95
  "rimraf": "^5.0.1",
95
96
  "semver": "^7.5.2",
96
97
  "ts-jest": "~29.2.0",
97
98
  "type-fest": "^4.10.2",
98
99
  "typescript": "~5.5.4",
100
+ "typescript-eslint": "~8.18.0",
99
101
  "yaml-eslint-parser": "^1.2.2"
100
102
  },
101
103
  "schematics": "./collection.json",
102
- "type": "commonjs",
103
- "types": "./src/public_api.d.ts",
104
104
  "contributors": [
105
105
  {
106
106
  "name": "Yannick Adam",
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../schematics/ng-add/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAEvD;;GAEG;AACH,wBAAgB,KAAK,IAAI,IAAI,CAG5B"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../schematics/ng-add/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,IAAI,EACL,MAAM,4BAA4B,CAAC;AAEpC;;GAEG;AACH,wBAAgB,KAAK,IAAI,IAAI,CAG5B"}
package/src/index.js CHANGED
@@ -1,15 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- /* eslint-disable @typescript-eslint/naming-convention */
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");
3
+ const json_dependency_versions_harmonize_1 = require("./rules/json/json-dependency-versions-harmonize/json-dependency-versions-harmonize");
6
4
  const no_inner_html_1 = require("./rules/template/no-inner-html/no-inner-html");
7
5
  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
6
  const matching_configuration_name_1 = require("./rules/typescript/matching-configuration-name/matching-configuration-name");
7
+ const no_folder_import_for_module_1 = require("./rules/typescript/no-folder-import-for-module/no-folder-import-for-module");
11
8
  const no_multiple_type_configuration_property_1 = require("./rules/typescript/no-multiple-type-configuration-property/no-multiple-type-configuration-property");
12
9
  const o3r_categories_tags_1 = require("./rules/typescript/o3r-categories-tags/o3r-categories-tags");
10
+ const o3r_restriction_key_tags_1 = require("./rules/typescript/o3r-restriction-key-tags/o3r-restriction-key-tags");
11
+ const o3r_widget_tags_1 = require("./rules/typescript/o3r-widget-tags/o3r-widget-tags");
12
+ const yarnrc_package_extensions_harmonize_1 = require("./rules/yaml/yarnrc-package-extensions-harmonize/yarnrc-package-extensions-harmonize");
13
13
  module.exports = {
14
14
  rules: {
15
15
  'no-folder-import-for-module': no_folder_import_for_module_1.default,
@@ -20,7 +20,8 @@ module.exports = {
20
20
  'matching-configuration-name': matching_configuration_name_1.default,
21
21
  'yarnrc-package-extensions-harmonize': yarnrc_package_extensions_harmonize_1.default,
22
22
  'no-multiple-type-configuration-property': no_multiple_type_configuration_property_1.default,
23
- 'o3r-categories-tags': o3r_categories_tags_1.default
23
+ 'o3r-categories-tags': o3r_categories_tags_1.default,
24
+ 'o3r-restriction-key-tags': o3r_restriction_key_tags_1.default
24
25
  },
25
26
  configs: {
26
27
  '@o3r/no-folder-import-for-module': 'error',
@@ -38,17 +39,30 @@ module.exports = {
38
39
  '@o3r/template-async-number-limitation': 'off'
39
40
  }
40
41
  },
42
+ // deprecated: should use `angular-template-recommended` instead. Will be removed in v13.
41
43
  'template-recommended': {
42
44
  rules: {
43
45
  '@o3r/no-folder-import-for-module': 'error',
44
46
  '@o3r/template-async-number-limitation': 'warn'
45
47
  }
46
48
  },
49
+ // deprecated: should use `monorepo-recommended` instead. Will be removed in v13.
47
50
  'json-recommended': {
48
51
  rules: {
49
52
  '@o3r/json-dependency-versions-harmonize': 'error'
50
53
  }
51
54
  },
55
+ 'angular-template-recommended': {
56
+ rules: {
57
+ '@o3r/no-inner-html': 'off',
58
+ '@o3r/template-async-number-limitation': 'error'
59
+ }
60
+ },
61
+ 'monorepo-recommended': {
62
+ rules: {
63
+ '@o3r/json-dependency-versions-harmonize': 'error'
64
+ }
65
+ },
52
66
  'yarn-recommended': {
53
67
  rules: {
54
68
  '@o3r/yarnrc-package-extensions-harmonize': 'error'
@@ -1 +1,4 @@
1
1
  export * from './index';
2
+ export type { NoMultipleTypeConfigurationPropertyOption } from './rules/typescript/no-multiple-type-configuration-property/no-multiple-type-configuration-property';
3
+ export type { O3rCategoriesTagsRuleOption } from './rules/typescript/o3r-categories-tags/o3r-categories-tags';
4
+ export type { O3rWidgetTagsRuleOption } from './rules/typescript/o3r-widget-tags/o3r-widget-tags';
package/src/public_api.js CHANGED
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
+ // eslint-disable-next-line import/export -- needed to export the eslint plugin in the same format as in index.ts
4
5
  tslib_1.__exportStar(require("./index"), exports);
@@ -1,4 +1,5 @@
1
- interface Options {
1
+ /** Options for the ESLint rule @o3r/json-dependency-versions-harmonize */
2
+ export interface VersionsHarmonizeOptions {
2
3
  /** List of package name to ignore when determining the dependencies versions */
3
4
  ignoredPackages?: string[];
4
5
  /** List of dependencies to ignore */
@@ -15,5 +16,5 @@ interface Options {
15
16
  /** Align the Engines versions */
16
17
  alignEngines?: boolean;
17
18
  }
18
- declare const _default: import("@typescript-eslint/utils/dist/ts-eslint").RuleModule<"error" | "versionUpdate", [Options, ...any[]], import("@typescript-eslint/utils/dist/ts-eslint").RuleListener>;
19
+ declare const _default: import("@typescript-eslint/utils/dist/ts-eslint").RuleModule<"error" | "versionUpdate", [VersionsHarmonizeOptions, ...any[]], unknown, import("@typescript-eslint/utils/dist/ts-eslint").RuleListener>;
19
20
  export default _default;
@@ -78,74 +78,74 @@ exports.default = (0, utils_1.createRule)({
78
78
  const workspace = (0, version_harmonize_1.findWorkspacePackageJsons)(dirname);
79
79
  const dependencyTypesWithInterest = [...options.dependencyTypes, ...(options.alignEngines ? [enginesField] : [])];
80
80
  const bestRanges = workspace && (0, version_harmonize_1.getBestRanges)(dependencyTypesWithInterest, workspace.packages.filter(({ content }) => !content.name || !options.ignoredPackages.includes(content.name)));
81
- const ignoredDependencies = options.ignoredDependencies.map((dep) => new RegExp(dep.replace(/[.+?^${}()|[\]\\]/g, '\\$&').replace(/\*/g, '.*')));
81
+ const ignoredDependencies = options.ignoredDependencies.map((dep) => new RegExp(dep.replace(/[$()+.?[\\\]^{|}]/g, '\\$&').replace(/\*/g, '.*')));
82
82
  const dependencyTypes = [...dependencyTypesWithInterest, ...(options.alignResolutions ? resolutionsFields : [])];
83
83
  if (parserServices.isJSON) {
84
- return {
85
- // eslint-disable-next-line @typescript-eslint/naming-convention
86
- 'JSONExpressionStatement': (node) => {
87
- if (node.expression.type === 'JSONObjectExpression') {
88
- const deps = node.expression.properties
89
- .filter(({ key }) => dependencyTypes.includes(key.type === 'JSONLiteral' ? key.value.toString() : key.name));
90
- if (deps.length > 0 && bestRanges) {
91
- deps
92
- .map((depGroup) => depGroup.value)
93
- .filter((depGroup) => depGroup.type === 'JSONObjectExpression')
94
- .forEach((depGroup) => {
95
- const report = (name, resolvedName, dep, range, bestRange) => {
96
- if (bestRange && bestRange !== range) {
97
- if (!options.alignPeerDependencies && depGroup.parent.type === 'JSONProperty' && range &&
98
- (depGroup.parent.key.type === 'JSONLiteral' ? depGroup.parent.key.value.toString() : depGroup.parent.key.name) === 'peerDependencies' &&
99
- semver.subset(bestRange, range)) {
100
- return;
101
- }
102
- context.report({
103
- loc: dep.value.loc,
104
- messageId: 'error',
105
- data: {
106
- depName: name,
107
- version: bestRange,
108
- packageJsonFile: bestRanges[resolvedName].path
109
- },
110
- fix: (fixer) => fixer.replaceTextRange(dep.value.range, `"${bestRange}"`),
111
- suggest: [
112
- {
113
- messageId: 'versionUpdate',
114
- data: {
115
- version: bestRange
116
- },
117
- fix: (fixer) => fixer.replaceTextRange(dep.value.range, `"${bestRange}"`)
118
- }
119
- ]
120
- });
84
+ const rule = (node) => {
85
+ if (node.expression.type === 'JSONObjectExpression') {
86
+ const deps = node.expression.properties
87
+ .filter(({ key }) => dependencyTypes.includes(key.type === 'JSONLiteral' ? key.value.toString() : key.name));
88
+ if (deps.length > 0 && bestRanges) {
89
+ deps
90
+ .map((depGroup) => depGroup.value)
91
+ .filter((depGroup) => depGroup.type === 'JSONObjectExpression')
92
+ .forEach((depGroup) => {
93
+ const report = (name, resolvedName, dep, range, bestRange) => {
94
+ if (bestRange && bestRange !== range) {
95
+ if (!options.alignPeerDependencies && depGroup.parent.type === 'JSONProperty' && range
96
+ && (depGroup.parent.key.type === 'JSONLiteral' ? depGroup.parent.key.value.toString() : depGroup.parent.key.name) === 'peerDependencies'
97
+ && semver.subset(bestRange, range)) {
98
+ return;
99
+ }
100
+ context.report({
101
+ loc: dep.value.loc,
102
+ messageId: 'error',
103
+ data: {
104
+ depName: name,
105
+ version: bestRange,
106
+ packageJsonFile: bestRanges[resolvedName].path
107
+ },
108
+ fix: (fixer) => fixer.replaceTextRange(dep.value.range, `"${bestRange}"`),
109
+ suggest: [
110
+ {
111
+ messageId: 'versionUpdate',
112
+ data: {
113
+ version: bestRange
114
+ },
115
+ fix: (fixer) => fixer.replaceTextRange(dep.value.range, `"${bestRange}"`)
116
+ }
117
+ ]
118
+ });
119
+ }
120
+ };
121
+ depGroup.properties.forEach((dependencyNode) => {
122
+ const isResolutionsField = options.alignResolutions && depGroup.parent.type === 'JSONProperty'
123
+ && resolutionsFields.includes(depGroup.parent.key.type === 'JSONLiteral' ? depGroup.parent.key.value.toString() : depGroup.parent.key.name);
124
+ const getNodeDetails = (dep) => {
125
+ const name = dep.key.type === 'JSONLiteral' ? dep.key.value.toString() : dep.key.name;
126
+ const nameParts = name.split('/');
127
+ if (ignoredDependencies.some((ignore) => ignore.test(name))) {
128
+ return;
129
+ }
130
+ const range = dep.value.type === 'JSONLiteral' ? dep.value.value : (dep.value.type === 'JSONIdentifier' ? dep.value.name : undefined);
131
+ if (!range && dep.value.type === 'JSONObjectExpression') {
132
+ return dep.value.properties
133
+ .forEach((prop) => getNodeDetails(prop));
121
134
  }
135
+ const resolutionSubNameIndex = isResolutionsField ? nameParts.findIndex((_, i) => !!bestRanges[nameParts.slice(nameParts.length - i).join('/')]) : -1;
136
+ const resolvedName = resolutionSubNameIndex > -1 ? nameParts.slice(nameParts.length - resolutionSubNameIndex).join('/') : name;
137
+ const bestRange = (0, version_harmonize_1.getBestRange)(range, bestRanges[resolvedName]?.range);
138
+ report(name, resolvedName, dep, range, bestRange);
122
139
  };
123
- depGroup.properties.forEach((dependencyNode) => {
124
- const isResolutionsField = options.alignResolutions && depGroup.parent.type === 'JSONProperty' &&
125
- resolutionsFields.includes(depGroup.parent.key.type === 'JSONLiteral' ? depGroup.parent.key.value.toString() : depGroup.parent.key.name);
126
- const getNodeDetails = (dep) => {
127
- const name = dep.key.type === 'JSONLiteral' ? dep.key.value.toString() : dep.key.name;
128
- const nameParts = name.split('/');
129
- if (ignoredDependencies.some((ignore) => ignore.test(name))) {
130
- return;
131
- }
132
- const range = dep.value.type === 'JSONLiteral' ? dep.value.value : (dep.value.type === 'JSONIdentifier' ? dep.value.name : undefined);
133
- if (!range && dep.value.type === 'JSONObjectExpression') {
134
- return dep.value.properties
135
- .forEach((prop) => getNodeDetails(prop));
136
- }
137
- const resolutionSubNameIndex = isResolutionsField ? nameParts.findIndex((_, i) => !!bestRanges[nameParts.slice(nameParts.length - i).join('/')]) : -1;
138
- const resolvedName = resolutionSubNameIndex > -1 ? nameParts.slice(nameParts.length - resolutionSubNameIndex).join('/') : name;
139
- const bestRange = (0, version_harmonize_1.getBestRange)(range, bestRanges[resolvedName]?.range);
140
- report(name, resolvedName, dep, range, bestRange);
141
- };
142
- getNodeDetails(dependencyNode);
143
- });
140
+ getNodeDetails(dependencyNode);
144
141
  });
145
- }
142
+ });
146
143
  }
147
144
  }
148
145
  };
146
+ return {
147
+ JSONExpressionStatement: rule
148
+ };
149
149
  }
150
150
  return {};
151
151
  }
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getBestRanges = exports.getBestRange = exports.findWorkspacePackageJsons = void 0;
4
- const semver = require("semver");
5
4
  const fs = require("node:fs");
6
5
  const node_fs_1 = require("node:fs");
7
6
  const node_path_1 = require("node:path");
8
7
  const globby_1 = require("globby");
8
+ const semver = require("semver");
9
9
  /**
10
10
  * Find the closest package.json file containing workspace definition in the parent directories
11
11
  * @param directory Current directory to search for
@@ -15,7 +15,7 @@ function isJsoncParserServices(parserServices) {
15
15
  * @param context Rule context
16
16
  */
17
17
  function getJsoncParserServices(context) {
18
- const parserService = context.parserServices;
18
+ const parserService = context.sourceCode.parserServices;
19
19
  if (!isJsoncParserServices(parserService)) {
20
20
  /*
21
21
  * The user needs to have configured "parser" in their eslint config and set it
@@ -31,7 +31,7 @@ function getJsoncParserServices(context) {
31
31
  * @param context
32
32
  */
33
33
  function ensureJsoncParser(context) {
34
- if (!(context.parserServices)) {
34
+ if (!(context.sourceCode.parserServices)) {
35
35
  /*
36
36
  * The user needs to have configured "parser" in their eslint config and set it
37
37
  * to jsonc-eslint-parser
@@ -1,5 +1,5 @@
1
1
  /** Rule Name */
2
2
  export declare const name = "no-inner-html";
3
3
  type Messages = 'error' | 'fix';
4
- declare const _default: import("@typescript-eslint/utils/dist/ts-eslint").RuleModule<Messages, [], import("@typescript-eslint/utils/dist/ts-eslint").RuleListener>;
4
+ declare const _default: import("@typescript-eslint/utils/dist/ts-eslint").RuleModule<Messages, [], unknown, import("@typescript-eslint/utils/dist/ts-eslint").RuleListener>;
5
5
  export default _default;
@@ -1,19 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.name = void 0;
4
- const utils_1 = require("../utils");
5
- const utils_2 = require("../../utils");
4
+ const utils_1 = require("../../utils");
5
+ const utils_2 = require("../utils");
6
6
  /** Rule Name */
7
7
  exports.name = 'no-inner-html';
8
- exports.default = (0, utils_2.createRule)({
8
+ exports.default = (0, utils_1.createRule)({
9
9
  name: exports.name,
10
10
  defaultOptions: [],
11
11
  meta: {
12
12
  type: 'problem',
13
13
  hasSuggestions: true,
14
14
  docs: {
15
- description: 'Ensures that your template does not use innerHTML',
16
- recommended: 'recommended'
15
+ description: 'Ensures that your template does not use innerHTML'
17
16
  },
18
17
  schema: [],
19
18
  messages: {
@@ -24,34 +23,34 @@ exports.default = (0, utils_2.createRule)({
24
23
  },
25
24
  create: (context) => {
26
25
  // 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
- }
26
+ (0, utils_2.getTemplateParserServices)(context);
27
+ const rule = (node) => {
28
+ const innerHTMLAttribute = node.attributes.find((a) => /innerhtml/i.test(a.name));
29
+ if (innerHTMLAttribute && innerHTMLAttribute.keySpan) {
30
+ context.report({
31
+ messageId: 'error',
32
+ loc: {
33
+ column: innerHTMLAttribute.keySpan.start.col,
34
+ line: innerHTMLAttribute.keySpan.start.line,
35
+ end: {
36
+ column: innerHTMLAttribute.keySpan.end.col,
37
+ line: innerHTMLAttribute.keySpan.end.line
46
38
  },
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
- }
39
+ start: {
40
+ column: innerHTMLAttribute.keySpan.start.col,
41
+ line: innerHTMLAttribute.keySpan.start.line
42
+ }
43
+ },
44
+ fix: (fixer) => fixer.replaceTextRange([innerHTMLAttribute.keySpan.start.offset, innerHTMLAttribute.keySpan.end.offset], 'innerText'),
45
+ suggest: [{
46
+ messageId: 'fix',
47
+ fix: (fixer) => fixer.replaceTextRange([innerHTMLAttribute.keySpan.start.offset, innerHTMLAttribute.keySpan.end.offset], 'innerText')
48
+ }]
49
+ });
54
50
  }
55
51
  };
52
+ return {
53
+ Element$1: rule
54
+ };
56
55
  }
57
56
  });
@@ -1,7 +1,7 @@
1
- interface Options {
1
+ export interface TemplateAsyncNumberLimitationOptions {
2
2
  maximumAsyncOnTag: number;
3
3
  }
4
4
  /** Rule Name */
5
5
  export declare const name = "template-async-number-limitation";
6
- declare const _default: import("@typescript-eslint/utils/dist/ts-eslint").RuleModule<"tooManyAsyncOnTag", [Options, ...any[]], import("@typescript-eslint/utils/dist/ts-eslint").RuleListener>;
6
+ declare const _default: import("@typescript-eslint/utils/dist/ts-eslint").RuleModule<"tooManyAsyncOnTag", [TemplateAsyncNumberLimitationOptions, ...any[]], unknown, import("@typescript-eslint/utils/dist/ts-eslint").RuleListener>;
7
7
  export default _default;
@@ -1,14 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.name = void 0;
4
- const utils_1 = require("../utils");
5
- const utils_2 = require("../../utils");
4
+ const utils_1 = require("../../utils");
5
+ const utils_2 = require("../utils");
6
6
  /** Rule Name */
7
7
  exports.name = 'template-async-number-limitation';
8
8
  const defaultOptions = [{
9
9
  maximumAsyncOnTag: 5
10
10
  }];
11
- exports.default = (0, utils_2.createRule)({
11
+ exports.default = (0, utils_1.createRule)({
12
12
  name: exports.name,
13
13
  meta: {
14
14
  type: 'problem',
@@ -35,29 +35,29 @@ exports.default = (0, utils_2.createRule)({
35
35
  },
36
36
  defaultOptions,
37
37
  create: (context, [options]) => {
38
- const parserServices = (0, utils_1.getTemplateParserServices)(context);
38
+ const parserServices = (0, utils_2.getTemplateParserServices)(context);
39
39
  const asyncRegExp = /\| *async\b/g;
40
- return {
41
- // eslint-disable-next-line @typescript-eslint/naming-convention
42
- 'Element$1': ({ attributes, inputs, sourceSpan }) => {
43
- const values = [
44
- ...attributes.map(({ value }) => value),
45
- ...inputs.map((attr) => attr.value.toString())
46
- ];
47
- const asyncNumber = values
48
- .reduce((acc, value) => acc + (value.match(asyncRegExp)?.length ?? 0), 0);
49
- if (asyncNumber > options.maximumAsyncOnTag) {
50
- const loc = parserServices.convertNodeSourceSpanToLoc(sourceSpan);
51
- context.report({
52
- messageId: 'tooManyAsyncOnTag',
53
- data: {
54
- asyncNumber,
55
- maximumAsyncOnTag: options.maximumAsyncOnTag
56
- },
57
- loc
58
- });
59
- }
40
+ const rule = ({ attributes, inputs, sourceSpan }) => {
41
+ const values = [
42
+ ...attributes.map(({ value }) => value),
43
+ ...inputs.map((attr) => attr.value.toString())
44
+ ];
45
+ const asyncNumber = values
46
+ .reduce((acc, value) => acc + (value.match(asyncRegExp)?.length ?? 0), 0);
47
+ if (asyncNumber > options.maximumAsyncOnTag) {
48
+ const loc = parserServices.convertNodeSourceSpanToLoc(sourceSpan);
49
+ context.report({
50
+ messageId: 'tooManyAsyncOnTag',
51
+ data: {
52
+ asyncNumber,
53
+ maximumAsyncOnTag: options.maximumAsyncOnTag
54
+ },
55
+ loc
56
+ });
60
57
  }
61
58
  };
59
+ return {
60
+ Element$1: rule
61
+ };
62
62
  }
63
63
  });
@@ -8,15 +8,15 @@ exports.ensureTemplateParser = ensureTemplateParser;
8
8
  * @param parserServices Parser services object
9
9
  */
10
10
  function isTemplateParserServices(parserServices) {
11
- return parserServices && (typeof parserServices.convertElementSourceSpanToLoc === 'function' ||
12
- typeof parserServices.convertNodeSourceSpanToLoc === 'function');
11
+ return parserServices && (typeof parserServices.convertElementSourceSpanToLoc === 'function'
12
+ || typeof parserServices.convertNodeSourceSpanToLoc === 'function');
13
13
  }
14
14
  /**
15
15
  * Retrieve the template parser services object or throw if the invalid parser is used
16
16
  * @param context Rule context
17
17
  */
18
18
  function getTemplateParserServices(context) {
19
- const parserService = context.parserServices;
19
+ const parserService = context.sourceCode.parserServices;
20
20
  if (!isTemplateParserServices(parserService)) {
21
21
  /*
22
22
  * The user needs to have configured "parser" in their eslint config and set it
@@ -1,2 +1,2 @@
1
- declare const _default: import("@typescript-eslint/utils/dist/ts-eslint").RuleModule<"suggestion" | "error", [], import("@typescript-eslint/utils/dist/ts-eslint").RuleListener>;
1
+ declare const _default: import("@typescript-eslint/utils/dist/ts-eslint").RuleModule<"error" | "suggestion", [], unknown, import("@typescript-eslint/utils/dist/ts-eslint").RuleListener>;
2
2
  export default _default;