Lint-staged: Lint-staged but to lint modified files from a pull request ?

Created on 8 Sep 2017  路  16Comments  路  Source: okonet/lint-staged

Hi,

I would like to get your feedback about a new tool / enhancement to lint-staged to lint modified files
from a pull request at build time.

Would you love it ?

What are your ideas to reuse the code from lint-staged to do it ?

WDYT ?

? Needs Validation ?

Most helpful comment

All 16 comments

I kinda like this idea

But is there any specific task you need to run?
I mean for ESLint, we can run eslint . --cache for jest there is jest --lastCommit

Yes, We may not be able to use --cache if build environnement is run on another node/agent ?

CMIIW I think ESLint reads from .eslintcache, so as long as we commit it in our repo ESLint will be able to check only modified files

@luftywiranda13 nice idea, is it a good practice to commit the eslint cache files ?

@luftywiranda13 BTW can we 'trust' a eslint cache file updated in a PR ? no malicious way to bypass the linter ?

Is this similar to #150?

@okonet I think @clakech wants to make a GitHub app with a bot which will get triggered when someone open a PR

Sorry, accidentally closed this. Fat fingers :s

@okonet nope I think this is a different use case. #150 is for current local unstaged files. This question is for "every single files modified in the current pull request that cas contains several commits". But yes, this can be out of scope of this lib. I am just getting feedback to find a path to a good solution ;)

For ESLint specifically, I personally against the idea of using --cache flag on ESLint to make sure the whole codebase get checked if the eslint config or eslint itself get updated

my use case is a legacy project with A LOT of eslint errors / warning and we may need to apply lint config only on new / modified files

Well, if we can ditch staged-git-files or make the first step pluggable this will be possible. I'm open for explorations since it might open interesting opportunities.

@clakech in this case the simplest way to do so is just to have separate .eslintrc in different directories. I have the same use case and it's totally covered by eslint.

I have a committed-git-files module now, forked from staged-git-files. I forked lint-staged too and plug this new module and tada now I got what I wanted.
I may contribute back this once I figure out how to insert my code elegantly.

commited-git-files could be a optional dependency of lint-staged and we could use a npm script:
lint-staged --target-branch origin/master

Was this page helpful?
0 / 5 - 0 ratings

Related issues

okonet picture okonet  路  5Comments

hadrienl picture hadrienl  路  8Comments

shermendev picture shermendev  路  4Comments

acusti picture acusti  路  6Comments

timche picture timche  路  5Comments