Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(eslint-plugin): add prefer-standalone rule for checking all components, directives and pipes #1627

Merged
merged 1 commit into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/builder/src/lint.impl.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import type { ESLint } from 'eslint';
import { mkdtempSync, writeFileSync } from 'node:fs';
import { tmpdir } from 'node:os';
import { join } from 'node:path';
import { join, sep } from 'node:path';
import type { Schema } from './schema';

// Add a placeholder file for the native workspace context within nx implementation details otherwise it will hang in CI
Expand Down Expand Up @@ -178,7 +178,7 @@
fix: true,
quiet: false,
cache: true,
cacheLocation: 'cacheLocation1/<???>',
cacheLocation: `cacheLocation1${sep}<???>`,
cacheStrategy: 'content',
format: 'stylish',
force: false,
Expand All @@ -196,7 +196,7 @@
});

it('should resolve and instantiate ESLint with useFlatConfig=true if the root config is eslint.config.js', async () => {
jest.spyOn(fs, 'existsSync').mockImplementation((path: any) => {

Check warning on line 199 in packages/builder/src/lint.impl.spec.ts

View workflow job for this annotation

GitHub Actions / Primary

Unexpected any. Specify a different type
if (path.endsWith('/eslint.config.js')) {
return true;
}
Expand All @@ -214,7 +214,7 @@
fix: true,
quiet: false,
cache: true,
cacheLocation: 'cacheLocation1/<???>',
cacheLocation: `cacheLocation1${sep}<???>`,
cacheStrategy: 'content',
format: 'stylish',
force: false,
Expand Down
10 changes: 9 additions & 1 deletion packages/eslint-plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
| [`pipe-prefix`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin/docs/rules/pipe-prefix.md) | Enforce consistent prefix for pipes. | | | |
| [`prefer-on-push-component-change-detection`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin/docs/rules/prefer-on-push-component-change-detection.md) | Ensures component's `changeDetection` is set to `ChangeDetectionStrategy.OnPush` | | | :bulb: |
| [`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` as `readonly` since they are not supposed to be reassigned | | | :bulb: |
| [`prefer-standalone-component`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin/docs/rules/prefer-standalone-component.md) | Ensures component `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 component, directive and pipe `standalone` property is set to `true` in the component decorator | | :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.io/styleguide#style-05-04 | | | |
| [`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. | | | |
| [`sort-ngmodule-metadata-arrays`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin/docs/rules/sort-ngmodule-metadata-arrays.md) | Ensures ASC alphabetical order for `NgModule` metadata arrays for easy visual scanning | | :wrench: | |
Expand All @@ -82,4 +82,12 @@

<!-- begin deprecated rule list -->

### Deprecated

<!-- prettier-ignore-start -->
| Rule | Replaced by |
| --- | --- |
| [`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-component.md) |
<!-- prettier-ignore-end -->

<!-- end deprecated rule list -->
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@

# `@angular-eslint/prefer-standalone-component`

## ⚠️ THIS RULE IS DEPRECATED

Please use `@angular-eslint/prefer-standalone` instead.

---

Ensures component `standalone` property is set to `true` in the component decorator

- Type: suggestion
Expand Down