Skip to content

Commit

Permalink
Fix eslint plugin (eslint.config.js missed as entry file)
Browse files Browse the repository at this point in the history
  • Loading branch information
webpro committed Oct 7, 2023
1 parent 12bbf7e commit 3f1a5f0
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import prettier from 'eslint-plugin-prettier';
import noSecrets from 'eslint-plugin-no-secrets';

export default [
'eslint:recommended',
{
plugins: {
prettier,
'no-secrets': noSecrets,
},
},
];
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
},
"devDependencies": {
"vitest": "*",
"happy-dom": "*"
"happy-dom": "*",
"eslint-plugin-no-secrets": "*",
"eslint-plugin-prettier": "*"
}
}
3 changes: 1 addition & 2 deletions src/plugins/eslint/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ or `devDependencies`:
```json
{
"eslint": {
"config": [".eslintrc", ".eslintrc.{js,json,cjs}", ".eslintrc.{yml,yaml}", "package.json"],
"entry": ["eslint.config.js"]
"config": ["eslint.config.js", ".eslintrc", ".eslintrc.{js,json,cjs}", ".eslintrc.{yml,yaml}", "package.json"]
}
}
```
Expand Down
14 changes: 12 additions & 2 deletions src/plugins/eslint/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,27 @@ export const isEnabled: IsPluginEnabledCallback = ({ dependencies, manifest, con
Boolean(manifest.name && /(^eslint-config|\/eslint-config)/.test(manifest.name));

// Current: https://eslint.org/docs/latest/user-guide/configuring/configuration-files
export const CONFIG_FILE_PATTERNS = ['.eslintrc', '.eslintrc.{js,json,cjs}', '.eslintrc.{yml,yaml}', 'package.json'];
export const CONFIG_FILE_PATTERNS = [
'eslint.config.js',
'.eslintrc',
'.eslintrc.{js,json,cjs}',
'.eslintrc.{yml,yaml}',
'package.json',
];

// New: https://eslint.org/docs/latest/user-guide/configuring/configuration-files-new
// We can handle eslint.config.js just like other source code (as dependencies are imported)
/** @public */
export const ENTRY_FILE_PATTERNS = ['eslint.config.js'];
export const ENTRY_FILE_PATTERNS = [];

// TODO Handle better. Make separate plugin?
// export const ENTRY_FILE_PATTERNS = ['eslint.config.js'];

// Note: shareable configs should use `peerDependencies` for plugins
// https://eslint.org/docs/latest/developer-guide/shareable-configs#publishing-a-shareable-config

const findESLintDependencies: GenericPluginCallback = async (configFilePath, { cwd, manifest, isProduction }) => {
if (configFilePath.endsWith('eslint.config.js')) return [];
if (isProduction) return [];
const dependencies = await getDependenciesDeep(configFilePath, new Set(), { cwd, manifest });
return Array.from(dependencies);
Expand Down
4 changes: 2 additions & 2 deletions tests/workspaces-plugin-config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ test('Use root plugin config in workspaces', async () => {

assert.deepEqual(counters, {
...baseCounters,
total: 9,
processed: 9,
total: 10,
processed: 10,
});
});

0 comments on commit 3f1a5f0

Please sign in to comment.