How do I:
ESLint flat config is quite different from the previous format. To help understand the "flat config" the following pointers helped me:
.eslintignore is no longer available)Setup for VS Code - at the time of writing you'll need:
v3.0.5 or above (this currently requires "switch to pre-release version") in the plugin's installation page"eslint.useFlatConfig": true to your settings.json (this was previously eslint.experimental.useFlatConfig)Install the following dependencies:
yarn add --dev \
eslint \
@eslint/js \
typescript-eslint \
--
Use the following eslint.config.mjs file to get you started (locate it alongside package.json). This provides defaults from https://typescript-eslint.io/getting-started/. This config additionally allows you to add ignored files, which is useful because .eslintignore is no longer available. NB the config is 'just Javascript' so you can make additional changes. This uses module.exports which avoids the need to add type: "module" to package.json:
// @ts-check
import eslint from '@eslint/js';
import tseslint from 'typescript-eslint';
// https://typescript-eslint.io/getting-started/
const ignores = [
'**/*.js',
];
export default tseslint.config(
{
...eslint.configs.recommended,
ignores,
},
...tseslint.configs.recommended.map((config) => ({
...config,
ignores,
})),
);
Pro:
Con:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With