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

feat: no-not-data-props-in-kit-pages #283

Merged

Conversation

baseballyama
Copy link
Member

@baseballyama baseballyama commented Oct 30, 2022

resolve: #241

This is based on #281.
So At first, we should merge #281.

@changeset-bot
Copy link

changeset-bot bot commented Oct 30, 2022

🦋 Changeset detected

Latest commit: cde30a5

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
eslint-plugin-svelte Minor

Not sure what this means? Click here to learn what changesets are.

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

@codesandbox-ci
Copy link

codesandbox-ci bot commented Oct 30, 2022

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

@baseballyama baseballyama force-pushed the feat/no-not-data-props-in-kit-pages branch 2 times, most recently from cfde211 to a65362a Compare October 30, 2022 06:45
@baseballyama baseballyama force-pushed the feat/no-not-data-props-in-kit-pages branch from a65362a to 7a41b55 Compare November 1, 2022 03:25
@baseballyama baseballyama changed the title [wip] feat: no-not-data-props-in-kit-pages feat: no-not-data-props-in-kit-pages Nov 1, 2022
@baseballyama baseballyama marked this pull request as ready for review November 1, 2022 03:35
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.

Thank you for this PR!
I made some comments.

},

// export let xxx
[`ExportNamedDeclaration > VariableDeclaration > VariableDeclarator > Identifier`]:
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 it's not enough to just check the Identifier.

export let {a, b} = obj

I think it's better to select a VariableDeclarator and report an node.id other than Identifire, or something other than data or error.

"ExportNamedDeclaration > VariableDeclaration > VariableDeclarator"

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh export let { data, errors } = { data: {}, errors: {} } is correct way.

https://svelte.dev/repl/61922177a5944a5294e9551787479d6a?version=3.52.0

I updated the logic, so could you please review it again?

type: "problem",
},
create(context) {
if (!isKitPageComponent(context)) return {}
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 isKitPageComponent needs to be changed to be more strict.
I think we need to check if the file name starts with +.
For filenames that don't start with +, it may just be a component.

Copy link
Member Author

Choose a reason for hiding this comment

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

I added check logic and fixed tests.

@@ -0,0 +1,6 @@
<script>
export let data
export let 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 saw this and noticed that errors is also allowed.
So I think it would be better to change the rule name (no-not-data-props-in-kit-pages) from what I suggested 😓.

Do you have any good ideas?
For example, how about a name like valid-prop-names-in-kit-pages?

Copy link
Member Author

Choose a reason for hiding this comment

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

I changed the rule name according to your suggestion!

@ota-meshi
Copy link
Member

I'm sorry, could you change the namespace of settings? #290

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! Thank you!

@ota-meshi ota-meshi merged commit 909979e into sveltejs:main Nov 2, 2022
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.

Add rules to help migrate Svelte Kit (v1.0.0-next.405)
2 participants