diff --git a/e2e/angular/src/projects.test.ts b/e2e/angular/src/projects.test.ts index 501f9ef922fee..f0685e7925939 100644 --- a/e2e/angular/src/projects.test.ts +++ b/e2e/angular/src/projects.test.ts @@ -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 projects with --project-name-and-root-format=derived', () => { diff --git a/packages/eslint-plugin/src/flat-configs/angular.ts b/packages/eslint-plugin/src/flat-configs/angular.ts index 12880957aa35f..e0abe64e0cf88 100644 --- a/packages/eslint-plugin/src/flat-configs/angular.ts +++ b/packages/eslint-plugin/src/flat-configs/angular.ts @@ -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 }, + } +);