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: add no-export-load-in-svelte-module-in-kit-pages #281

Conversation

baseballyama
Copy link
Member

resolve: #241

@changeset-bot
Copy link

changeset-bot bot commented Oct 29, 2022

🦋 Changeset detected

Latest commit: 7d870c0

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 29, 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.

package.json Outdated
@@ -174,7 +174,7 @@
"access": "public"
},
"typeCoverage": {
"atLeast": 98.71,
"atLeast": 98.7,
Copy link
Member Author

Choose a reason for hiding this comment

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

Due to package.json check, I couldn't find a way to cover the conditions.
So helplessly, I changed here.

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 it's a problem because I think it's a sufficient coverage rate.

@baseballyama baseballyama force-pushed the feature/no-export-load-in-svelte-module-in-kit-pages branch from ddc46a6 to 08fc369 Compare October 29, 2022 16:44
Comment on lines 5 to 18
const hasSvelteKit = (() => {
try {
const packageJson = JSON.parse(fs.readFileSync("./package.json", "utf8"))
// Hack: CI removes `@sveltejs/kit` and it returns false and test failed.
// So always it returns true if it runs on the package.
if (packageJson.name === "eslint-plugin-svelte") return true
return Boolean(
packageJson.dependencies["@sveltejs/kit"] ??
packageJson.devDependencies["@sveltejs/kit"],
)
} catch (_e) {
return false
}
})()
Copy link
Member Author

Choose a reason for hiding this comment

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

If a user doesn't use SvelteKit, I don't want to show an error, so I added to check package.json.
Is it the correct way?
And in the CI removes SvelteKit, so for the test, I added chack logic with packageJson.name
I think this is a bad idea but I don't have a better idea.

If correct, I will move it to utils for other SvelteKit-related rules.

Comment on lines +228 to +238
module.exports = {
// ...
settings: {
kit: {
files: {
routes: "src/routes",
},
},
},
// ...
}
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 choose that I added shared configuration for kit routes path.
I think over 95% of users use default settings src/routes.
So only a few users need to config it.

And for 5% users, we discussed that we will use espree but it may fail to get the path if they rely to env of some external information. So for now I didn't implement this logic.
#241 (comment)

src/rules/kit-helpers/kit-helpers.ts Outdated Show resolved Hide resolved
src/rules/no-export-load-in-svelte-module-in-kit-pages.ts Outdated Show resolved Hide resolved
src/rules/no-export-load-in-svelte-module-in-kit-pages.ts Outdated Show resolved Hide resolved
docs-svelte-kit/src/.eslintrc.js Outdated Show resolved Hide resolved
src/rules/no-export-load-in-svelte-module-in-kit-pages.ts Outdated Show resolved Hide resolved
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 for your wonderful work!

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