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

Add rule for prevent from printing undefined to HTML #807

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

DongwonTTuna
Copy link

@DongwonTTuna DongwonTTuna commented Jun 27, 2024

close: #747

Copy link

changeset-bot bot commented Jun 27, 2024

⚠️ No Changeset found

Latest commit: 067e90c

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@baseballyama baseballyama marked this pull request as draft June 27, 2024 12:52
Copy link
Member

@baseballyama baseballyama left a comment

Choose a reason for hiding this comment

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

Thank you for your PR!

But it seems to me that the rule cannot be made great without a check using types such as this comment. And I think we need to handle null also.

#747 (comment)

And there are several points that clearly need to be corrected.

Copy link
Member

Choose a reason for hiding this comment

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

I don't think we need this.

Comment on lines +17 to +33
This rule reports all uses of `{@html}` in order to reduce the risk of injecting potentially unsafe / unescaped html into the browser leading to Cross-Site Scripting (XSS) attacks.

<ESLintCodeBlock>

<!--eslint-skip-->

```svelte
<script>
/* eslint svelte/no-at-html-tags: "error" */
</script>

<!-- ✓ GOOD -->
{foo}

<!-- ✗ BAD -->
{@html foo}
```
Copy link
Member

Choose a reason for hiding this comment

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

Please write proper document.

meta: {
docs: {
description: 'Disallow from printing `undefined`',
category: 'Possible Errors',
Copy link
Member

Choose a reason for hiding this comment

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

I don't think printing undefined is possible error.

docs: {
description: 'Disallow from printing `undefined`',
category: 'Possible Errors',
recommended: true
Copy link
Member

Choose a reason for hiding this comment

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

Please do not add recommended rules without major version up.

Suggested change
recommended: true
recommended: false

pageClass: 'rule-details'
sidebarDepth: 0
title: 'svelte/no-undefined-print'
description: 'Disallow from printing `undefined`'
Copy link
Member

Choose a reason for hiding this comment

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

I think this is grammatically better?

Suggested change
description: 'Disallow from printing `undefined`'
description: 'Disallow printing `undefined`'

sidebarDepth: 0
title: 'svelte/no-undefined-print'
description: 'Disallow from printing `undefined`'
since: 'v0.0.1'
Copy link
Member

Choose a reason for hiding this comment

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

We can use pnpm update to update docs automatically.

},
schema: [],
messages: {
unexpected: 'Unexpected `undefined`.'
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
unexpected: 'Unexpected `undefined`.'
unexpected: 'Disallow printing `undefined`'

let string = `this string contains some <strong>HTML!!!</strong>`;
</script>

<p>{@html string}</p>
Copy link
Member

Choose a reason for hiding this comment

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

I think this test is not for this rule.

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.

New rule: no undefined variable in the DOM
2 participants