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

Stage 4 syntaxes in core rules #7101

Closed
12 tasks done
mysticatea opened this issue Sep 10, 2016 · 15 comments
Closed
12 tasks done

Stage 4 syntaxes in core rules #7101

mysticatea opened this issue Sep 10, 2016 · 15 comments
Assignees
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly enhancement This change enhances an existing feature of ESLint new syntax This issue is related to new syntax that has reached stage 4 rule Relates to ESLint's core rules

Comments

@mysticatea
Copy link
Member

mysticatea commented Sep 10, 2016

acorn, the base of espree, has supported async/await and trailing function commas: Acorn 4.0.0
espree is going to support those, coming soon: eslint/espree#287

Then, I'm starting to modify core rules to support those.
In my head, the following rules need some tweaks.

Changelog:

  • space-before-function-paren was added.
  • space-unary-ops was added.
  • Sorted by priority.
  • generator-star-spacing was added.
@mysticatea mysticatea added enhancement This change enhances an existing feature of ESLint rule Relates to ESLint's core rules evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion labels Sep 10, 2016
@mysticatea mysticatea self-assigned this Sep 10, 2016
@mysticatea mysticatea added the bug ESLint is working incorrectly label Sep 10, 2016
@hzoo
Copy link
Member

hzoo commented Sep 10, 2016

maybe generator-star-spacing? https://github.com/babel/eslint-plugin-babel has an override for that

@mysticatea
Copy link
Member Author

generator-star-spacing should work for async functions since node.generator of async functions is false.

@hzoo
Copy link
Member

hzoo commented Sep 10, 2016

Oh right, it was probably one of the rules you already mentioned then. Still need to fix it in babel-eslint. My mistake

@mysticatea
Copy link
Member Author

Hmm. I have a question:

async () => 0
//   │
//   └ Should this space be warned by which rule?
//
// 1. keyword-spacing
// 2. space-before-function-paren
//
// By the way,
(function () {})
//       │
//       └ This space is warned by space-before-function-paren

I guess space-before-function-paren is it.

@platinumazure
Copy link
Member

@mysticatea Is async function foo() {} valid syntax? If so I would rather have keyword-spacing cover both cases. But I can see arguments for either way!

@mysticatea
Copy link
Member Author

Yes, async function foo() {} is valid. But we cannot remove the space between async and function, so keyword-spacing rule ignores it.

@kaicataldo
Copy link
Member

I think this should be warned by keyword-spacing. Given the intent of space-before-function-paren, my preference would be to maintain not checking ArrowFunctionExpressions in that rule. To me, it makes more sense for the checks to not care about whether the token following the async keyword is a FunctionDeclaration, FunctionExpression, or ArrowFunctionExpression, but rather for the checks to focus on spacing around the keyword itself. It also avoids having to configure in two places would arguably should be one configuration.

For context, in my ideal world, I think space-before-function-paren would actually only warn on named functions, leaving anonymous function spacing to keyword-spacing.

@mysticatea
Copy link
Member Author

For context, in my ideal world, I think space-before-function-paren would actually only warn on named functions, leaving anonymous function spacing to keyword-spacing.

I agree! In the ideal world, definitely keyword-spacing should warn the space.
But in this world, I have the concern that the priority of spacing rules is confusing: a mix of keyword-spacing > space-before-function-paren or keyword-spacing < space-before-function-paren.

keyword-spacing space-before-function-paren
Pros don't need to modify space-before-function-paren. the priority of spacing rules is consistent: keyword-spacing < space-before-function-paren
Cons keyword-spacing > space-before-function-paren in arrow but keyword-spacing < space-before-function-paren in others. needs new option asyncArrow for space-before-function-paren

@not-an-aardvark
Copy link
Member

It looks like a new version of espree just came out with acorn 4.0.0, so our tests are now failing on master (example).

@ilyavolodin
Copy link
Member

Umm.. That's not good. That shouldn't be happening, since we haven't enabled ES2018 anywhere yet. I'll open a new issue for this.

@not-an-aardvark
Copy link
Member

not-an-aardvark commented Sep 16, 2016

I've been working on a few of the issues on this list; see #7172, #7173, #7174, #7175, #7176.

@mysticatea
Copy link
Member Author

Oh, I have been late for the party. Thank you, @not-an-aardvark .
(often releases are done in midnight in my timezone.)

@mysticatea
Copy link
Member Author

Filled all items with PRs.

@Gawdl3y
Copy link

Gawdl3y commented Oct 5, 2016

I created #7307, which is a problem with the valid-jsdoc rule on async functions that I don't believe is mentioned here.

@nzakas nzakas added accepted There is consensus among the team that this change meets the criteria for inclusion and removed evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion labels Oct 5, 2016
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Feb 6, 2018
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Feb 6, 2018
@mysticatea mysticatea added the new syntax This issue is related to new syntax that has reached stage 4 label Dec 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly enhancement This change enhances an existing feature of ESLint new syntax This issue is related to new syntax that has reached stage 4 rule Relates to ESLint's core rules
Projects
None yet
Development

No branches or pull requests

8 participants