question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Feature request] Lint only certain lines in a file

See original GitHub issue

My motivation for this feature request is that the same that precise-commits addresses. I want to be able to --fix only the lines that I’ve changed in a source file. precise-commits lays out some of the drawbacks of applying --fix on a particularly large file:

  • Increases the complexity and review time burden of PRs on senior team members.
  • Potentially increases the amount of time it takes to complete a PR in the first place.
  • Can block concurrent work on the same codebase and/or result in nasty merge conflicts with outstanding feature branches.

If I make a change on line 10 of a 4000 line file, I shouldn’t be forced to reformat all 4000s lines (thus making me the last git user to update all of them) as part of my PR. I should just need to reformat line 10.

This may already be possible by splicing changes and passing them to eslint’s --stdin. Either way, consider this request a conversation starter.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:5
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
betaorbustcommented, Nov 2, 2018

We would also like this feature, as we’d like to enforce folks fixing/modifying their own changes while not making them fix the entire file. This use case for us is in a large team, with incoming new lint rules, and large files that the engineer might not have all the context on. We don’t want to block their PRs or pushes because everything isn’t perfect, but we’d like to ensure that new/modified code is within our current styles.

2reactions
not-an-aardvarkcommented, Mar 23, 2018

I’ve had a related use case in the past where I wanted to gradually enable ESLint on a large codebase, but running eslint --fix on the whole codebase (or even fixing problems one rule at a time) was undesirable because it would mess up the git history and cause a lot of merge conflicts. In that case, it would have been useful to have a general heuristic of “Only report problems that weren’t present before this change, or problems that appear on a line that has been changed.” As a result of following this heuristic, the codebase would gradually become more consistent as lines were changed, without interfering with git history.

I’m not sure what the best way to enforce that heuristic is (whether it’s something that should be handled in ESLint core or elsewhere), but hopefully that explains a potential use case.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Linting Python in Visual Studio Code
The Select Linter command adds "python.linting.<linter>Enabled": true to your settings, where <linter> is the name of the chosen linter. See Specific ...
Read more >
Push rules - GitLab Docs
Use these rules for your commit messages. Require expression in commit messages: Messages must match the expression. To allow any commit message, leave...
Read more >
How to contribute - Arduino Lint - GitHub Pages
Support requests should be made to the Arduino forum. High quality bug reports and feature requests are valuable contributions to the Arduino Lint...
Read more >
Configuring ESLint - ESLint - Pluggable JavaScript Linter
You can turn off every rule and run only with basic syntax validation or mix and ... Configuration Files - use a JavaScript,...
Read more >
Gitlint - Joris Roovers
Gitlint support for Windows is experimental, and there are some known issues. Also, gitlint is not the only git commit message linter out...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found