Skip to content

Commit

Permalink
Clarify eslint --print-config usage
Browse files Browse the repository at this point in the history
I thought that `--print-config` to a config file path as argument, but
it takes _any_ file path as argument. ESLint starts looking for config
files from that file and upwards in the file system.

(If one wishes to specify a config file via a flag, the command is
`eslint --config config.js --print-config some/file.js`.)
  • Loading branch information
lydell committed Aug 13, 2018
1 parent c97f0d4 commit e0bee25
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
12 changes: 10 additions & 2 deletions README.md
Expand Up @@ -58,14 +58,20 @@ First, add a script for it to package.json:
```json
{
"scripts": {
"eslint-check": "eslint --print-config .eslintrc.js | eslint-config-prettier-check"
"eslint-check": "eslint --print-config . | eslint-config-prettier-check"
}
}
```

Then run `npm run eslint-check`.

(Swap out .eslintrc.js with the path to your config if needed.)
If you use [multiple configuration files] or [overrides], you may need to run
the above script several times with different `--print-config` arguments, such
as:

```
eslint --print-config test/index.js | eslint-config-prettier-check
```

Exit codes:

Expand Down Expand Up @@ -524,10 +530,12 @@ several other npm scripts:
[eslint-plugin-standard]: https://github.com/xjamundx/eslint-plugin-standard
[lines-around-comment]: https://eslint.org/docs/rules/lines-around-comment
[max-len]: https://eslint.org/docs/rules/max-len
[multiple configuration files]: https://eslint.org/docs/user-guide/configuring#configuration-cascading-and-hierarchy
[no-confusing-arrow]: https://eslint.org/docs/rules/no-confusing-arrow
[no-mixed-operators]: https://eslint.org/docs/rules/no-mixed-operators
[no-tabs]: https://eslint.org/docs/rules/no-tabs
[no-unexpected-multiline]: https://eslint.org/docs/rules/no-unexpected-multiline
[overrides]: https://eslint.org/docs/user-guide/configuring#configuration-based-on-glob-patterns
[quotes]: https://eslint.org/docs/rules/quotes
[travis-badge]: https://travis-ci.org/prettier/eslint-config-prettier.svg?branch=master
[travis]: https://travis-ci.org/prettier/eslint-config-prettier
5 changes: 2 additions & 3 deletions bin/cli.js
Expand Up @@ -16,9 +16,8 @@ if (module === require.main) {
"This tool checks whether an ESLint configuration contains rules that are",
"unnecessary or conflict with Prettier. It’s supposed to be run like this:",
"",
" eslint --print-config .eslintrc.js | eslint-config-prettier-check",
"",
"(Swap out .eslintrc.js with the path to your config if needed.)",
" eslint --print-config . | eslint-config-prettier-check",
" eslint --print-config test/index.js | eslint-config-prettier-check",
"",
"Exit codes:",
"",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -25,7 +25,7 @@
"test:lint-verify-fail": "eslint test-lint/ --config .eslintrc.base.js --format json",
"test:lint-rules": "eslint index.js --config test-config/.eslintrc.js --format json",
"test:jest": "jest",
"test:cli-sanity": "eslint --print-config .eslintrc.js | node ./bin/cli.js",
"test:cli-sanity": "eslint --print-config . | node ./bin/cli.js",
"test": "npm run test:lint && npm run test:jest && npm run test:cli-sanity"
},
"dependencies": {
Expand Down

0 comments on commit e0bee25

Please sign in to comment.