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.

Proposal: Conditional rules based on the environment

See original GitHub issue

What version of ESLint are you using? 2.13.0

What parser (default, Babel-ESLint, etc.) are you using? default

Hello, I have a scenario where I would like to have different .eslint rules when developing locally on my machine than when it’s time to submit the project. Here is how eslint is currently useful to me for local development: As part of the build process, we run something like (simplified): rm -rf dist/ && eslint app/js && browserify app/js/index.js

The nice thing about this setup is that the build fails if eslint doesn’t pass, so I don’t spend time debugging or testing code that is bad in some way. This is mostly goodness, except for when I want to debug something using banned rules. A couple of classic examples are no-constant-condition and no-console. What I want is to be able to say: Have two configs: The main config, and then a few modifications for local development.

Currently, as far as I can tell, I have to have separate config files and pass them in the command line. This is sub-optimal because the rules are in different places and it is not easy to extend off a rule. As far as I know (I may be wrong), I have to essentially copy/paste the .eslintrc and then make the modifications I want for the dev version.

My proposal is to add conditional rules in the form of env:[your environment here]/[rule] For example, I would create this .eslintrc:

no-constant-condition: ["error"],
env:dev/no-constant-condition: ["warn"],

Which would allow me to place both variants side-by-side and then to trigger the code would be eslint --env dev which is easily configurable by build scripts.

I have a local modification to eslint which accomplishes this, and I am happy to drive the fix to mainline if folks like the proposal. This is my first time working with this project so I would appreciate patience and help getting it in.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:12 (10 by maintainers)

github_iconTop GitHub Comments

3reactions
ilyavolodincommented, Jun 18, 2016

@AnilRedshift you actually can extend from local files. And that’s what I would suggest to do. Create base config file, then create 2 config files per runtime environment and extend base in each one of those. Run ESLint with -c flag. Or just create a single config file and mark all of the rules that you don’t want to fail prod build as “warning” instead of “error”.

0reactions
albertocommented, Aug 26, 2016

Thanks for your interest in improving eslint. Unfortunately, it looks like consensus couldn’t be reached on this issue and so I’m closing it. While we wish we’d be able to accommodate everyone’s requests, we do need to prioritize. We’ve found that issues failing to reach consensus after 21 days tend never to reach consensus, and as such, we close those issues. This doesn’t mean the idea isn’t interesting, just that it’s not something the team can commit to.

Read more comments on GitHub >

github_iconTop Results From Across the Web

CSS Conditional Rules Module Level 5 - W3C
Usually, conditional group rules are independent; each one has a separate condition evaluated without direct reference to any other rule, and ...
Read more >
Conditional Rules - Knack Knowledge Base
Conditional rules can be used to automatically set the value of a field based on the rules, or conditions, that you define for...
Read more >
We are Not the Securities and Environment Commission
The proposal optimistically posits that mandatory disclosure of reams of climate information will ensure that all companies disclose comparable, ...
Read more >
Final Rule: 2013 Conditional Exclusions From Solid Waste ...
The purpose of this final rule is to provide a consistent regulatory framework for solvent-contaminated wipes that is appropriate to the level ...
Read more >
The Enhancement and Standardization of Climate-Related ...
A Proposed Rule by the Securities and Exchange Commission on 04/11/2022 ... climate disclosures based on a variety of different third-party ...
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