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

Allow configuration of parser #1624

Closed
nzakas opened this issue Jan 4, 2015 · 5 comments

Comments

Projects
None yet
3 participants
@nzakas
Copy link
Member

commented Jan 4, 2015

Many Esprima-based tools allow the end-user to specify an alternate parser to use (so long as they are Esprima compatible). We should do the same for ESLint. This would allow, for example, someone to specify to use Esprima-FB instead of Espree.

I'm unsure the best way to do this currently. My first thought was to have a --parser flag on the command line, but that would require someone getting that info into the eslint object, which isn't supposed to know about the command line. The other thought was to put it in settings, such as:

{
  "settings": {
    "parser": "esprima-fb"
  }
}

At the moment, I'm leaning towards the settings approach, since it would also allow rules to determine if the regular parser was being used or not.

@btmills

This comment has been minimized.

Copy link
Member

commented Jan 4, 2015

Since both this and #1602 deal with the parser and its options, it seems it would make sense to come up with something that might keep these together. Just some ideas:

{
  "settings": {

    // Custom parser with default options
    "parser": "esprima-fb",

    // Default parser with custom options
    "parser": {
      "ecmaFeatures": {
        "generators": true,
        "jsx": true
      }
    },

    // Custom parser with custom options
    "parser": {
      "module": "acorn",
      "options": {
        "ecmaVersion": 6
      }
    }

  }
}
@nzakas

This comment has been minimized.

Copy link
Member Author

commented Jan 5, 2015

I'm not sure it makes sense to combine these, as I'd prefer people think about configuring ESLint with certain features rather than configuring the underlying parser directly, nor am I sure I want to allow people to configure an external parser. This is a dicey feature as it is, so I'd like to keep it as simple as possible.

@yannickcr

This comment has been minimized.

Copy link
Contributor

commented Jan 6, 2015

I opened a related issue in JSCS jscs-dev/node-jscs#865 that allows us to use a custom parser but not to configure it which is very limiting.

@nzakas

This comment has been minimized.

Copy link
Member Author

commented Jan 6, 2015

Configuring is more complex and we don't have any use cases for that right now. We do have a request to allow the usage of esprima-fb directly, and that's what I'd like to support.

@nzakas

This comment has been minimized.

Copy link
Member Author

commented Feb 7, 2015

Working on this.

@nzakas nzakas closed this in 4f4a7ea Feb 7, 2015

nzakas added a commit that referenced this issue Feb 7, 2015

Merge pull request #1781 from eslint/issue1624
New: Allow parser to be configured (fixes #1624)

Holixus pushed a commit to Holixus/eslint that referenced this issue Feb 12, 2015

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

@eslint eslint bot added the archived due to age label Feb 7, 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.