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

Proposal: errors option #368

Open
mysticatea opened this issue Feb 14, 2018 · 5 comments
Open

Proposal: errors option #368

mysticatea opened this issue Feb 14, 2018 · 5 comments

Comments

@mysticatea
Copy link
Member

Purpose: There are recoverable errors in syntax error, e.g. duplicate names, invalid escapes in RegExp, and etc. ESLint stops all linting if it encountered those recoverable errors. However, ESLint should be able to work.

Proposal: Adds errors option to espree.

const ast = espree.parse(code, { errors: true })
console.log(ast.errors) //→ Array of recoverable errors.

acorn reports errors by this.raiseRecoverable() method if the error is recoverable. If the errors:true option is given, espree collects recoverable errors into ast.errors property instead of throwing exception.

Then ESLint can report the ast.errors to users.

@not-an-aardvark
Copy link
Member

I'm a bit concerned that this would make it more difficult to write rules, because the rules would need to have a reasonable behavior for impossible ASTs. (For example, this could create other issues like eslint/eslint#7712.)

@mysticatea
Copy link
Member Author

Yes, you are right.
Using this errors option will be a breaking change for ESLint. I will make a PR to update core rules if this is accepted.

@platinumazure
Copy link
Member

@not-an-aardvark Is that necessarily the case? Could we instead augment parseForESLint to support an AST errors property, and just report errors without linting if errors are present?

@not-an-aardvark
Copy link
Member

not-an-aardvark commented Feb 24, 2018

We could do that. I was under the impression that the goal was to be able to run rules when there are non-fatal errors.

@platinumazure
Copy link
Member

platinumazure commented Feb 24, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants