I have some rules inside my root .eslintrc.json. This is the file.
{
"root": true,
"ignorePatterns": ["**/*"],
"plugins": ["@nrwl/nx", "react", "@typescript-eslint", "prettier"],
"extends": [
"plugin:react/recommended",
"google",
"plugin:@typescript-eslint/recommended",
"prettier"
],
"rules": {
"camelcase": "off",
"prettier/prettier": 0,
"no-unused-vars": "error",
"@typescript-eslint/no-unused-vars": "error",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/no-empty-function": "off",
"require-jsdoc": 0,
"no-invalid-this": 0,
"valid-jsdoc": 0,
"indent": "off",
"linebreak-style": "off",
"object-curly-spacing": 0,
"quotes": ["error", "single"],
"semi": ["error", "always"],
"operator-linebreak": [
"error",
"after",
{ "overrides": { "?": "before", ":": "before" } }
],
// React
"react/prop-types": 0,
"react/react-in-jsx-scope": 0, // NEXT dynamic imports
"comma-dangle": [
"error",
{
"arrays": "only-multiline",
"objects": "only-multiline",
"imports": "only-multiline",
"exports": "only-multiline",
"functions": "only-multiline"
}
],
"max-len": [
"error",
{
"code": 80,
"ignoreTrailingComments": true,
"ignoreRegExpLiterals": true,
"ignoreUrls": true,
"tabWidth": 2,
"ignorePattern": ".*[as|import]"
}
]
},
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {
"@nrwl/nx/enforce-module-boundaries": [
"error",
{
"enforceBuildableLibDependency": true,
"allow": [],
"depConstraints": [
{
"sourceTag": "*",
"onlyDependOnLibsWithTags": ["*"]
}
]
}
]
}
},
{
"files": ["*.ts", "*.tsx"],
"extends": ["plugin:@nrwl/nx/typescript"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"extends": ["plugin:@nrwl/nx/javascript"],
"rules": {}
}
]
}
I have a .eslintrc.json inside one of my projects, that extends rules from the root file. However, the rules are not being applied. This is what the file looks like.
{
"extends": ["plugin:@nrwl/nx/react", "../../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
}
],
"rules": {
"camelcase": "off",
"prettier/prettier": 0,
"no-unused-vars": "error",
"@typescript-eslint/no-unused-vars": "error",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/no-empty-function": "off",
"require-jsdoc": 0,
"no-invalid-this": 0,
"valid-jsdoc": 0,
"indent": "off",
"linebreak-style": "off",
"object-curly-spacing": 0,
"quotes": ["error", "single"],
"semi": ["error", "always"],
"operator-linebreak": [
"error",
"after",
{ "overrides": { "?": "before", ":": "before" } }
],
// React
"react/prop-types": 0,
"react/react-in-jsx-scope": 0, // NEXT dynamic imports
"comma-dangle": [
"error",
{
"arrays": "only-multiline",
"objects": "only-multiline",
"imports": "only-multiline",
"exports": "only-multiline",
"functions": "only-multiline"
}
],
"max-len": [
"error",
{
"code": 80,
"ignoreTrailingComments": true,
"ignoreRegExpLiterals": true,
"ignoreUrls": true,
"tabWidth": 2,
"ignorePattern": ".*[as|import]"
}
]
}
}
Because of this, I'm being forced to manually copy over the rules from the root file to the file inside the project. This is not ideal, so I was hoping someone could point out what I could be doing wrong.