standard / semistandard

:icecream: All the goodness of `standard/standard` with semicolons sprinkled on top.
MIT License
1.41k stars 124 forks source link

Is there something like configuration cascading feature of eslint? #187

Closed kt3k closed 7 years ago

kt3k commented 7 years ago

eslint seems to have configuration cascade feature. http://eslint.org/docs/user-guide/configuring#configuration-cascading-and-hierarchy

It works like:

The configuration cascade works by using the closest .eslintrc file to the file being linted as the highest priority, then any configuration files in the parent directory, and so on. When you run ESLint on this project, all files in lib/ will use the .eslintrc file at the root of the project as their configuration. When ESLint traverses into the tests/ directory, it will then use your-project/tests/.eslintrc in addition to your-project/.eslintrc

I'm curious whether semistandard has this (or similar) feature. In our use case, we want to apply env: ['mocha'] option to only test/ directory and env: ['browser'] option to only browser/ (browser specific directory) etc.

Flet commented 7 years ago

semistandard uses the standard-engine package (just like standard) which intentionally ignores .eslintrc files, so this won't work the same way eslint does.

However, there is an --env command line switch. So, you could run separate lint commands for each directory:

semistandard --env mocha test/**/*.js

semistandard --env browser browser/**/*.js

# fancy glob syntax to include all except test and browser directories
semistandard !(test|browser)/**/*.js

Perhaps setting up separate npm scripts for each one will work?

Flet commented 7 years ago

Oh! one other option is to put this at the top of every test file:

/* eslint-env mocha */

And this at the top of every browser file:

/* eslint-env browser */

...This would allow for linting everything with a single command.

kt3k commented 7 years ago

Thanks for the quick response!

Command line solution seems to work with our use case. Thank you :)