Skip to content

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.

2 participants