Given a project with its node's package.json
installing eslint and a few plugins, how can I know where a particular rule is set?
I see a rule being applied (space-before-function-paren
) but I cannot find it either in any of the .eslintrc
files in the project, or in the documentation of the plugins.
Additionally, I'm working with VSCode with some extensions such as ESLint itself, which could potentially be interfering here, but again I'm not sure how/where to check which part is applying that rule (though I think this is unlikely to be happening, as npm run lint
fails if the code fails against the mentioned rule.
I'm posting the relevant parts of the package.json file:
{
// ...
"scripts": {
"watch": "NODE_ENV=development node build/build.js --watch",
"build": "NODE_ENV=development node build/build.js",
"build:prod": "NODE_ENV=production node build/build.js",
"unit": "NODE_ENV=test jest --config test/unit/jest.conf.js --coverage",
"test": "npm run unit",
"lint": "eslint --ext .js,.vue src test/unit/specs",
"ci-lint": "eslint --ext .js,.vue src test/unit/specs --format checkstyle --output-file lint_out/unit_timeline.xml"
},
"devDependencies": {
"@vue/test-utils": "^1.0.0-beta.27",
"autoprefixer": "^8.2.0",
"babel-core": "^6.26.0",
"babel-eslint": "^8.2.2",
"babel-jest": "^22.4.3",
"babel-loader": "^7.1.4",
"babel-plugin-dynamic-import-node": "^2.2.0",
"babel-plugin-transform-es2015-modules-commonjs": "^6.26.2",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-preset-env": "^1.7.0",
"babel-preset-stage-2": "^6.24.1",
"chalk": "^2.3.2",
"copy-webpack-plugin": "^4.5.1",
"css-loader": "^0.28.11",
"cssnano": "^3.10.0",
"eslint": "^5.10.0",
"eslint-config-standard": "^12.0.0",
"eslint-friendly-formatter": "^4.0.1",
"eslint-loader": "^2.1.1",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-node": "^8.0.0",
"eslint-plugin-promise": "^4.0.1",
"eslint-plugin-standard": "^4.0.0",
"eslint-plugin-vue": "^5.0.0",
"extract-text-webpack-plugin": "^3.0.2",
"file-loader": "^1.1.11",
"friendly-errors-webpack-plugin": "^1.6.1",
"html-webpack-plugin": "^3.1.0",
"jest": "^22.4.3",
"jest-junit": "^3.6.0",
"jest-serializer-vue": "^1.0.0",
"node-notifier": "^5.2.1",
"optimize-css-assets-webpack-plugin": "^3.2.0",
"ora": "^2.0.0",
"portfinder": "^1.0.13",
"postcss-import": "^11.1.0",
"postcss-loader": "^2.1.3",
"postcss-url": "^7.3.1",
"rimraf": "^2.6.2",
"sass-loader": "^6.0.7",
"semver": "^5.5.0",
"shelljs": "^0.8.1",
"uglifyjs-webpack-plugin": "^1.2.4",
"url-loader": "^1.0.1",
"vue-jest": "^2.3.0",
"vue-loader": "^14.2.2",
"vue-style-loader": "^4.1.0",
"vue-template-compiler": "^2.5.21",
"webpack": "^3.11.0",
"webpack-bundle-analyzer": "^2.11.1",
"webpack-file-list-plugin": "0.0.6",
"webpack-merge": "^4.1.2",
"yargs": "^11.0.0"
}
// ...
}
There are two primary ways to configure ESLint: Configuration Comments - use JavaScript comments to embed configuration information directly into a file. Configuration Files - use a JavaScript, JSON, or YAML file to specify configuration information for an entire directory and all of its subdirectories.
To temporarily turn off ESLint, you should add a block comment /* eslint-disable */ before the lines that you're interested in: /* eslint-disable */ console.
Fixing “'BigInt' is not defined”. When using the BigInt data type with ESLint, you may run into the following error message: 'BigInt' is not defined (eslintno-undef) You can fix this on your side by updating your ESLint configuration file. For example, you may use an ESLint JSON config stored in .eslintrc.json.
Add defineProps to globals in eslint. From docs: module.exports = { + globals: { + defineProps: "readonly", + } }
The module global is specific to Node.js, ESLint needs to be configured to recognize it. To enable node support, add it to the env field in the ESLint config https://eslint.org/docs/user-guide/configuring#specifying-environments
Unfortunately, it seems there's no "eslint" way to perform such a report.
If you run eslint
with debug options, you get a lot of information about how the program runs: what file is processing, with which configuration, how it fails, etc., but not from where a rule was taken.
I managed to find it by simply running a grep + find
within the node_modules
directory, and being sure which module was providing the rule by simply changing it and seeing the eslint
results afterwards.
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