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.

[Request] use constants for linter error levels

See original GitHub issue

My team has forked this project a couple times because linting rules are mostly 2/error instead of 1/warning, so it obscures genuine errors.

Something like this:

<Foo b={} a={} /> // props sorted wrong

Should not have the same severity as a critical bug! This adds a ton of mental overhead to every line when red dots are popping up everywhere: “will this code throw an error or is there some minor formatting issue?”

Needing to be so precious with every line slows down development when you may just be testing some additions or wading into third party code.

Doubly with autofix enabled, Atom currently fixes a ton of formatting inconsistencies on save, I can safely ignore some warnings now.

However, I understand your logic in #853 – when you need to enforce absolute consistency in your team, saying “you can’t proceed without fixing this niggle” is important. I would argue that should go in a commit hook or similar, but…

why not use a custom constant to define the error levels? This would allow the linting logic to be more flexible:

{ rule: airbnb.ERROR }

Issue Analytics

  • State:open
  • Created 7 years ago
  • Reactions:3
  • Comments:5

github_iconTop GitHub Comments

1reaction
ljharbcommented, Aug 16, 2016

The M&M clause is a very apt analogy, yes 😃

Things that might be obscuring errors, are themselves errors. I totally understand there are occasionally workflows where fast iteration matters more than correctness/style, but those aren’t the majority, and it’s better to inconvenience those people, and risk that they’re slower, then to risk that the majority has more brittle code.

One concern I’ve heard about the env var approach is ease of configurability in editors, which is where most people would probably prefer the flexibility. Those interested in this configurability can help by commenting with ways that demonstrate how to configure env vars for linting in popular editors/IDEs 😃

1reaction
bracocommented, Aug 16, 2016

@ljharb: thanks for the discussion.

The logic you’re using in that first link is a bit like the brown M&M test – if you suck at this part, you probably suck at other parts. That’s a good rule of thumb, but that could also be enforced by rejecting PR/pushes with any warnings, among other things. In the meantime, rephrasing “warning, this might be obscuring an error” as “this is an error” is an extreme style in itself and broadly impacts everyone that uses this popular and thoughtful ruleset. (My team doesn’t check up any code with linter warnings, for example, but the in-editor distinction is kept)

Formatting is of utmost importance, but there is a difference between “this should be fixed” and “this code will not compile”. It’s easy to come up with some silly examples, like errors from a trailing space inside a comment block sitting next to errors from a missing comma inside an object init. I guess there’s probably an argument in here for a protected eslint level or editor differentiation for compile errors…

Regarding saving to preemptively autofix formatting: it doesn’t fix everything yet, and if you’ve got some form of hot reload/autobuild going, you may be loading a critically broken script. That’s why I would scan for red-dot errors first.

I think much of this comes down to workflow preferences, and the constant would go a long way into making the package more flexible. Thanks for considering, and for all your output here in general.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Linters | golangci-lint
Name Description Presets Since asasalint ⚙️ check for pass any as any in variadic func(...any) bugs 1.47.0 bidichk ⚙️ Checks for dangerous unicode character sequences...
Read more >
Linter rules - Dart
You can use the linter through your IDE or with the dart analyze command. ... These rules identify possible errors and other mistakes...
Read more >
Rules - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >
clj-kondo/linters.md at master - GitHub
Static analyzer and linter for Clojure code that sparks joy - clj-kondo/linters.md at master · clj-kondo/clj-kondo.
Read more >
lint Source Code Checker - Oracle Help Center
The lint program issues every error and warning message produced by the C compiler. ... Unused # include directives, variables, and procedures; Memory...
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