Skip to content

Commit b52507d

Browse files
committed
fix site
1 parent 079f6f2 commit b52507d

File tree

9 files changed

+141
-101
lines changed

9 files changed

+141
-101
lines changed

README.md

+33-33
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
`@ota-meshi/eslint-plugin-svelte` is ESLint plugin for Svelte.
44
It provides many unique check rules by using the template AST.
5-
You can check on the [Online DEMO](https://ota-meshi.github.io/eslint-plugin-svelte/playground).
5+
You can check on the [Online DEMO](https://ota-meshi.github.io/eslint-plugin-svelte/playground/).
66

77
::: **_WORKS IN PROGRESS_** :::
88

@@ -85,7 +85,7 @@ This plugin provides configs:
8585
- `plugin:@ota-meshi/svelte/base` ... Configuration to enable correct Svelte parsing.
8686
- `plugin:@ota-meshi/svelte/recommended` ... Above, plus rules to prevent errors or unintended behavior.
8787

88-
See [the rule list](https://ota-meshi.github.io/eslint-plugin-svelte/rules) to get the `rules` that this plugin provides.
88+
See [the rule list](https://ota-meshi.github.io/eslint-plugin-svelte/rules/) to get the `rules` that this plugin provides.
8989

9090
::: warning ❗ Attention
9191

@@ -245,64 +245,64 @@ The rules with the following star :star: are included in the configs.
245245

246246
These rules relate to possible syntax or logic errors in Svelte code:
247247

248-
| Rule ID | Description | |
249-
|:--------|:------------|:---|
250-
| [@ota-meshi/svelte/no-dupe-else-if-blocks](https://ota-meshi.github.io/eslint-plugin-svelte/rules/no-dupe-else-if-blocks) | disallow duplicate conditions in `{#if}` / `{:else if}` chains | :star: |
251-
| [@ota-meshi/svelte/no-dynamic-slot-name](https://ota-meshi.github.io/eslint-plugin-svelte/rules/no-dynamic-slot-name) | disallow dynamic slot name | :star::wrench: |
252-
| [@ota-meshi/svelte/no-not-function-handler](https://ota-meshi.github.io/eslint-plugin-svelte/rules/no-not-function-handler) | disallow use of not function in event handler | :star: |
253-
| [@ota-meshi/svelte/no-object-in-text-mustaches](https://ota-meshi.github.io/eslint-plugin-svelte/rules/no-object-in-text-mustaches) | disallow objects in text mustache interpolation | :star: |
254-
| [@ota-meshi/svelte/valid-compile](https://ota-meshi.github.io/eslint-plugin-svelte/rules/valid-compile) | disallow warnings when compiling. | :star: |
248+
| Rule ID | Description | |
249+
| :---------------------------------------------------------------------------------------------------------------------------------- | :------------------------------------------------------------- | :------------- |
250+
| [@ota-meshi/svelte/no-dupe-else-if-blocks](https://ota-meshi.github.io/eslint-plugin-svelte/rules/no-dupe-else-if-blocks) | disallow duplicate conditions in `{#if}` / `{:else if}` chains | :star: |
251+
| [@ota-meshi/svelte/no-dynamic-slot-name](https://ota-meshi.github.io/eslint-plugin-svelte/rules/no-dynamic-slot-name) | disallow dynamic slot name | :star::wrench: |
252+
| [@ota-meshi/svelte/no-not-function-handler](https://ota-meshi.github.io/eslint-plugin-svelte/rules/no-not-function-handler) | disallow use of not function in event handler | :star: |
253+
| [@ota-meshi/svelte/no-object-in-text-mustaches](https://ota-meshi.github.io/eslint-plugin-svelte/rules/no-object-in-text-mustaches) | disallow objects in text mustache interpolation | :star: |
254+
| [@ota-meshi/svelte/valid-compile](https://ota-meshi.github.io/eslint-plugin-svelte/rules/valid-compile) | disallow warnings when compiling. | :star: |
255255

256256
## Security Vulnerability
257257

258258
These rules relate to security vulnerabilities in Svelte code:
259259

260-
| Rule ID | Description | |
261-
|:--------|:------------|:---|
262-
| [@ota-meshi/svelte/no-at-html-tags](https://ota-meshi.github.io/eslint-plugin-svelte/rules/no-at-html-tags) | disallow use of `{@html}` to prevent XSS attack | :star: |
263-
| [@ota-meshi/svelte/no-target-blank](https://ota-meshi.github.io/eslint-plugin-svelte/rules/no-target-blank) | disallow `target="_blank"` attribute without `rel="noopener noreferrer"` | |
260+
| Rule ID | Description | |
261+
| :---------------------------------------------------------------------------------------------------------- | :----------------------------------------------------------------------- | :----- |
262+
| [@ota-meshi/svelte/no-at-html-tags](https://ota-meshi.github.io/eslint-plugin-svelte/rules/no-at-html-tags) | disallow use of `{@html}` to prevent XSS attack | :star: |
263+
| [@ota-meshi/svelte/no-target-blank](https://ota-meshi.github.io/eslint-plugin-svelte/rules/no-target-blank) | disallow `target="_blank"` attribute without `rel="noopener noreferrer"` | |
264264

265265
## Best Practices
266266

267267
These rules relate to better ways of doing things to help you avoid problems:
268268

269-
| Rule ID | Description | |
270-
|:--------|:------------|:---|
271-
| [@ota-meshi/svelte/button-has-type](https://ota-meshi.github.io/eslint-plugin-svelte/rules/button-has-type) | disallow usage of button without an explicit type attribute | |
272-
| [@ota-meshi/svelte/no-at-debug-tags](https://ota-meshi.github.io/eslint-plugin-svelte/rules/no-at-debug-tags) | disallow the use of `{@debug}` | :star: |
273-
| [@ota-meshi/svelte/no-useless-mustaches](https://ota-meshi.github.io/eslint-plugin-svelte/rules/no-useless-mustaches) | disallow unnecessary mustache interpolations | :wrench: |
269+
| Rule ID | Description | |
270+
| :-------------------------------------------------------------------------------------------------------------------- | :---------------------------------------------------------- | :------- |
271+
| [@ota-meshi/svelte/button-has-type](https://ota-meshi.github.io/eslint-plugin-svelte/rules/button-has-type) | disallow usage of button without an explicit type attribute | |
272+
| [@ota-meshi/svelte/no-at-debug-tags](https://ota-meshi.github.io/eslint-plugin-svelte/rules/no-at-debug-tags) | disallow the use of `{@debug}` | :star: |
273+
| [@ota-meshi/svelte/no-useless-mustaches](https://ota-meshi.github.io/eslint-plugin-svelte/rules/no-useless-mustaches) | disallow unnecessary mustache interpolations | :wrench: |
274274

275275
## Stylistic Issues
276276

277277
These rules relate to style guidelines, and are therefore quite subjective:
278278

279-
| Rule ID | Description | |
280-
|:--------|:------------|:---|
281-
| [@ota-meshi/svelte/first-attribute-linebreak](https://ota-meshi.github.io/eslint-plugin-svelte/rules/first-attribute-linebreak) | enforce the location of first attribute | :wrench: |
282-
| [@ota-meshi/svelte/html-quotes](https://ota-meshi.github.io/eslint-plugin-svelte/rules/html-quotes) | enforce quotes style of HTML attributes | :wrench: |
283-
| [@ota-meshi/svelte/indent](https://ota-meshi.github.io/eslint-plugin-svelte/rules/indent) | enforce consistent indentation | :wrench: |
284-
| [@ota-meshi/svelte/max-attributes-per-line](https://ota-meshi.github.io/eslint-plugin-svelte/rules/max-attributes-per-line) | enforce the maximum number of attributes per line | :wrench: |
285-
| [@ota-meshi/svelte/mustache-spacing](https://ota-meshi.github.io/eslint-plugin-svelte/rules/mustache-spacing) | enforce unified spacing in mustache | :wrench: |
286-
| [@ota-meshi/svelte/prefer-class-directive](https://ota-meshi.github.io/eslint-plugin-svelte/rules/prefer-class-directive) | require class directives instead of ternary expressions | :wrench: |
287-
| [@ota-meshi/svelte/shorthand-attribute](https://ota-meshi.github.io/eslint-plugin-svelte/rules/shorthand-attribute) | enforce use of shorthand syntax in attribute | :wrench: |
288-
| [@ota-meshi/svelte/spaced-html-comment](https://ota-meshi.github.io/eslint-plugin-svelte/rules/spaced-html-comment) | enforce consistent spacing after the `<!--` and before the `-->` in a HTML comment | :wrench: |
279+
| Rule ID | Description | |
280+
| :------------------------------------------------------------------------------------------------------------------------------ | :--------------------------------------------------------------------------------- | :------- |
281+
| [@ota-meshi/svelte/first-attribute-linebreak](https://ota-meshi.github.io/eslint-plugin-svelte/rules/first-attribute-linebreak) | enforce the location of first attribute | :wrench: |
282+
| [@ota-meshi/svelte/html-quotes](https://ota-meshi.github.io/eslint-plugin-svelte/rules/html-quotes) | enforce quotes style of HTML attributes | :wrench: |
283+
| [@ota-meshi/svelte/indent](https://ota-meshi.github.io/eslint-plugin-svelte/rules/indent) | enforce consistent indentation | :wrench: |
284+
| [@ota-meshi/svelte/max-attributes-per-line](https://ota-meshi.github.io/eslint-plugin-svelte/rules/max-attributes-per-line) | enforce the maximum number of attributes per line | :wrench: |
285+
| [@ota-meshi/svelte/mustache-spacing](https://ota-meshi.github.io/eslint-plugin-svelte/rules/mustache-spacing) | enforce unified spacing in mustache | :wrench: |
286+
| [@ota-meshi/svelte/prefer-class-directive](https://ota-meshi.github.io/eslint-plugin-svelte/rules/prefer-class-directive) | require class directives instead of ternary expressions | :wrench: |
287+
| [@ota-meshi/svelte/shorthand-attribute](https://ota-meshi.github.io/eslint-plugin-svelte/rules/shorthand-attribute) | enforce use of shorthand syntax in attribute | :wrench: |
288+
| [@ota-meshi/svelte/spaced-html-comment](https://ota-meshi.github.io/eslint-plugin-svelte/rules/spaced-html-comment) | enforce consistent spacing after the `<!--` and before the `-->` in a HTML comment | :wrench: |
289289

290290
## Extension Rules
291291

292292
These rules extend the rules provided by ESLint itself to work well in Svelte:
293293

294-
| Rule ID | Description | |
295-
|:--------|:------------|:---|
294+
| Rule ID | Description | |
295+
| :---------------------------------------------------------------------------------------------------------------------- | :------------------------------------------------------------ | :----- |
296296
| [@ota-meshi/svelte/no-inner-declarations](https://ota-meshi.github.io/eslint-plugin-svelte/rules/no-inner-declarations) | disallow variable or `function` declarations in nested blocks | :star: |
297297

298298
## System
299299

300300
These rules relate to this plugin works:
301301

302-
| Rule ID | Description | |
303-
|:--------|:------------|:---|
302+
| Rule ID | Description | |
303+
| :-------------------------------------------------------------------------------------------------------------- | :------------------------------------------ | :----- |
304304
| [@ota-meshi/svelte/comment-directive](https://ota-meshi.github.io/eslint-plugin-svelte/rules/comment-directive) | support comment-directives in HTML template | :star: |
305-
| [@ota-meshi/svelte/system](https://ota-meshi.github.io/eslint-plugin-svelte/rules/system) | system rule for working this plugin | :star: |
305+
| [@ota-meshi/svelte/system](https://ota-meshi.github.io/eslint-plugin-svelte/rules/system) | system rule for working this plugin | :star: |
306306

307307
<!--RULES_TABLE_END-->
308308
<!--RULES_SECTION_END-->

docs-svelte-kit/src/lib/header/Header.svelte

+46-39
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,14 @@
4040
<li class:active={isActive("/", $page)}>
4141
<a sveltekit:prefetch href="{baseUrl}/">Home</a>
4242
</li>
43-
<li class:active={isActive("/user-guide", $page)}>
44-
<a sveltekit:prefetch href="{baseUrl}/user-guide">User Guide</a>
43+
<li class:active={isActive("/user-guide/", $page)}>
44+
<a sveltekit:prefetch href="{baseUrl}/user-guide/">User Guide</a>
4545
</li>
46-
<li class:active={isActive("/rules", $page)}>
47-
<a sveltekit:prefetch href="{baseUrl}/rules">Rules</a>
46+
<li class:active={isActive("/rules/", $page)}>
47+
<a sveltekit:prefetch href="{baseUrl}/rules/">Rules</a>
4848
</li>
49-
<li class:active={isActive("/playground", $page)}>
50-
<a sveltekit:prefetch href="{baseUrl}/playground">Playground</a>
49+
<li class:active={isActive("/playground/", $page)}>
50+
<a sveltekit:prefetch href="{baseUrl}/playground/">Playground</a>
5151
</li>
5252
</ul>
5353
<div class="nav-title">
@@ -106,37 +106,6 @@
106106
height: 100%;
107107
}
108108
109-
.sidebar-button,
110-
.nav-title {
111-
display: none;
112-
}
113-
@media (max-width: 719px) {
114-
.sidebar-button {
115-
display: flex;
116-
}
117-
.corner .home-link {
118-
display: none;
119-
}
120-
.nav-title {
121-
display: flex;
122-
background: var(--background-without-opacity);
123-
max-width: calc(100vw - 170px);
124-
}
125-
.nav-title a {
126-
height: 3rem;
127-
object-fit: contain;
128-
font-size: 0.5rem;
129-
}
130-
.nav-title img {
131-
width: 2rem;
132-
height: 2rem;
133-
object-fit: contain;
134-
}
135-
nav ul {
136-
display: none;
137-
}
138-
}
139-
140109
.corner img {
141110
width: 2em;
142111
height: 2em;
@@ -214,8 +183,7 @@
214183
color: var(--accent-color);
215184
}
216185
217-
.home-link,
218-
.sidebar-button {
186+
.home-link {
219187
background: var(--background-without-opacity);
220188
border-bottom-right-radius: 20%;
221189
}
@@ -224,4 +192,43 @@
224192
background: var(--background-without-opacity);
225193
border-bottom-left-radius: 20%;
226194
}
195+
196+
.sidebar-button {
197+
background: var(--background-without-opacity);
198+
}
199+
.sidebar-button,
200+
.nav-title {
201+
display: none;
202+
}
203+
@media (max-width: 719px) {
204+
.sidebar-button {
205+
display: flex;
206+
}
207+
.corner .home-link {
208+
display: none;
209+
}
210+
.nav-title {
211+
display: flex;
212+
justify-content: center;
213+
background: var(--background-without-opacity);
214+
width: calc(100vw - 96px);
215+
}
216+
.nav-title a {
217+
height: 3rem;
218+
object-fit: contain;
219+
font-size: 0.5rem;
220+
}
221+
.nav-title img {
222+
width: 2rem;
223+
height: 2rem;
224+
object-fit: contain;
225+
}
226+
nav ul,
227+
nav svg {
228+
display: none;
229+
}
230+
.github-link {
231+
border-bottom-left-radius: 0;
232+
}
233+
}
227234
</style>

docs-svelte-kit/src/lib/markdown/Markdown.svelte

+7-1
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,19 @@
1313
function handleToggleSidebar() {
1414
sidebarOpen = !sidebarOpen
1515
}
16+
function clickHandler() {
17+
sidebarOpen = false
18+
}
1619
</script>
1720

1821
<Header on:toggle-sidebar-open={handleToggleSidebar} />
1922

2023
<SideMenu {sidebarOpen} hiddenMenu={frontmatter.hiddenMenu} />
2124

22-
<main class:hidden-menu={frontmatter.hiddenMenu}>
25+
<main
26+
class:hidden-menu={frontmatter.hiddenMenu}
27+
on:click={sidebarOpen ? clickHandler : null}
28+
>
2329
<div class="main-content">
2430
<slot />
2531
</div>

docs-svelte-kit/src/lib/utils.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -28,27 +28,27 @@ const categoryRules = categories.map((cat) => {
2828
.map((rule) => {
2929
return {
3030
title: rule.meta.docs.ruleId,
31-
path: `/rules/${rule.meta.docs.ruleName}`,
31+
path: `/rules/${rule.meta.docs.ruleName}/`,
3232
}
3333
}),
3434
}
3535
})
3636
const SIDE_MENU = {
3737
"/rules": [
3838
{ path: "/", title: "Introduction" },
39-
{ path: "/user-guide", title: "User Guide" },
39+
{ path: "/user-guide/", title: "User Guide" },
4040
{
41-
path: "/rules",
41+
path: "/rules/",
4242
title: "Available Rules",
4343
children: categoryRules,
4444
},
45-
{ path: "/playground", title: "Playground" },
45+
{ path: "/playground/", title: "Playground" },
4646
],
4747
"/": [
4848
{ path: "/", title: "Introduction" },
49-
{ path: "/user-guide", title: "User Guide" },
50-
{ path: "/rules", title: "Available Rules" },
51-
{ path: "/playground", title: "Playground" },
49+
{ path: "/user-guide/", title: "User Guide" },
50+
{ path: "/rules/", title: "Available Rules" },
51+
{ path: "/playground/", title: "Playground" },
5252
],
5353
}
5454

docs-svelte-kit/tools/markdown-it-replace-link.mjs

+27-15
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,31 @@
55
// 2. converting internal links to remove .md
66
import path from "path"
77

8-
export default (md) => {
8+
export default (md, options = {}) => {
9+
const base = options.baseUrl
10+
const root = path.resolve(options.root)
11+
12+
/** Normalize href */
13+
function normalizeHref(curr, href) {
14+
let absolutePath
15+
let hash = ""
16+
if (/\.md(?:#.*)?$/.test(href)) {
17+
hash = /\.md(#.*)?$/.exec(href)[1] || ""
18+
absolutePath = path.join(
19+
path.dirname(curr),
20+
hash ? href.slice(0, -hash.length) : href,
21+
)
22+
} else {
23+
// hash only
24+
absolutePath = curr
25+
hash = href
26+
}
27+
28+
return `${base}/${path
29+
.relative(root, absolutePath)
30+
.replace(/\.md$/, "")}/${hash}`.replace(/\\/gu, "/")
31+
}
32+
933
md.renderer.rules.link_open = (tokens, idx, options, env, self) => {
1034
const token = tokens[idx]
1135
const hrefIndex = token.attrIndex("href")
@@ -18,24 +42,12 @@ export default (md) => {
1842
attrs: [...token.attrs, ["target", "_blank"]],
1943
}
2044
return self.renderToken([proxyToken], 0, options)
21-
} else if (/\.md(?:#.*)?$/.test(href)) {
22-
const proxyToken = {
23-
...token,
24-
attrs: [
25-
...token.attrs.slice(0, hrefIndex - 1),
26-
[link[0], href.replace(/\.md$/, "").replace(/\.md(#.*)$/, `$1`)],
27-
...token.attrs.slice(hrefIndex + 1),
28-
],
29-
}
30-
return self.renderToken([proxyToken], 0, options)
31-
} else if (/^#.*$/.test(href)) {
32-
// Avoid build error
33-
const name = path.basename(env.id).replace(/\.md$/, "")
45+
} else if (/\.md(?:#.*)?$/.test(href) || /^#.*$/.test(href)) {
3446
const proxyToken = {
3547
...token,
3648
attrs: [
3749
...token.attrs.slice(0, hrefIndex - 1),
38-
[link[0], name + href],
50+
[link[0], normalizeHref(env.id, href)],
3951
...token.attrs.slice(hrefIndex + 1),
4052
],
4153
}

docs-svelte-kit/tools/vite-plugin-svelte-md-option.mjs

+9-3
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,19 @@ import markdownPlugin from "./markdown-it-markdown.mjs"
99
import containerPluginOption from "./markdown-it-container-option.mjs"
1010
import slugify from "@sindresorhus/slugify"
1111

12-
export default {
12+
export default (options = {}) => ({
1313
wrapperClasses: [],
1414
markdownItOptions: {
1515
highlight,
1616
},
1717
markdownItUses: [
18-
replaceLinkPlugin,
18+
[
19+
replaceLinkPlugin,
20+
{
21+
baseUrl: options.baseUrl,
22+
root: options.root,
23+
},
24+
],
1925
emojiPlugin,
2026
[
2127
anchorPlugin,
@@ -34,4 +40,4 @@ export default {
3440
[containerPlugin, "danger", containerPluginOption("danger", "warning")],
3541
[containerPlugin, "details", containerPluginOption("details")],
3642
],
37-
}
43+
})

src/utils/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export function createRule(
1414
...rule.meta,
1515
docs: {
1616
...rule.meta.docs,
17-
url: `https://ota-meshi.github.io/eslint-plugin-svelte/rules/${ruleName}`,
17+
url: `https://ota-meshi.github.io/eslint-plugin-svelte/rules/${ruleName}/`,
1818
ruleId: `@ota-meshi/svelte/${ruleName}`,
1919
ruleName,
2020
},

0 commit comments

Comments
 (0)