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

fix(linter): add files entry to angular flat config to avoid applying TS rules to JSON files #28102

Merged
merged 3 commits into from
Sep 25, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions e2e/angular/src/projects.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,9 @@ describe('Angular Projects', () => {
`Building entry point '@${proj}/${lib}/${entryPoint}'`
);
expect(buildOutput).toContain('Successfully ran target build');

expect(() => runCLI(`lint ${lib} --fix`)).not.toThrow();
expect(() => runCLI(`lint ${childLib} --fix`)).not.toThrow();
});

it('should support generating libraries with a scoped name when --project-name-and-root-format=as-provided', () => {
Expand Down
30 changes: 20 additions & 10 deletions packages/eslint-plugin/src/flat-configs/angular.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,24 @@ import tseslint from 'typescript-eslint';
* This configuration is intended to be combined with other configs from this
* package.
*/
export default tseslint.config(...angularEslint.configs.tsRecommended, {
languageOptions: {
globals: {
...globals.browser,
...globals.es2015,
...globals.node,
export default tseslint.config(
...angularEslint.configs.tsRecommended.map((c) => ({
// Files need to be specified or else typescript-eslint rules will be
// applied to non-TS files. For example, buildable/publishable libs
// add rules to *.json files, and TS rules should not apply to them.
// See: https://github.com/nrwl/nx/issues/28069
files: ['**/*.ts'],
...c,
})),
{
languageOptions: {
globals: {
...globals.browser,
...globals.es2015,
...globals.node,
},
},
},
processor: angularEslint.processInlineTemplates,
plugins: { '@angular-eslint': angularEslint.tsPlugin },
});
processor: angularEslint.processInlineTemplates,
plugins: { '@angular-eslint': angularEslint.tsPlugin },
}
);