I am using Angular with Eslint and Prettier configured for the entire project. All the files are checked correctly according to rules. Unfortunately, the files that have .mock
in name are completely ignored. The file is called for example test.mock.ts
and is ignored by Eslint/Prettier. If I rename it to test.mocks.ts
or anything else without the mock
keyword, it starts to work.
Does anyone know why it behave like this?
Eslint config file:
{
"extends": ["prettier"],
"plugins": ["prettier"],
"rules": {
"prettier/prettier": ["error"]
},
"root": true,
"ignorePatterns": [
"projects/**/*"
],
"overrides": [
{
"files": [
"*.ts"
],
"parserOptions": {
"project": [
"tsconfig.json"
],
"createDefaultProgram": true
},
"extends": [
"plugin:@angular-eslint/recommended",
"plugin:@angular-eslint/template/process-inline-templates"
],
"rules": {
...some rules...
}
}
]
}
Tsconfig file:
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"downlevelIteration": true,
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"module": "es2020",
"moduleResolution": "node",
"experimentalDecorators": true,
"importHelpers": true,
"typeRoots": [
"node_modules/@types"
],
"target": "es2020",
"lib": [
"es2020",
"dom"
],
"resolveJsonModule": true,
"allowSyntheticDefaultImports": true,
"paths": {
"@generated/*": [
"libs/shared/*"
],
}
}
}
Turned out I had in .eslintignore file rule to ignore all .mock files.