Skip to content

Commit cfaf58c

Browse files
committed
chore: simplify
1 parent 7584b10 commit cfaf58c

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/rules/no-export-load-in-svelte-module-in-kit-pages.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type * as ESTree from "estree"
22
import { createRule } from "../utils"
3-
import { isKitPageComponent, hasSvelteKit } from "../utils/svelte-kit"
3+
import { isKitPageComponent } from "../utils/svelte-kit"
44

55
export default createRule("no-export-load-in-svelte-module-in-kit-pages", {
66
meta: {
@@ -19,7 +19,7 @@ export default createRule("no-export-load-in-svelte-module-in-kit-pages", {
1919
type: "problem",
2020
},
2121
create(context) {
22-
if (!hasSvelteKit(context.getFilename()) || !isKitPageComponent(context)) {
22+
if (!isKitPageComponent(context)) {
2323
return {}
2424
}
2525
let isModule = false

src/utils/svelte-kit.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const isRunOnBrowser = !fs.readFileSync
1717
export function isKitPageComponent(context: RuleContext): boolean {
1818
// Hack: if it runs on browser, it regards as Svelte Kit project.
1919
if (isRunOnBrowser) return true
20-
20+
if (!hasSvelteKit(context.getFilename())) return false
2121
const routes =
2222
context.settings?.kit?.files?.routes?.replace(/^\//, "") ?? "src/routes"
2323
const filePath = context.getFilename()
@@ -33,7 +33,7 @@ export function isKitPageComponent(context: RuleContext): boolean {
3333
* @param filePath A file path.
3434
* @returns
3535
*/
36-
export function hasSvelteKit(filePath: string): boolean {
36+
function hasSvelteKit(filePath: string): boolean {
3737
// Hack: if it runs on browser, it regards as Svelte Kit project.
3838
if (isRunOnBrowser) return true
3939
try {

0 commit comments

Comments
 (0)