Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor eslint configs inside tseslint.config #2182

Merged
merged 1 commit into from
Apr 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,34 @@ const tseslint = require('typescript-eslint');
const prettier = require('eslint-config-prettier');
//const jsdoc = require('eslint-plugin-jsdoc');

// Using tseslint config helper to customise its setup the tseslint way.
// Only run tseslint on the files that we have included for TypeScript.
const tsconfigTsFiles = ['**/*.{ts,mts}']; // match "include" in tsconfig.ts.json;
const tsconfigJsFiles = ['*.{js,mjs}', 'lib/**/*.{js,mjs}']; // match "include" in tsconfig.js.json
const tseslintConfigs = tseslint.config(

// Using tseslint.config adds some type safety and `extends` to simplify customising config array.
module.exports = tseslint.config(
// Add recommended rules.
esLintjs.configs.recommended,
// jsdoc.configs['flat/recommended'],
jest.configs['flat/recommended'],
// tseslint with different setup for js/ts
{
files: tsconfigJsFiles,
extends: [...tseslint.configs.recommended],
languageOptions: {
parserOptions: { project: './tsconfig.js.json' },
},
extends: [...tseslint.configs.recommended],
rules: {
'@typescript-eslint/no-var-requires': 'off', // (tseslint does not autodetect commonjs context )
'@typescript-eslint/no-var-requires': 'off', // tseslint does not autodetect commonjs context
},
},
{
files: tsconfigTsFiles,
extends: [...tseslint.configs.recommended],
languageOptions: {
parserOptions: { project: './tsconfig.ts.json' },
},
extends: [...tseslint.configs.recommended],
},
);

module.exports = [
esLintjs.configs.recommended,
// jsdoc.configs['flat/recommended'],
jest.configs['flat/recommended'],
...tseslintConfigs,
prettier, // Do Prettier last so it can override previous configs.

// Customise rules.
Expand Down Expand Up @@ -72,4 +72,4 @@ module.exports = [
],
},
},
];
);