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

Breaking: support new syntax in Vue.js 2.6 #807

Merged
merged 11 commits into from Feb 27, 2019
Merged

Conversation

mysticatea
Copy link
Member

@mysticatea mysticatea commented Feb 7, 2019

This PR updates vue-eslint-parser to 6.0.0, contains Vue.js 2.6 support.

https://github.com/mysticatea/vue-eslint-parser/releases/tag/v6.0.0

This release contains drastic change about VDirectiveKey node to support dynamic argument syntax. Please see the release note.

This PR contains:

  • update package.json for vue-eslint-parser@^6.0.0.
  • update rules to pass tests.
  • add some tests about new syntax to check not to crash.

@ota-meshi
Copy link
Member

ota-meshi commented Feb 8, 2019

For example, if you do the following test with vue/array-bracket-spacing, an error reports because there is no space.

    {
      code: '<template><div :[[attr]]="a" /></template>',
      options: ['always']
    }

But reports is incorrect as spaces are not allowed in dynamic arguments.

Although this vue template is a useless, it seems to be valid as a template.

https://template-explorer.vuejs.org/#%3Cdiv%20%3A%5B%5Battr%5D%5D%3D%22a%22%20%2F%3E

I'd like to change the wrapCoreRule method to solve this issue as follows.

vue-eslint-parser/6.0.0...vue-eslint-parser/6.0.0-wrap-core

What do you think?

@mysticatea
Copy link
Member Author

Yeah, you are right. We must disable spacing rules in dynamic arguments. That skipDynamicArguments option is the same solution as I thought 😄

Would you push it into this branch?

@ota-meshi
Copy link
Member

@mysticatea Thank you for your comment.
I pushed this branch.

6037a9f

I will change other wrapper rules later.

- vue/block-spacing
- vue/brace-style
- vue/key-spacing
- vue/object-curly-spacing
- vue/space-infix-ops
- vue/space-unary-ops

Add testcases

- vue/array-bracket-spacing
- vue/comma-dangle
- vue/no-restricted-syntax
@ota-meshi
Copy link
Member

I changed other wrapper rules as well.

00f6db9

@mysticatea
Copy link
Member Author

Awesome, thank you!

- handle dynamic argument names
- handle v-slot directive
- support dynamic arguments
- supports autofix to make .prop shortohand to long-form.
@mysticatea mysticatea changed the title WIP: Update: support new syntax in Vue.js 2.6 Update: support new syntax in Vue.js 2.6 Feb 9, 2019
@mysticatea
Copy link
Member Author

OK, I think done. Please review, @michalsnik, @ota-meshi, @armano2.

Copy link
Member

@ota-meshi ota-meshi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@mysticatea
Copy link
Member Author

I'm sorry, please wait a bit. I found that I have overlooked about tests for references in dynamic arguments. (E.g. vue/no-unused-vars)

@mysticatea
Copy link
Member Author

I believe done this time.

Copy link
Collaborator

@armano2 armano2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mysticatea
Copy link
Member Author

I'm considering if we should mark this PR as a breaking change.

This PR will not break CI for people which use our presets such as vue/recommended.
However, if someone uses parser setting with their version of vue-eslint-parser, this change will break it because AST was massively changed.

@mysticatea mysticatea changed the title Update: support new syntax in Vue.js 2.6 Breaking: support new syntax in Vue.js 2.6 Feb 14, 2019
@mysticatea mysticatea merged commit 5d26e94 into master Feb 27, 2019
@mysticatea mysticatea deleted the vue-eslint-parser/6.0.0 branch February 27, 2019 18:15
LeSuisse added a commit to Enalean/tuleap that referenced this pull request Apr 19, 2019
v-html usages is replaced by a safer by default alternative.

The goals are multiple:
 * make it easier to do the right thing for the developers: besides
telling Vue to use the plugin at the instantiation of the app, the new directive
can be used directly. There is no need of defining a new computed properties to sanize
the value which means less boilerplate code.
* reduce the number of points to inspect: only the directive/plugin code (and potentially
a custom config at the init of the Vue app) instead of all the usages of v-html and the
computed props associated with them.

Note this does not means v-dompurify-html should be used everywhere, the usages
should be limited where there is a real need for it and no alternative (same as v-html).

No functionnal change is expected.

vue-eslint-parser has been rollbacked to version 5.x. The 6.x version is not yet compatible
with eslint-plugin-vue [0] causing false positives. It seems that major versions of
vue-eslint-parser and eslint-plugin-vue must be kept in sync.

[0] vuejs/eslint-plugin-vue#807

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

Successfully merging this pull request may close these issues.

None yet

3 participants