@o3r/eslint-plugin 11.6.0-prerelease.7 → 11.6.0-prerelease.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (29) hide show
  1. package/package.json +22 -21
  2. package/schematics/ng-add/index.d.ts.map +1 -1
  3. package/src/index.js +4 -5
  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-widget-tags/o3r-widget-tags.d.ts +1 -1
  24. package/src/rules/typescript/o3r-widget-tags/o3r-widget-tags.js +142 -142
  25. package/src/rules/utils.d.ts +1 -1
  26. package/src/rules/utils.js +4 -7
  27. package/src/rules/yaml/utils.js +2 -2
  28. package/src/rules/yaml/yarnrc-package-extensions-harmonize/yarnrc-package-extensions-harmonize.d.ts +2 -2
  29. package/src/rules/yaml/yarnrc-package-extensions-harmonize/yarnrc-package-extensions-harmonize.js +45 -45
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@o3r/eslint-plugin",
3
- "version": "11.6.0-prerelease.7",
3
+ "version": "11.6.0-prerelease.9",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -24,7 +24,7 @@
24
24
  "build:builders": "tsc -b tsconfig.builders.json --pretty && yarn generate-cjs-manifest"
25
25
  },
26
26
  "dependencies": {
27
- "@typescript-eslint/utils": "^7.14.1",
27
+ "@typescript-eslint/utils": "~8.12.2",
28
28
  "globby": "^11.1.0",
29
29
  "semver": "^7.5.2",
30
30
  "tslib": "^2.6.2",
@@ -46,46 +46,46 @@
46
46
  },
47
47
  "peerDependencies": {
48
48
  "@angular-devkit/schematics": "~18.2.0",
49
- "@angular-eslint/template-parser": "~18.3.0",
50
- "@angular-eslint/test-utils": "~18.3.0",
49
+ "@angular-eslint/template-parser": "~18.4.0",
50
+ "@angular-eslint/test-utils": "~18.4.0",
51
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",
52
+ "eslint": "^8.57.0 || ~9.14.0",
57
53
  "jsonc-eslint-parser": "~2.4.0",
58
54
  "yaml-eslint-parser": "^1.2.2"
59
55
  },
60
56
  "devDependencies": {
61
57
  "@angular-devkit/core": "~18.2.0",
62
58
  "@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",
59
+ "@angular-eslint/test-utils": "~18.4.0",
66
60
  "@angular/compiler": "~18.2.0",
67
61
  "@babel/core": "~7.26.0",
68
62
  "@babel/preset-typescript": "~7.26.0",
69
63
  "@compodoc/compodoc": "^1.1.19",
64
+ "@eslint-community/eslint-plugin-eslint-comments": "^4.4.0",
70
65
  "@eslint/eslintrc": "^3.0.0",
71
66
  "@nx/eslint-plugin": "~19.5.0",
72
67
  "@nx/jest": "~19.5.0",
73
- "@o3r/build-helpers": "^11.6.0-prerelease.7",
74
- "@o3r/test-helpers": "^11.6.0-prerelease.7",
75
- "@stylistic/eslint-plugin-ts": "~2.4.0",
68
+ "@o3r/build-helpers": "^11.6.0-prerelease.9",
69
+ "@o3r/eslint-config": "^11.6.0-prerelease.9",
70
+ "@o3r/test-helpers": "^11.6.0-prerelease.9",
71
+ "@stylistic/eslint-plugin": "~2.7.0",
76
72
  "@types/eslint": "~9.6.0",
77
73
  "@types/jest": "~29.5.2",
78
74
  "@types/node": "^20.0.0",
79
75
  "@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",
76
+ "@typescript-eslint/parser": "~8.12.2",
77
+ "@typescript-eslint/rule-tester": "~8.12.2",
78
+ "angular-eslint": "~18.4.0",
83
79
  "cpy-cli": "^5.0.0",
84
- "eslint": "^8.57.0",
80
+ "eslint": "~9.14.0",
81
+ "eslint-plugin-import": "^2.31.0",
82
+ "eslint-plugin-import-newlines": "^1.4.0",
85
83
  "eslint-plugin-jest": "~28.8.0",
86
- "eslint-plugin-jsdoc": "~48.11.0",
84
+ "eslint-plugin-jsdoc": "~50.2.0",
87
85
  "eslint-plugin-prefer-arrow": "~1.2.3",
88
- "eslint-plugin-unicorn": "^54.0.0",
86
+ "eslint-plugin-unicorn": "^56.0.0",
87
+ "eslint-plugin-unused-imports": "^4.1.4",
88
+ "globals": "^15.9.0",
89
89
  "jest": "~29.7.0",
90
90
  "jest-junit": "~16.0.0",
91
91
  "jsonc-eslint-parser": "~2.4.0",
@@ -96,6 +96,7 @@
96
96
  "ts-jest": "~29.2.0",
97
97
  "type-fest": "^4.10.2",
98
98
  "typescript": "~5.5.4",
99
+ "typescript-eslint": "~8.12.2",
99
100
  "yaml-eslint-parser": "^1.2.2"
100
101
  },
101
102
  "schematics": "./collection.json",
