Skip to content

Add support for parser object to parserOptions.parser #196

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

Merged
merged 2 commits into from
Aug 12, 2022
Merged

Conversation

ota-meshi
Copy link
Member

This PR changes parserOptions.parser to allow you to directly specify a parser object.

The new usage is described in the README.

Parser Object

When using JavaScript configuration (.eslintrc.js), you can also give the parser object directly.

const tsParser = require("@typescript-eslint/parser")
const espree = require("espree")
module.exports = {
    parser: "svelte-eslint-parser",
    parserOptions: {
        // Single parser
        parser: tsParser,
        // Multiple parser
        parser: {
            js: espree,
            ts: tsParser,
        }
    },
}

As background, ESLint core is planning a new flat configuration.
https://eslint.org/blog/2022/08/new-config-system-part-1/

The new configuration allows you to specify parser objects directly.
https://eslint.org/blog/2022/08/new-config-system-part-2/#custom-parsers-and-parser-options-are-mostly-the-same

For this reason, there is a possibility that parsers that do not assume module name specification as before will appear.
The changes in this PR are intended to follow the new parser specification method.

However, you cannot use the custom parser provided by the plugin by name. Because the plugin configuration is not accessible from the parser options.
https://eslint.org/blog/2022/08/new-config-system-part-2/#custom-parsers-in-plugins

@ota-meshi ota-meshi merged commit 10e28ba into main Aug 12, 2022
@ota-meshi ota-meshi deleted the parser-object branch August 12, 2022 00:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant