@angular-eslint/eslint-plugin
Advanced tools
Comparing version
@@ -19,3 +19,2 @@ { | ||
"@angular-eslint/no-forward-ref": "error", | ||
"@angular-eslint/no-host-metadata-property": "error", | ||
"@angular-eslint/no-input-prefix": "error", | ||
@@ -35,3 +34,2 @@ "@angular-eslint/no-input-rename": "error", | ||
"@angular-eslint/prefer-standalone": "error", | ||
"@angular-eslint/prefer-standalone-component": "error", | ||
"@angular-eslint/relative-url-prefix": "error", | ||
@@ -41,3 +39,2 @@ "@angular-eslint/require-localize-metadata": "error", | ||
"@angular-eslint/sort-lifecycle-methods": "error", | ||
"@angular-eslint/sort-ngmodule-metadata-arrays": "error", | ||
"@angular-eslint/use-component-selector": "error", | ||
@@ -44,0 +41,0 @@ "@angular-eslint/use-component-view-encapsulation": "error", |
@@ -15,2 +15,3 @@ { | ||
"@angular-eslint/no-outputs-metadata-property": "error", | ||
"@angular-eslint/prefer-standalone": "error", | ||
"@angular-eslint/use-pipe-transform-interface": "error", | ||
@@ -17,0 +18,0 @@ "@angular-eslint/use-lifecycle-interface": "warn" |
@@ -21,3 +21,2 @@ declare const _default: { | ||
"@angular-eslint/no-forward-ref": string; | ||
"@angular-eslint/no-host-metadata-property": string; | ||
"@angular-eslint/no-input-prefix": string; | ||
@@ -37,3 +36,2 @@ "@angular-eslint/no-input-rename": string; | ||
"@angular-eslint/prefer-standalone": string; | ||
"@angular-eslint/prefer-standalone-component": string; | ||
"@angular-eslint/relative-url-prefix": string; | ||
@@ -43,3 +41,2 @@ "@angular-eslint/require-localize-metadata": string; | ||
"@angular-eslint/sort-lifecycle-methods": string; | ||
"@angular-eslint/sort-ngmodule-metadata-arrays": string; | ||
"@angular-eslint/use-component-selector": string; | ||
@@ -66,2 +63,3 @@ "@angular-eslint/use-component-view-encapsulation": string; | ||
"@angular-eslint/no-outputs-metadata-property": string; | ||
"@angular-eslint/prefer-standalone": string; | ||
"@angular-eslint/use-pipe-transform-interface": string; | ||
@@ -87,3 +85,2 @@ "@angular-eslint/use-lifecycle-interface": string; | ||
"no-forward-ref": import("@typescript-eslint/utils/ts-eslint").RuleModule<"noForwardRef", [], import("./utils/create-eslint-rule").RuleDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>; | ||
"no-host-metadata-property": import("@typescript-eslint/utils/ts-eslint").RuleModule<"noHostMetadataProperty", import("./rules/no-host-metadata-property").Options, import("./utils/create-eslint-rule").RuleDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>; | ||
"no-input-prefix": import("@typescript-eslint/utils/ts-eslint").RuleModule<"noInputPrefix", import("./rules/no-input-prefix").Options, import("./utils/create-eslint-rule").RuleDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>; | ||
@@ -102,3 +99,2 @@ "no-input-rename": import("@typescript-eslint/utils/ts-eslint").RuleModule<import("./rules/no-input-rename").MessageIds, import("./rules/no-input-rename").Options, import("./utils/create-eslint-rule").RuleDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>; | ||
"prefer-standalone": import("@typescript-eslint/utils/ts-eslint").RuleModule<"preferStandalone", [], import("./utils/create-eslint-rule").RuleDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>; | ||
"prefer-standalone-component": import("@typescript-eslint/utils/ts-eslint").RuleModule<"preferStandaloneComponent", [], import("./utils/create-eslint-rule").RuleDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>; | ||
"prefer-output-readonly": import("@typescript-eslint/utils/ts-eslint").RuleModule<import("./rules/prefer-output-readonly").MessageIds, [], import("./utils/create-eslint-rule").RuleDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>; | ||
@@ -109,3 +105,2 @@ "relative-url-prefix": import("@typescript-eslint/utils/ts-eslint").RuleModule<"relativeUrlPrefix", [], import("./utils/create-eslint-rule").RuleDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>; | ||
"sort-lifecycle-methods": import("@typescript-eslint/utils/ts-eslint").RuleModule<"lifecycleMethodsNotSorted", [], import("./utils/create-eslint-rule").RuleDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>; | ||
"sort-ngmodule-metadata-arrays": import("@typescript-eslint/utils/ts-eslint").RuleModule<"sortNgmoduleMetadataArrays", import("./rules/sort-ngmodule-metadata-arrays").Options, import("./utils/create-eslint-rule").RuleDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>; | ||
"use-component-selector": import("@typescript-eslint/utils/ts-eslint").RuleModule<"useComponentSelector", [], import("./utils/create-eslint-rule").RuleDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>; | ||
@@ -112,0 +107,0 @@ "use-component-view-encapsulation": import("@typescript-eslint/utils/ts-eslint").RuleModule<import("./rules/use-component-view-encapsulation").MessageIds, [], import("./utils/create-eslint-rule").RuleDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>; |
@@ -43,3 +43,2 @@ "use strict"; | ||
const no_forward_ref_1 = __importStar(require("./rules/no-forward-ref")); | ||
const no_host_metadata_property_1 = __importStar(require("./rules/no-host-metadata-property")); | ||
const no_input_prefix_1 = __importStar(require("./rules/no-input-prefix")); | ||
@@ -59,3 +58,2 @@ const no_input_rename_1 = __importStar(require("./rules/no-input-rename")); | ||
const prefer_standalone_1 = __importStar(require("./rules/prefer-standalone")); | ||
const prefer_standalone_component_1 = __importStar(require("./rules/prefer-standalone-component")); | ||
const relative_url_prefix_1 = __importStar(require("./rules/relative-url-prefix")); | ||
@@ -65,3 +63,2 @@ const require_localize_metadata_1 = __importStar(require("./rules/require-localize-metadata")); | ||
const sort_lifecycle_methods_1 = __importStar(require("./rules/sort-lifecycle-methods")); | ||
const sort_ngmodule_metadata_arrays_1 = __importStar(require("./rules/sort-ngmodule-metadata-arrays")); | ||
const use_component_selector_1 = __importStar(require("./rules/use-component-selector")); | ||
@@ -93,3 +90,2 @@ const use_component_view_encapsulation_1 = __importStar(require("./rules/use-component-view-encapsulation")); | ||
[no_forward_ref_1.RULE_NAME]: no_forward_ref_1.default, | ||
[no_host_metadata_property_1.RULE_NAME]: no_host_metadata_property_1.default, | ||
[no_input_prefix_1.RULE_NAME]: no_input_prefix_1.default, | ||
@@ -108,3 +104,2 @@ [no_input_rename_1.RULE_NAME]: no_input_rename_1.default, | ||
[prefer_standalone_1.RULE_NAME]: prefer_standalone_1.default, | ||
[prefer_standalone_component_1.RULE_NAME]: prefer_standalone_component_1.default, | ||
[prefer_output_readonly_1.RULE_NAME]: prefer_output_readonly_1.default, | ||
@@ -115,3 +110,2 @@ [relative_url_prefix_1.RULE_NAME]: relative_url_prefix_1.default, | ||
[sort_lifecycle_methods_1.RULE_NAME]: sort_lifecycle_methods_1.default, | ||
[sort_ngmodule_metadata_arrays_1.RULE_NAME]: sort_ngmodule_metadata_arrays_1.default, | ||
[use_component_selector_1.RULE_NAME]: use_component_selector_1.default, | ||
@@ -118,0 +112,0 @@ [use_component_view_encapsulation_1.RULE_NAME]: use_component_view_encapsulation_1.default, |
@@ -7,4 +7,2 @@ "use strict"; | ||
exports.RULE_NAME = 'prefer-standalone'; | ||
const METADATA_PROPERTY_NAME = 'standalone'; | ||
const IS_STANDALONE = 'true'; | ||
exports.default = (0, create_eslint_rule_1.createESLintRule)({ | ||
@@ -15,3 +13,4 @@ name: exports.RULE_NAME, | ||
docs: { | ||
description: `Ensures component, directive and pipe \`${METADATA_PROPERTY_NAME}\` property is set to \`${IS_STANDALONE}\` in the component decorator`, | ||
description: `Ensures Components, Directives and Pipes do not opt out of standalone`, | ||
recommended: 'recommended', | ||
}, | ||
@@ -21,3 +20,3 @@ fixable: 'code', | ||
messages: { | ||
preferStandalone: `The {{type}} \`${METADATA_PROPERTY_NAME}\` property should be set to \`${IS_STANDALONE}\``, | ||
preferStandalone: `Components, Directives and Pipes should not opt out of standalone`, | ||
}, | ||
@@ -28,6 +27,6 @@ }, | ||
const standaloneRuleFactory = (type) => (node) => { | ||
const standalone = utils_1.ASTUtils.getDecoratorPropertyValue(node, METADATA_PROPERTY_NAME); | ||
if (standalone && | ||
utils_1.ASTUtils.isLiteral(standalone) && | ||
standalone.value === true) { | ||
const standalone = utils_1.ASTUtils.getDecoratorPropertyValue(node, 'standalone'); | ||
// Leave the standalone property alone if it was set to true or not present | ||
if (!standalone || | ||
(utils_1.ASTUtils.isLiteral(standalone) && standalone.value === true)) { | ||
return; | ||
@@ -43,10 +42,11 @@ } | ||
fix: (fixer) => { | ||
if (standalone && | ||
utils_1.ASTUtils.isLiteral(standalone) && | ||
standalone.value !== true) { | ||
return [fixer.replaceText(standalone, IS_STANDALONE)].filter(utils_1.isNotNullOrUndefined); | ||
// Remove the standalone property altogether if it was set to false | ||
const tokenAfter = context.sourceCode.getTokenAfter(standalone.parent); | ||
// Remove the trailing comma, if present | ||
const removeStart = standalone.parent.range[0]; | ||
let removeEnd = standalone.parent.range[1]; | ||
if (tokenAfter && tokenAfter.value === ',') { | ||
removeEnd = tokenAfter.range[1]; | ||
} | ||
return [ | ||
utils_1.RuleFixes.getDecoratorPropertyAddFix(node, fixer, `${METADATA_PROPERTY_NAME}: ${IS_STANDALONE}`), | ||
].filter(utils_1.isNotNullOrUndefined); | ||
return fixer.removeRange([removeStart, removeEnd]); | ||
}, | ||
@@ -53,0 +53,0 @@ }); |
{ | ||
"name": "@angular-eslint/eslint-plugin", | ||
"version": "18.4.3", | ||
"version": "18.4.4-alpha.0", | ||
"description": "ESLint plugin for Angular applications, following https://angular.dev/style-guide", | ||
@@ -21,7 +21,7 @@ "license": "MIT", | ||
"dependencies": { | ||
"@angular-eslint/bundled-angular-compiler": "18.4.3", | ||
"@angular-eslint/utils": "18.4.3" | ||
"@angular-eslint/utils": "18.4.4-alpha.0", | ||
"@angular-eslint/bundled-angular-compiler": "18.4.4-alpha.0" | ||
}, | ||
"devDependencies": { | ||
"@angular-eslint/test-utils": "18.4.3" | ||
"@angular-eslint/test-utils": "18.4.4-alpha.0" | ||
}, | ||
@@ -28,0 +28,0 @@ "peerDependencies": { |
@@ -69,3 +69,3 @@ # @angular-eslint/eslint-plugin | ||
| [`prefer-output-readonly`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin/docs/rules/prefer-output-readonly.md) | Prefer to declare `@Output`, `OutputEmitterRef` and `OutputRef` as `readonly` since they are not supposed to be reassigned | | | :bulb: | | ||
| [`prefer-standalone`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin/docs/rules/prefer-standalone.md) | Ensures component, directive and pipe `standalone` property is set to `true` in the component decorator | | :wrench: | | | ||
| [`prefer-standalone`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin/docs/rules/prefer-standalone.md) | Ensures Components, Directives and Pipes do not opt out of standalone | :white_check_mark: | :wrench: | | | ||
| [`relative-url-prefix`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin/docs/rules/relative-url-prefix.md) | The ./ and ../ prefix is standard syntax for relative URLs; don't depend on Angular's current ability to do without that prefix. See more at https://angular.dev/style-guide#style-05-04 | | | | | ||
@@ -89,12 +89,2 @@ | [`require-localize-metadata`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin/docs/rules/require-localize-metadata.md) | Ensures that $localize tagged messages contain helpful metadata to aid with translations. | | | | | ||
### Deprecated | ||
<!-- prettier-ignore-start --> | ||
| Rule | Replaced by | | ||
| --- | --- | | ||
| [`no-host-metadata-property`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin/docs/rules/no-host-metadata-property.md) | | | ||
| [`prefer-standalone-component`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin/docs/rules/prefer-standalone-component.md) | [`prefer-standalone`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin/docs/rules/prefer-standalone.md) | | ||
| [`sort-ngmodule-metadata-arrays`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin/docs/rules/sort-ngmodule-metadata-arrays.md) | | | ||
<!-- prettier-ignore-end --> | ||
<!-- end deprecated rule list --> |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
188720
-1.82%126
-4.55%3193
-1.3%2
100%89
-10.1%+ Added
+ Added
- Removed
- Removed
Updated