Skip to content

Commit

Permalink
fix(misc): ensure that eslint.config.js file is ignored for dep-check…
Browse files Browse the repository at this point in the history
…s rule
  • Loading branch information
jaysoo committed Sep 11, 2024
1 parent 00130f5 commit acbdcbc
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ function createEsLintConfiguration(
'error',
{
// With flat configs, we don't want to include imports in the eslint js/cjs/mjs files to be checked
ignoredFiles: ['**/*/*eslint*'],
ignoredFiles: ['{projectRoot}/eslint.config.{js,cjs,mjs}'],
},
],
},
Expand Down
16 changes: 11 additions & 5 deletions packages/js/src/generators/library/library.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ describe('lib', () => {
"error",
{
"ignoredFiles": [
"**/*/*eslint*",
"{projectRoot}/eslint.config.{js,cjs,mjs}",
],
},
],
Expand Down Expand Up @@ -605,7 +605,7 @@ describe('lib', () => {
"error",
{
"ignoredFiles": [
"**/*/*eslint*",
"{projectRoot}/eslint.config.{js,cjs,mjs}",
],
},
],
Expand Down Expand Up @@ -737,7 +737,7 @@ describe('lib', () => {
"error",
{
"ignoredFiles": [
"**/*/*eslint*",
"{projectRoot}/eslint.config.{js,cjs,mjs}",
],
},
],
Expand Down Expand Up @@ -1503,7 +1503,10 @@ describe('lib', () => {
'@nx/dependency-checks': [
'error',
{
ignoredFiles: ['{projectRoot}/esbuild.config.{js,ts,mjs,mts}'],
ignoredFiles: [
'{projectRoot}/eslint.config.{js,cjs,mjs}',
'{projectRoot}/esbuild.config.{js,ts,mjs,mts}',
],
},
],
},
Expand All @@ -1528,7 +1531,10 @@ describe('lib', () => {
'@nx/dependency-checks': [
'error',
{
ignoredFiles: ['{projectRoot}/rollup.config.{js,ts,mjs,mts}'],
ignoredFiles: [
'{projectRoot}/eslint.config.{js,cjs,mjs}',
'{projectRoot}/rollup.config.{js,ts,mjs,mts}',
],
},
],
},
Expand Down
21 changes: 12 additions & 9 deletions packages/js/src/generators/library/library.ts
Original file line number Diff line number Diff line change
Expand Up @@ -388,19 +388,22 @@ export async function addLint(
ruleOptions = {};
}
if (options.bundler === 'vite' || options.unitTestRunner === 'vitest') {
ruleOptions.ignoredFiles = [
'{projectRoot}/vite.config.{js,ts,mjs,mts}',
];
ruleOptions.ignoredFiles ??= [];
ruleOptions.ignoredFiles.push(
'{projectRoot}/vite.config.{js,ts,mjs,mts}'
);
o.rules['@nx/dependency-checks'] = [ruleSeverity, ruleOptions];
} else if (options.bundler === 'rollup') {
ruleOptions.ignoredFiles = [
'{projectRoot}/rollup.config.{js,ts,mjs,mts}',
];
ruleOptions.ignoredFiles ??= [];
ruleOptions.ignoredFiles.push(
'{projectRoot}/rollup.config.{js,ts,mjs,mts}'
);
o.rules['@nx/dependency-checks'] = [ruleSeverity, ruleOptions];
} else if (options.bundler === 'esbuild') {
ruleOptions.ignoredFiles = [
'{projectRoot}/esbuild.config.{js,ts,mjs,mts}',
];
ruleOptions.ignoredFiles ??= [];
ruleOptions.ignoredFiles.push(
'{projectRoot}/esbuild.config.{js,ts,mjs,mts}'
);
o.rules['@nx/dependency-checks'] = [ruleSeverity, ruleOptions];
}
return o;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,10 @@ describe('@nx/vite:configuration', () => {
'@nx/dependency-checks': [
'error',
{
ignoredFiles: ['{projectRoot}/vite.config.{js,ts,mjs,mts}'],
ignoredFiles: [
'{projectRoot}/eslint.config.{js,cjs,mjs}',
'{projectRoot}/vite.config.{js,ts,mjs,mts}',
],
},
],
},
Expand Down

0 comments on commit acbdcbc

Please sign in to comment.