fix(linter): add cjs, cts, mjs, and mts to the default extensions for the inference plugin (#29534)
## Current Behavior
On the default generated eslint on a ts reference workspace, the config
allows for linting of cjs and mjs files
```js
const nx = require('@nx/eslint-plugin');
module.exports = [
...nx.configs['flat/base'],
...nx.configs['flat/typescript'],
...nx.configs['flat/javascript'],
{
ignores: ['**/dist'],
},
{
files: ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx'],
rules: {
'@nx/enforce-module-boundaries': [
'error',
{
enforceBuildableLibDependency: true,
allow: ['^.*/eslint(\\.base)?\\.config\\.[cm]?js$'],
depConstraints: [
{
sourceTag: '*',
onlyDependOnLibsWithTags: ['*'],
},
],
},
],
},
},
{
files: [
'**/*.ts',
'**/*.tsx',
'**/*.js',
'**/*.jsx',
'**/*.cjs',
'**/*.mjs',
],
// Override or add rules here
rules: {},
},
];
```
However, the default glob is not matching them
## Expected Behavior
All cjs and mjs files are included in the lint target detection
---------
Co-authored-by: Leosvel Pérez Espinosa <leosvel.perez.espinosa@gmail.com>
This commit is contained in:
parent
e2e9e6cb36
commit
dfbfe3b786
@ -158,6 +158,8 @@ export const getGlobalFlatEslintConfiguration = (
|
|||||||
files: [
|
files: [
|
||||||
'**/*.ts',
|
'**/*.ts',
|
||||||
'**/*.tsx',
|
'**/*.tsx',
|
||||||
|
'**/*.cts',
|
||||||
|
'**/*.mts',
|
||||||
'**/*.js',
|
'**/*.js',
|
||||||
'**/*.jsx',
|
'**/*.jsx',
|
||||||
'**/*.cjs',
|
'**/*.cjs',
|
||||||
|
|||||||
@ -327,6 +327,8 @@ describe('@nx/eslint:lint-project', () => {
|
|||||||
files: [
|
files: [
|
||||||
"**/*.ts",
|
"**/*.ts",
|
||||||
"**/*.tsx",
|
"**/*.tsx",
|
||||||
|
"**/*.cts",
|
||||||
|
"**/*.mts",
|
||||||
"**/*.js",
|
"**/*.js",
|
||||||
"**/*.jsx",
|
"**/*.jsx",
|
||||||
"**/*.cjs",
|
"**/*.cjs",
|
||||||
@ -396,6 +398,8 @@ describe('@nx/eslint:lint-project', () => {
|
|||||||
files: [
|
files: [
|
||||||
"**/*.ts",
|
"**/*.ts",
|
||||||
"**/*.tsx",
|
"**/*.tsx",
|
||||||
|
"**/*.cts",
|
||||||
|
"**/*.mts",
|
||||||
"**/*.js",
|
"**/*.js",
|
||||||
"**/*.jsx",
|
"**/*.jsx",
|
||||||
"**/*.cjs",
|
"**/*.cjs",
|
||||||
|
|||||||
@ -34,7 +34,18 @@ export interface EslintPluginOptions {
|
|||||||
extensions?: string[];
|
extensions?: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
const DEFAULT_EXTENSIONS = ['ts', 'tsx', 'js', 'jsx', 'html', 'vue'];
|
const DEFAULT_EXTENSIONS = [
|
||||||
|
'ts',
|
||||||
|
'cts',
|
||||||
|
'mts',
|
||||||
|
'tsx',
|
||||||
|
'js',
|
||||||
|
'cjs',
|
||||||
|
'mjs',
|
||||||
|
'jsx',
|
||||||
|
'html',
|
||||||
|
'vue',
|
||||||
|
];
|
||||||
const PROJECT_CONFIG_FILENAMES = ['project.json', 'package.json'];
|
const PROJECT_CONFIG_FILENAMES = ['project.json', 'package.json'];
|
||||||
const ESLINT_CONFIG_GLOB_V1 = combineGlobPatterns(
|
const ESLINT_CONFIG_GLOB_V1 = combineGlobPatterns(
|
||||||
ESLINT_CONFIG_FILENAMES.map((f) => `**/${f}`)
|
ESLINT_CONFIG_FILENAMES.map((f) => `**/${f}`)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user