@@ -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,14 @@
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_widget_tags_1 = require("./rules/typescript/o3r-widget-tags/o3r-widget-tags");
11
+ const yarnrc_package_extensions_harmonize_1 = require("./rules/yaml/yarnrc-package-extensions-harmonize/yarnrc-package-extensions-harmonize");
13
12
  module.exports = {
14
13
  rules: {
15
14
  'no-folder-import-for-module': no_folder_import_for_module_1.default,
@@ -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;
@@ -10,8 +10,8 @@ exports.default = (0, utils_2.createRule)({
10
10
  fixable: 'code',
11
11
  type: 'problem',
12
12
  docs: {
13
- // eslint-disable-next-line max-len
14
- description: 'Ensures that the configuration interface name matches the first parameter of `computeItemIdentifier` (or `computeConfigurationName`) used beside the configuration interface to expose its ID (as generated by the configuration module).'
13
+ description: 'Ensures that the configuration interface name matches the first parameter of `computeItemIdentifier`'
14
+ + ' (or `computeConfigurationName`) used beside the configuration interface to expose its ID (as generated by the configuration module).'
15
15
  },
16
16
  schema: [],
17
17
  messages: {
@@ -21,49 +21,49 @@ exports.default = (0, utils_2.createRule)({
21
21
  },
22
22
  defaultOptions: [],
23
23
  create: (context) => {
24
- return {
25
- // eslint-disable-next-line @typescript-eslint/naming-convention
26
- CallExpression: (node) => {
27
- if (node.callee.type !== utils_1.TSESTree.AST_NODE_TYPES.Identifier
28
- || !nameDeterminingFunctionNames.includes(node.callee.name)
29
- || !node.arguments.length
30
- || node.arguments[0].type !== utils_1.TSESTree.AST_NODE_TYPES.Literal
31
- || typeof node.arguments[0].value !== 'string') {
32
- return;
33
- }
34
- const sourceCode = context.getSourceCode();
35
- const interfaceNames = sourceCode.ast.body
36
- .filter((statement) => statement.type === utils_1.TSESTree.AST_NODE_TYPES.ExportNamedDeclaration
37
- && statement.declaration?.type === utils_1.TSESTree.AST_NODE_TYPES.TSInterfaceDeclaration
38
- && (statement.declaration.extends || []).some((heritageClause) => heritageClause.expression.type === utils_1.TSESTree.AST_NODE_TYPES.Identifier
39
- && heritageClause.expression.name === 'Configuration'))
40
- .map((statement) => statement.declaration.id.name);
41
- const fnArgInterfaceName = node.arguments[0].value;
42
- if (interfaceNames.length && !interfaceNames.includes(fnArgInterfaceName)) {
43
- return context.report({
44
- node: node.arguments[0],
45
- loc: node.arguments[0].loc,
46
- messageId: 'error',
24
+ const rule = (node) => {
25
+ if (node.callee.type !== utils_1.TSESTree.AST_NODE_TYPES.Identifier
26
+ || !nameDeterminingFunctionNames.includes(node.callee.name)
27
+ || node.arguments.length === 0
28
+ || node.arguments[0].type !== utils_1.TSESTree.AST_NODE_TYPES.Literal
29
+ || typeof node.arguments[0].value !== 'string') {
30
+ return;
31
+ }
32
+ const { sourceCode } = context;
33
+ const interfaceNames = sourceCode.ast.body
34
+ .filter((statement) => statement.type === utils_1.TSESTree.AST_NODE_TYPES.ExportNamedDeclaration
35
+ && statement.declaration?.type === utils_1.TSESTree.AST_NODE_TYPES.TSInterfaceDeclaration
36
+ && (statement.declaration.extends || []).some((heritageClause) => heritageClause.expression.type === utils_1.TSESTree.AST_NODE_TYPES.Identifier
37
+ && heritageClause.expression.name === 'Configuration'))
38
+ .map((statement) => statement.declaration.id.name);
39
+ const fnArgInterfaceName = node.arguments[0].value;
40
+ if (interfaceNames.length > 0 && !interfaceNames.includes(fnArgInterfaceName)) {
41
+ return context.report({
42
+ node: node.arguments[0],
43
+ loc: node.arguments[0].loc,
44
+ messageId: 'error',
45
+ data: {
46
+ currentValue: fnArgInterfaceName,
47
+ possibleValues: interfaceNames.join(', ')
48
+ },
49
+ fix: (fixer) => {
50
+ return fixer.replaceText(node.arguments[0], `'${interfaceNames[0]}'`);
51
+ },
52
+ suggest: interfaceNames.map((interfaceName) => ({
53
+ messageId: 'suggestion',
47
54
  data: {
48
55
  currentValue: fnArgInterfaceName,
49
- possibleValues: interfaceNames.join(', ')
56
+ recommendedValue: interfaceName
50
57
  },
51
58
  fix: (fixer) => {
52
- return fixer.replaceText(node.arguments[0], `'${interfaceNames[0]}'`);
53
- },
54
- suggest: interfaceNames.map((interfaceName) => ({
55
- messageId: 'suggestion',
56
- data: {
57
- currentValue: fnArgInterfaceName,
58
- recommendedValue: interfaceName
59
- },
60
- fix: (fixer) => {
61
- return fixer.replaceText(node.arguments[0], `'${interfaceName}'`);
62
- }
63
- }))
64
- });
65
- }
59
+ return fixer.replaceText(node.arguments[0], `'${interfaceName}'`);
60
+ }
61
+ }))
62
+ });
66
63
  }
67
64
  };
65
+ return {
66
+ CallExpression: rule
67
+ };
68
68
  }
69
69
  });