A template for a Typescript repository
module.exports = {
env: {
es2022: true,
node: true,
},
overrides: [
{
files: ['**/*.js'],
extends: ['eslint:recommended'],
// https://eslint.org/docs/v8.x/use/configure/language-options#specifying-parser-options
parserOptions: {
ecmaVersion: '2022',
},
},
{
files: ['src**/*.ts'],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended-type-checked',
'plugin:@typescript-eslint/stylistic-type-checked',
],
plugins: ['@typescript-eslint'],
parser: '@typescript-eslint/parser',
parserOptions: {
project: true,
},
},
],
};
The newest version of ESLint is using the new flatconfig
format. Even though it looks cool sadly
the adaptation of it in the community has not yet reached to the point where it makes sense to start
using it. That is why this repo uses the 8.57.0
version which still defaults to the old config
file format. It has some consequences.
- The file has to be in CommonJS format since version
8.57.0
doesn't support anything else - The support both JS and Typescript by using the overrides property.
- Note that the
module.exports.overrides[0].parserOptions
needs to have a higher ECMA version specified as the default isES5
. For the Typescript configuration this is not needed as it reads the settings from thetsconfig
whenmodule.exports.overrides[1].parserOptions.project
is set totrue