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

Chore: ts-parser support in demo #1972

Merged
merged 3 commits into from Sep 15, 2022
Merged

Chore: ts-parser support in demo #1972

merged 3 commits into from Sep 15, 2022

Conversation

ota-meshi
Copy link
Member

@ota-meshi ota-meshi commented Sep 15, 2022

This PR modifies the documentation site demo so that it parses well using typescript.

https://deploy-preview-1972--eslint-plugin-vue.netlify.app/rules/valid-define-emits.html
https://deploy-preview-1972--eslint-plugin-vue.netlify.app/rules/valid-define-props.html

We'll need to clear the cache in netlify for this to take effect.

Related to #1968 (comment)

Copy link
Member

@FloEdelmann FloEdelmann left a comment

Choose a reason for hiding this comment

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

Nice, this looks mostly good. I have just one suggestion.

Comment on lines 99 to 106
parser: this.typescript
? this.tsEslintParser
: this.langTs
? {
ts: this.tsEslintParser,
typescript: this.tsEslintParser
}
: null,
Copy link
Member

Choose a reason for hiding this comment

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

It's really hard to read this. Can we extract part of this to a separate variable to make it more readable? Or use if? Or configure Prettier to allow parentheses here?

Also, is the second check really needed? Or can we always set the TS parser for the ts and typescript blocks?

Copy link
Member Author

Choose a reason for hiding this comment

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

Thank you for review!
I would like to rewrite this and write comments.

this.typescript is intended to be used when using ts code blocks.
The this.langTs condition is used during <script lang="ts"> or <script lang="typescript">. <script lang="typescript"> is not currently used, but I think someone may PR a new rule to enforce it in the future.

.eslintrc.js Outdated
@@ -131,7 +131,8 @@ module.exports = {
'unicorn/no-useless-undefined': 'off',
'unicorn/prefer-optional-catch-binding': 'off', // not supported by current ESLint parser version
'unicorn/prefer-module': 'off',
'unicorn/prevent-abbreviations': 'off'
'unicorn/prevent-abbreviations': 'off',
'unicorn/no-nested-ternary': 'off' // conflicts with Prettier
Copy link
Member

Choose a reason for hiding this comment

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

But it makes the code more readable than Prettier 🙈

Copy link
Member

@FloEdelmann FloEdelmann left a comment

Choose a reason for hiding this comment

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

This is much better now. LGTM! :)

@ota-meshi ota-meshi merged commit faa067e into master Sep 15, 2022
@ota-meshi ota-meshi deleted the demo-with-ts branch September 15, 2022 10:00
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.

None yet

2 participants