Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New: Adding support for custom environments (fixes #1130) #2024

Closed
wants to merge 1 commit into from

Conversation

ilyavolodin
Copy link
Member

Fixes #1130
This adds support for custom environments provided by plugins. All the same limitations as with custom rules apply here (See #2022). I also think that unit tests are probably lacking a bit right now. It should probably include at least a unit-test for changing rules from custom environment, however, it's pretty hard to test that, since when reset is true, rule configuration will be discarded, and when it's false, all of the rules from the default config are being pulled in.


Plugins can also provide custom environments. Custom environments can declare `globals`, turn `ecmaFeatures` on and off,
and configure both core rules as well as rules included in the plugin. To provide custom environment, include `environment`
property in your exported object.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about enabling other plugins?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Environments can't specify plugins, only globals, ecmaFeatures, and rules.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While you can't include plugins section, the thing that was bothering me, was that you can specify rules from another plugins. There's no validation currently anywhere in the code, to verify that rules inside environments don't include rules from some other plugin. I guess even if that happens, you are going to get a message about incorrect configuration of the rule, so not the end of the world.

@ilyavolodin
Copy link
Member Author

OK, I had a chance to go over the code in eslint.js to see how hard would it be to add support for inline config for environments from plugins, and it looks like there's some major re-factoring required to do that. All of the code that deals with config should be moved out from eslint.js, and there's a lot of it there. I don't really know when I'll have time to get to it, so for now I'll close this pull request and will reopen it when I will refactor all of the code.

@tommck
Copy link

tommck commented Apr 10, 2015

oh, man.. I was hoping we'd get something like this in here for something like adding an "angular-mocks" environment so I don't have to have this in all my tests:

/*eslint-env jasmine */
/*global inject, module */

I could just have

/*eslint-env jasmine, angular-mocks */

@ilyavolodin
Copy link
Member Author

We will. Eventually:-) Just don't really have time or energy to refactor the whole eslint.js file right now.

@tommck
Copy link

tommck commented Apr 10, 2015

I understand :)

I haven't looked at the code yet, but it sounds like a lot of work.

@ilyavolodin ilyavolodin deleted the plugin-environments branch October 28, 2015 22:00
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Feb 7, 2018
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Feb 7, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow the user to specify custom environments
4 participants