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

Custom environments in plugins #4782

Closed
nzakas opened this Issue Dec 21, 2015 · 2 comments

Comments

Projects
None yet
2 participants
@nzakas
Copy link
Member

nzakas commented Dec 21, 2015

We discussed having custom environments a while back, but we got stuck due to the relationship between rules and environments. (Environments used to be able to enable/disable rules.) Since environments now just apply globals and parser options, I'd like to revisit allowing custom environments from plugins. This would relieve some of the pressure we get to provide an environment for every possible library.

Defining

The idea is to export an environments property from plugins, just like we export rules:

// your plugin
module.exports = {
    rules: {},
    environments: {
        custom: {
            globals: { "$": true }
            parserOptions: { ecmaVersion: 6 }
        }
    }
};

Using

You'd use the same convention to load environments from plugins as you do for loading rules from plugins:

In config files:

plugins:
  - myplugin
env:
  es6: true
  myplugin/custom: true

In comments:

/* eslint-env myplugin/custom, es6*/
@ilyavolodin

This comment has been minimized.

Copy link
Member

ilyavolodin commented Dec 22, 2015

For references, here's a PR that was doing it originally: #2024 If I get time, I'll take a look at possibly rebasing it doing some minor modifications to account for updated code.

@nzakas

This comment has been minimized.

Copy link
Member Author

nzakas commented Jan 7, 2016

Working on this.

nzakas added a commit that referenced this issue Jan 13, 2016

nzakas added a commit that referenced this issue Jan 14, 2016

nzakas added a commit that referenced this issue Jan 14, 2016

nzakas added a commit that referenced this issue Jan 15, 2016

nzakas added a commit that referenced this issue Jan 15, 2016

nzakas added a commit that referenced this issue Jan 15, 2016

@nzakas nzakas closed this in b28a19d Jan 19, 2016

nzakas added a commit that referenced this issue Jan 19, 2016

Merge pull request #4955 from eslint/issue4782
Breaking: Plugins envs and config removal (fixes #4782, fixes #4952)

@eslint eslint bot locked and limited conversation to collaborators Feb 6, 2018

@eslint eslint bot added the archived due to age label Feb 6, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.