diff --git a/packages/angular/src/generators/add-linting/__snapshots__/add-linting.spec.ts.snap b/packages/angular/src/generators/add-linting/__snapshots__/add-linting.spec.ts.snap index deedf6d74c4..d7795e8035e 100644 --- a/packages/angular/src/generators/add-linting/__snapshots__/add-linting.spec.ts.snap +++ b/packages/angular/src/generators/add-linting/__snapshots__/add-linting.spec.ts.snap @@ -1,4 +1,4 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP +// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing exports[`addLinting generator should correctly generate the .eslintrc.json file 1`] = ` { diff --git a/packages/angular/src/generators/add-linting/add-linting.spec.ts b/packages/angular/src/generators/add-linting/add-linting.spec.ts index 062ab59f323..b0eadabf176 100644 --- a/packages/angular/src/generators/add-linting/add-linting.spec.ts +++ b/packages/angular/src/generators/add-linting/add-linting.spec.ts @@ -125,6 +125,8 @@ describe('addLinting generator', () => { import baseConfig from "../../eslint.config.mjs"; export default [ + ...nx.configs["flat/angular"], + ...nx.configs["flat/angular-template"], ...baseConfig, { files: [ @@ -144,8 +146,6 @@ describe('addLinting generator', () => { parser: await import("jsonc-eslint-parser") } }, - ...nx.configs["flat/angular"], - ...nx.configs["flat/angular-template"], { files: [ "**/*.ts" diff --git a/packages/angular/src/generators/add-linting/add-linting.ts b/packages/angular/src/generators/add-linting/add-linting.ts index 782b5c94e2b..8a0668d6faa 100755 --- a/packages/angular/src/generators/add-linting/add-linting.ts +++ b/packages/angular/src/generators/add-linting/add-linting.ts @@ -56,12 +56,14 @@ export async function addLintingGenerator( addPredefinedConfigToFlatLintConfig( tree, options.projectRoot, - 'flat/angular' + 'flat/angular', + { checkBaseConfig: true } ); addPredefinedConfigToFlatLintConfig( tree, options.projectRoot, - 'flat/angular-template' + 'flat/angular-template', + { checkBaseConfig: true } ); addOverrideToLintConfig(tree, options.projectRoot, { files: ['*.ts'], diff --git a/packages/angular/src/generators/application/application.spec.ts b/packages/angular/src/generators/application/application.spec.ts index db3213de6f9..739cc110627 100644 --- a/packages/angular/src/generators/application/application.spec.ts +++ b/packages/angular/src/generators/application/application.spec.ts @@ -761,6 +761,8 @@ describe('app', () => { const baseConfig = require("../eslint.config.cjs"); module.exports = [ + ...nx.configs["flat/angular"], + ...nx.configs["flat/angular-template"], ...baseConfig, { files: [ @@ -777,8 +779,6 @@ describe('app', () => { } } }, - ...nx.configs["flat/angular"], - ...nx.configs["flat/angular-template"], { files: [ "**/*.ts" diff --git a/packages/angular/src/generators/library/library.spec.ts b/packages/angular/src/generators/library/library.spec.ts index f80eeb74898..2aa32088272 100644 --- a/packages/angular/src/generators/library/library.spec.ts +++ b/packages/angular/src/generators/library/library.spec.ts @@ -1222,9 +1222,9 @@ describe('lib', () => { const baseConfig = require("../eslint.config.cjs"); module.exports = [ - ...baseConfig, ...nx.configs["flat/angular"], ...nx.configs["flat/angular-template"], + ...baseConfig, { files: [ "**/*.ts" @@ -1274,6 +1274,8 @@ describe('lib', () => { const baseConfig = require("../eslint.config.cjs"); module.exports = [ + ...nx.configs["flat/angular"], + ...nx.configs["flat/angular-template"], ...baseConfig, { files: [ @@ -1290,8 +1292,6 @@ describe('lib', () => { } } }, - ...nx.configs["flat/angular"], - ...nx.configs["flat/angular-template"], { files: [ "**/*.ts" diff --git a/packages/cypress/src/utils/add-linter.ts b/packages/cypress/src/utils/add-linter.ts index f8040956a58..a63b0db910a 100644 --- a/packages/cypress/src/utils/add-linter.ts +++ b/packages/cypress/src/utils/add-linter.ts @@ -98,10 +98,12 @@ export async function addLinterToCyProject( tree, projectConfig.root, 'recommended', - 'cypress', - 'eslint-plugin-cypress/flat', - false, - false + { + moduleName: 'cypress', + moduleImportPath: 'eslint-plugin-cypress/flat', + spread: false, + insertAtTheEnd: false, + } ); addOverrideToLintConfig(tree, projectConfig.root, { files: ['*.ts', '*.js'], diff --git a/packages/detox/src/generators/application/lib/add-linting.ts b/packages/detox/src/generators/application/lib/add-linting.ts index 85e6424ce2d..3c5158016bf 100644 --- a/packages/detox/src/generators/application/lib/add-linting.ts +++ b/packages/detox/src/generators/application/lib/add-linting.ts @@ -38,7 +38,8 @@ export async function addLinting(host: Tree, options: NormalizedSchema) { addPredefinedConfigToFlatLintConfig( host, options.e2eProjectRoot, - 'flat/react' + 'flat/react', + { checkBaseConfig: true } ); // Add an empty rules object to users know how to add/override rules addOverrideToLintConfig(host, options.e2eProjectRoot, { diff --git a/packages/eslint-plugin/src/flat-configs/angular.ts b/packages/eslint-plugin/src/flat-configs/angular.ts index 995702cd5c3..2f1469f9d2e 100644 --- a/packages/eslint-plugin/src/flat-configs/angular.ts +++ b/packages/eslint-plugin/src/flat-configs/angular.ts @@ -23,6 +23,7 @@ const config: ConfigArray = tseslint.config( ...c, })), { + files: ['**/*.ts'], languageOptions: { globals: { ...globals.browser, diff --git a/packages/eslint-plugin/src/flat-configs/javascript.ts b/packages/eslint-plugin/src/flat-configs/javascript.ts index 1aef559be2c..be0394c0a8d 100644 --- a/packages/eslint-plugin/src/flat-configs/javascript.ts +++ b/packages/eslint-plugin/src/flat-configs/javascript.ts @@ -28,6 +28,7 @@ const config: ConfigArray = tseslint.config( extends: [eslint.configs.recommended, ...tseslint.configs.recommended], }, { + files: ['**/*.js', '**/*.jsx', '**/*.cjs', '**/*.mjs'], languageOptions: { parser: tseslint.parser, ecmaVersion: 2020, diff --git a/packages/eslint-plugin/src/flat-configs/typescript.ts b/packages/eslint-plugin/src/flat-configs/typescript.ts index 45349e19695..6daf0df6170 100644 --- a/packages/eslint-plugin/src/flat-configs/typescript.ts +++ b/packages/eslint-plugin/src/flat-configs/typescript.ts @@ -19,6 +19,7 @@ const config: ConfigArray = tseslint.config( extends: [eslint.configs.recommended, ...tseslint.configs.recommended], }, { + files: ['**/*.ts', '**/*.tsx', '**/*.cts', '**/*.mts'], plugins: { '@typescript-eslint': tseslint.plugin }, languageOptions: { parser: tseslint.parser, diff --git a/packages/eslint/src/generators/utils/eslint-file.ts b/packages/eslint/src/generators/utils/eslint-file.ts index c2b69f6624c..4fc47d169f2 100644 --- a/packages/eslint/src/generators/utils/eslint-file.ts +++ b/packages/eslint/src/generators/utils/eslint-file.ts @@ -535,11 +535,22 @@ export function addPredefinedConfigToFlatLintConfig( tree: Tree, root: string, predefinedConfigName: string, - moduleName = 'nx', - moduleImportPath = '@nx/eslint-plugin', - spread = true, - insertAtTheEnd = true + options: { + moduleName?: string; + moduleImportPath?: string; + spread?: boolean; + insertAtTheEnd?: boolean; + checkBaseConfig?: boolean; + } = {} ): void { + const { + moduleName = 'nx', + moduleImportPath = '@nx/eslint-plugin', + spread = true, + insertAtTheEnd = true, + checkBaseConfig = false, + } = options; + if (!useFlatConfig(tree)) throw new Error('Predefined configs can only be used with flat configs'); @@ -556,7 +567,7 @@ export function addPredefinedConfigToFlatLintConfig( content = addBlockToFlatConfigExport( content, generateFlatPredefinedConfig(predefinedConfigName, moduleName, spread), - { insertAtTheEnd } + { insertAtTheEnd, checkBaseConfig } ); tree.write(fileName, content); diff --git a/packages/eslint/src/generators/utils/flat-config/ast-utils.spec.ts b/packages/eslint/src/generators/utils/flat-config/ast-utils.spec.ts index 006e2d9fe9e..50900bac294 100644 --- a/packages/eslint/src/generators/utils/flat-config/ast-utils.spec.ts +++ b/packages/eslint/src/generators/utils/flat-config/ast-utils.spec.ts @@ -5,6 +5,7 @@ import { addImportToFlatConfig, generateAst, generateFlatOverride, + generateFlatPredefinedConfig, generatePluginExtendsElementWithCompatFixup, hasOverride, removeCompatExtends, @@ -272,6 +273,85 @@ describe('ast-utils', () => { " `); }); + + it('should insert before baseConfig when checkBaseConfig is true (ESM)', () => { + const content = `import baseConfig from "../../eslint.config.mjs"; + export default [ + ...baseConfig, + { + files: ["**/*.ts"], + rules: {} + }, + ];`; + const result = addBlockToFlatConfigExport( + content, + generateFlatPredefinedConfig('flat/react', 'nx', true), + { checkBaseConfig: true } + ); + expect(result).toMatchInlineSnapshot(` + "import baseConfig from "../../eslint.config.mjs"; + + export default [ + ...nx.configs["flat/react"], + ...baseConfig, + { + files: ["**/*.ts"], + rules: {} + } + ]; + " + `); + }); + + it('should append when checkBaseConfig is true but no baseConfig exists (ESM)', () => { + const content = `import nx from "@nx/eslint-plugin"; + export default [ + ...nx.configs["flat/base"], + ...nx.configs["flat/typescript"], + ];`; + const result = addBlockToFlatConfigExport( + content, + generateFlatPredefinedConfig('flat/react', 'nx', true), + { checkBaseConfig: true } + ); + expect(result).toMatchInlineSnapshot(` + "import nx from "@nx/eslint-plugin"; + + export default [ + ...nx.configs["flat/base"], + ...nx.configs["flat/typescript"], + ...nx.configs["flat/react"] + ]; + " + `); + }); + + it('should insert before baseConfig when checkBaseConfig is true (CJS)', () => { + const content = `const baseConfig = require("../../eslint.config.cjs"); +module.exports = [ + ...baseConfig, + { + files: ["**/*.ts"], + rules: {} + }, +];`; + const result = addBlockToFlatConfigExport( + content, + generateFlatPredefinedConfig('flat/react', 'nx', true), + { checkBaseConfig: true } + ); + expect(result).toMatchInlineSnapshot(` + "const baseConfig = require("../../eslint.config.cjs"); + module.exports = [ + ...nx.configs["flat/react"], + ...baseConfig, + { + files: ["**/*.ts"], + rules: {} + }, + ];" + `); + }); }); describe('addImportToFlatConfig', () => { diff --git a/packages/eslint/src/generators/utils/flat-config/ast-utils.ts b/packages/eslint/src/generators/utils/flat-config/ast-utils.ts index d919b7871fb..2da0e6a2b4f 100644 --- a/packages/eslint/src/generators/utils/flat-config/ast-utils.ts +++ b/packages/eslint/src/generators/utils/flat-config/ast-utils.ts @@ -912,9 +912,26 @@ function addBlockToFlatConfigExportESM( const exportArrayLiteral = exportDefaultStatement.expression as ts.ArrayLiteralExpression; - const updatedArrayElements = options.insertAtTheEnd - ? [...exportArrayLiteral.elements, config] - : [config, ...exportArrayLiteral.elements]; + let updatedArrayElements: ts.Expression[]; + if (options.checkBaseConfig) { + const baseConfigIndex = exportArrayLiteral.elements.findIndex( + (el) => + ts.isSpreadElement(el) && + ts.isIdentifier(el.expression) && + el.expression.text === 'baseConfig' + ); + if (baseConfigIndex >= 0) { + const before = exportArrayLiteral.elements.slice(0, baseConfigIndex); + const after = exportArrayLiteral.elements.slice(baseConfigIndex); + updatedArrayElements = [...before, config, ...after]; + } else { + updatedArrayElements = [...exportArrayLiteral.elements, config]; + } + } else { + updatedArrayElements = options.insertAtTheEnd + ? [...exportArrayLiteral.elements, config] + : [config, ...exportArrayLiteral.elements]; + } const updatedExportDefault = ts.factory.createExportAssignment( undefined, @@ -964,6 +981,33 @@ function addBlockToFlatConfigExportCJS( printer .printNode(ts.EmitHint.Expression, config, source) .replaceAll(/\n/g, '\n '); + + if (options.checkBaseConfig) { + const baseConfigElement = exportsArray.find( + (el) => + ts.isSpreadElement(el) && + ts.isIdentifier(el.expression) && + el.expression.text === 'baseConfig' + ); + if (baseConfigElement) { + // Match baseConfig's indentation for consistent formatting + const baseConfigStart = baseConfigElement.getStart(); + const lineStart = content.lastIndexOf('\n', baseConfigStart) + 1; + const indentation = content.substring(lineStart, baseConfigStart); + const configText = printer + .printNode(ts.EmitHint.Expression, config, source) + .replaceAll(/\n/g, `\n${indentation}`); + return applyChangesToString(content, [ + { + type: ChangeType.Insert, + index: baseConfigStart, + text: `${configText},\n${indentation}`, + }, + ]); + } + // baseConfig not found — fall through to insertAtTheEnd behavior + } + if (options.insertAtTheEnd) { const index = exportsArray.length > 0 diff --git a/packages/expo/src/generators/library/library.spec.ts b/packages/expo/src/generators/library/library.spec.ts index 5874307622b..980506aa73e 100644 --- a/packages/expo/src/generators/library/library.spec.ts +++ b/packages/expo/src/generators/library/library.spec.ts @@ -341,16 +341,16 @@ describe('lib', () => { moduleFileExtensions: ['ts', 'js', 'html', 'tsx', 'jsx'], setupFilesAfterEnv: ['/src/test-setup.ts'], moduleNameMapper: { - '\\\\.svg$': '@nx/expo/plugins/jest/svg-mock', + '[.]svg$': '@nx/expo/plugins/jest/svg-mock', }, transform: { - '\\\\.[jt]sx?$': [ + '[.][jt]sx?$': [ 'babel-jest', { configFile: __dirname + '/.babelrc.js', }, ], - '^.+\\\\.(bmp|gif|jpg|jpeg|mp4|png|psd|svg|webp|ttf|otf|m4v|mov|mp4|mpeg|mpg|webm|aac|aiff|caf|m4a|mp3|wav|html|pdf|obj)$': + '^.+[.](bmp|gif|jpg|jpeg|mp4|png|psd|svg|webp|ttf|otf|m4v|mov|mp4|mpeg|mpg|webm|aac|aiff|caf|m4a|mp3|wav|html|pdf|obj)$': require.resolve('jest-expo/src/preset/assetFileTransformer.js'), }, coverageDirectory: '../coverage/my-lib', diff --git a/packages/expo/src/utils/add-linting.ts b/packages/expo/src/utils/add-linting.ts index 7f9376d5daa..16c494c5e2d 100644 --- a/packages/expo/src/utils/add-linting.ts +++ b/packages/expo/src/utils/add-linting.ts @@ -84,7 +84,8 @@ export async function addLinting(host: Tree, options: NormalizedSchema) { addPredefinedConfigToFlatLintConfig( host, options.projectRoot, - 'flat/react' + 'flat/react', + { checkBaseConfig: true } ); // Add an empty rules object to users know how to add/override rules addOverrideToLintConfig(host, options.projectRoot, { diff --git a/packages/expo/src/utils/jest/add-jest.ts b/packages/expo/src/utils/jest/add-jest.ts index 9461b6288fe..d5e03436721 100644 --- a/packages/expo/src/utils/jest/add-jest.ts +++ b/packages/expo/src/utils/jest/add-jest.ts @@ -55,16 +55,16 @@ module.exports = { moduleFileExtensions: ['ts', 'js', 'html', 'tsx', 'jsx'], setupFilesAfterEnv: ['/src/test-setup.${js ? 'js' : 'ts'}'], moduleNameMapper: { - '\\\\.svg$': '@nx/expo/plugins/jest/svg-mock' + '[.]svg$': '@nx/expo/plugins/jest/svg-mock' }, transform: { - '\\\\.[jt]sx?$': [ + '[.][jt]sx?$': [ 'babel-jest', { configFile: __dirname + '/.babelrc.js', }, ], - '^.+\\\\.(bmp|gif|jpg|jpeg|mp4|png|psd|svg|webp|ttf|otf|m4v|mov|mp4|mpeg|mpg|webm|aac|aiff|caf|m4a|mp3|wav|html|pdf|obj)$': require.resolve( + '^.+[.](bmp|gif|jpg|jpeg|mp4|png|psd|svg|webp|ttf|otf|m4v|mov|mp4|mpeg|mpg|webm|aac|aiff|caf|m4a|mp3|wav|html|pdf|obj)$': require.resolve( 'jest-expo/src/preset/assetFileTransformer.js' ), }, diff --git a/packages/next/src/generators/application/application.spec.ts b/packages/next/src/generators/application/application.spec.ts index 86b8fa31ba3..67b074fbe75 100644 --- a/packages/next/src/generators/application/application.spec.ts +++ b/packages/next/src/generators/application/application.spec.ts @@ -596,8 +596,8 @@ describe('app', () => { export default [ { plugins: { '@next/next': nextEslintPluginNext } }, - ...baseConfig, ...nx.configs['flat/react-typescript'], + ...baseConfig, { ignores: ['.next/**/*'], }, @@ -624,8 +624,8 @@ describe('app', () => { module.exports = [ { plugins: { '@next/next': nextEslintPluginNext } }, - ...baseConfig, ...nx.configs['flat/react-typescript'], + ...baseConfig, { ignores: ['.next/**/*'], }, diff --git a/packages/next/src/generators/application/lib/add-linting.spec.ts b/packages/next/src/generators/application/lib/add-linting.spec.ts index 2ef216c57dc..6d448ee146c 100644 --- a/packages/next/src/generators/application/lib/add-linting.spec.ts +++ b/packages/next/src/generators/application/lib/add-linting.spec.ts @@ -110,8 +110,8 @@ describe('updateEslint', () => { module.exports = [ { plugins: { "@next/next": nextEslintPluginNext } }, - ...baseConfig, ...nx.configs["flat/react-typescript"], + ...baseConfig, { ignores: [ ".next/**/*" diff --git a/packages/next/src/generators/application/lib/add-linting.ts b/packages/next/src/generators/application/lib/add-linting.ts index bf16852f445..b24c61009f1 100644 --- a/packages/next/src/generators/application/lib/add-linting.ts +++ b/packages/next/src/generators/application/lib/add-linting.ts @@ -51,7 +51,8 @@ export async function addLinting( addPredefinedConfigToFlatLintConfig( host, options.appProjectRoot, - 'flat/react-typescript' + 'flat/react-typescript', + { checkBaseConfig: true } ); if (await isNext16(host)) { addPluginsToLintConfig(host, options.appProjectRoot, ['@next/next']); diff --git a/packages/playwright/src/utils/add-linter.ts b/packages/playwright/src/utils/add-linter.ts index 269cc8fc90b..478dff98f0e 100644 --- a/packages/playwright/src/utils/add-linter.ts +++ b/packages/playwright/src/utils/add-linter.ts @@ -83,10 +83,12 @@ export async function addLinterToPlaywrightProject( tree, projectConfig.root, 'flat/recommended', - 'playwright', - 'eslint-plugin-playwright', - false, - false + { + moduleName: 'playwright', + moduleImportPath: 'eslint-plugin-playwright', + spread: false, + insertAtTheEnd: false, + } ); addOverrideToLintConfig(tree, projectConfig.root, { files: ['*.ts', '*.js'], diff --git a/packages/react-native/src/generators/application/application.spec.ts b/packages/react-native/src/generators/application/application.spec.ts index 4186126e694..383ba5b9a17 100644 --- a/packages/react-native/src/generators/application/application.spec.ts +++ b/packages/react-native/src/generators/application/application.spec.ts @@ -80,16 +80,16 @@ describe('app', () => { moduleFileExtensions: ['ts', 'js', 'html', 'tsx', 'jsx'], setupFilesAfterEnv: ['/src/test-setup.ts'], moduleNameMapper: { - '\\\\.svg$': '@nx/react-native/plugins/jest/svg-mock', + '[.]svg$': '@nx/react-native/plugins/jest/svg-mock', }, transform: { - '^.+\\.(js|ts|tsx)$': [ + '^.+[.](js|ts|tsx)$': [ 'babel-jest', { configFile: __dirname + '/.babelrc.js', }, ], - '^.+\\.(bmp|gif|jpg|jpeg|mp4|png|psd|svg|webp)$': require.resolve( + '^.+[.](bmp|gif|jpg|jpeg|mp4|png|psd|svg|webp)$': require.resolve( 'react-native/jest/assetFileTransformer.js', ), }, diff --git a/packages/react-native/src/generators/library/library.spec.ts b/packages/react-native/src/generators/library/library.spec.ts index 01318e65235..b5fc6ed5d7a 100644 --- a/packages/react-native/src/generators/library/library.spec.ts +++ b/packages/react-native/src/generators/library/library.spec.ts @@ -292,16 +292,16 @@ describe('lib', () => { moduleFileExtensions: ['ts', 'js', 'html', 'tsx', 'jsx'], setupFilesAfterEnv: ['/src/test-setup.ts'], moduleNameMapper: { - '\\\\.svg$': '@nx/react-native/plugins/jest/svg-mock', + '[.]svg$': '@nx/react-native/plugins/jest/svg-mock', }, transform: { - '^.+\\.(js|ts|tsx)$': [ + '^.+[.](js|ts|tsx)$': [ 'babel-jest', { configFile: __dirname + '/.babelrc.js', }, ], - '^.+\\.(bmp|gif|jpg|jpeg|mp4|png|psd|svg|webp)$': require.resolve( + '^.+[.](bmp|gif|jpg|jpeg|mp4|png|psd|svg|webp)$': require.resolve( 'react-native/jest/assetFileTransformer.js', ), }, diff --git a/packages/react-native/src/utils/add-jest.ts b/packages/react-native/src/utils/add-jest.ts index d6e8840ce83..fbfd4d85e8d 100644 --- a/packages/react-native/src/utils/add-jest.ts +++ b/packages/react-native/src/utils/add-jest.ts @@ -45,16 +45,16 @@ module.exports = { moduleFileExtensions: ['ts', 'js', 'html', 'tsx', 'jsx'], setupFilesAfterEnv: ['/src/test-setup.${js ? 'js' : 'ts'}'], moduleNameMapper: { - '\\\\.svg$': '@nx/react-native/plugins/jest/svg-mock' + '[.]svg$': '@nx/react-native/plugins/jest/svg-mock' }, transform: { - '^.+\\.(js|ts|tsx)$': [ + '^.+[.](js|ts|tsx)$': [ 'babel-jest', { configFile: __dirname + '/.babelrc.js', }, ], - '^.+\\.(bmp|gif|jpg|jpeg|mp4|png|psd|svg|webp)$': require.resolve( + '^.+[.](bmp|gif|jpg|jpeg|mp4|png|psd|svg|webp)$': require.resolve( 'react-native/jest/assetFileTransformer.js' ), }, diff --git a/packages/react-native/src/utils/add-linting.ts b/packages/react-native/src/utils/add-linting.ts index ebe8749ce5c..3d215396893 100644 --- a/packages/react-native/src/utils/add-linting.ts +++ b/packages/react-native/src/utils/add-linting.ts @@ -84,7 +84,8 @@ export async function addLinting(host: Tree, options: NormalizedSchema) { addPredefinedConfigToFlatLintConfig( host, options.projectRoot, - 'flat/react' + 'flat/react', + { checkBaseConfig: true } ); // Add an empty rules object to users know how to add/override rules addOverrideToLintConfig(host, options.projectRoot, { diff --git a/packages/react/src/generators/application/lib/add-linting.ts b/packages/react/src/generators/application/lib/add-linting.ts index 61064d06116..a6bbe64b0e9 100644 --- a/packages/react/src/generators/application/lib/add-linting.ts +++ b/packages/react/src/generators/application/lib/add-linting.ts @@ -41,7 +41,8 @@ export async function addLinting(host: Tree, options: NormalizedSchema) { addPredefinedConfigToFlatLintConfig( host, options.appProjectRoot, - 'flat/react' + 'flat/react', + { checkBaseConfig: true } ); // Add an empty rules object to users know how to add/override rules addOverrideToLintConfig(host, options.appProjectRoot, { diff --git a/packages/react/src/generators/library/lib/add-linting.ts b/packages/react/src/generators/library/lib/add-linting.ts index 638955483c1..aef8a22e2f0 100644 --- a/packages/react/src/generators/library/lib/add-linting.ts +++ b/packages/react/src/generators/library/lib/add-linting.ts @@ -40,7 +40,8 @@ export async function addLinting(host: Tree, options: NormalizedSchema) { addPredefinedConfigToFlatLintConfig( host, options.projectRoot, - 'flat/react' + 'flat/react', + { checkBaseConfig: true } ); // Add an empty rules object to users know how to add/override rules addOverrideToLintConfig(host, options.projectRoot, { diff --git a/packages/vue/src/utils/add-linting.ts b/packages/vue/src/utils/add-linting.ts index 43c83070f04..cc8d06af28a 100644 --- a/packages/vue/src/utils/add-linting.ts +++ b/packages/vue/src/utils/add-linting.ts @@ -135,8 +135,7 @@ function editEslintConfigFiles(tree: Tree, projectRoot: string) { tree, projectRoot, 'flat/recommended', - 'vue', - 'eslint-plugin-vue' + { moduleName: 'vue', moduleImportPath: 'eslint-plugin-vue' } ); // This allows .vue files to be parsed addOverrideToLintConfig(