Skip to content

Commit 3a5e339

Browse files
authored
Add valid-compile rule (#39)
* Add valid-compile rule * fix
1 parent 28030a6 commit 3a5e339

16 files changed

+543
-1
lines changed

.eslintignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@
77
!/.vscode
88
!/.github
99
/prettier-playground
10-
/tests/fixtures/rules/indent/invalid/ts
10+
/tests/fixtures/rules/indent/invalid/ts
11+
/tests/fixtures/rules/valid-compile/valid/ts

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@ These rules relate to possible syntax or logic errors in Svelte code:
250250
| [@ota-meshi/svelte/no-dupe-else-if-blocks](https://ota-meshi.github.io/eslint-plugin-svelte/rules/no-dupe-else-if-blocks.html) | disallow duplicate conditions in `{#if}` / `{:else if}` chains | :star: |
251251
| [@ota-meshi/svelte/no-not-function-handler](https://ota-meshi.github.io/eslint-plugin-svelte/rules/no-not-function-handler.html) | disallow use of not function in event handler | :star: |
252252
| [@ota-meshi/svelte/no-object-in-text-mustaches](https://ota-meshi.github.io/eslint-plugin-svelte/rules/no-object-in-text-mustaches.html) | disallow objects in text mustache interpolation | :star: |
253+
| [@ota-meshi/svelte/valid-compile](https://ota-meshi.github.io/eslint-plugin-svelte/rules/valid-compile.html) | disallow warnings when compiling. | |
253254

254255
## Security Vulnerability
255256

docs/rules/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ These rules relate to possible syntax or logic errors in Svelte code:
1818
| [@ota-meshi/svelte/no-dupe-else-if-blocks](./no-dupe-else-if-blocks.md) | disallow duplicate conditions in `{#if}` / `{:else if}` chains | :star: |
1919
| [@ota-meshi/svelte/no-not-function-handler](./no-not-function-handler.md) | disallow use of not function in event handler | :star: |
2020
| [@ota-meshi/svelte/no-object-in-text-mustaches](./no-object-in-text-mustaches.md) | disallow objects in text mustache interpolation | :star: |
21+
| [@ota-meshi/svelte/valid-compile](./valid-compile.md) | disallow warnings when compiling. | |
2122

2223
## Security Vulnerability
2324

docs/rules/valid-compile.md

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
---
2+
pageClass: "rule-details"
3+
sidebarDepth: 0
4+
title: "@ota-meshi/svelte/valid-compile"
5+
description: "disallow warnings when compiling."
6+
---
7+
8+
# @ota-meshi/svelte/valid-compile
9+
10+
> disallow warnings when compiling.
11+
12+
- :exclamation: <badge text="This rule has not been released yet." vertical="middle" type="error"> **_This rule has not been released yet._** </badge>
13+
14+
## :book: Rule Details
15+
16+
This rule uses Svelte compiler to check the source code.
17+
18+
<eslint-code-block>
19+
20+
<!--eslint-skip-->
21+
22+
```svelte
23+
<script>
24+
/* eslint @ota-meshi/svelte/valid-compile: "error" */
25+
let src = "tutorial/image.gif"
26+
</script>
27+
28+
<!-- ✓ GOOD -->
29+
<img {src} alt="Rick Astley dances." />
30+
31+
<!-- ✗ BAD -->
32+
<img {src} />
33+
```
34+
35+
</eslint-code-block>
36+
37+
Note that we exclude reports for some checks, such as `missing-declaration`, which you can check with different ESLint rules.
38+
39+
## :wrench: Options
40+
41+
Nothing.
42+
43+
## :mag: Implementation
44+
45+
- [Rule source](https://github.com/ota-meshi/eslint-plugin-svelte/blob/main/src/rules/valid-compile.ts)
46+
- [Test source](https://github.com/ota-meshi/eslint-plugin-svelte/blob/main/tests/src/rules/valid-compile.ts)

package.json

+4
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
"dependencies": {
4949
"debug": "^4.3.1",
5050
"eslint-utils": "^3.0.0",
51+
"sourcemap-codec": "^1.4.8",
5152
"svelte-eslint-parser": "^0.4.0"
5253
},
5354
"peerDependencies": {
@@ -82,6 +83,9 @@
8283
"eslint-plugin-vue": "^7.9.0",
8384
"eslint-plugin-yml": "^0.9.0",
8485
"eslint4b": "^7.25.0",
86+
"estree-walker": "^3.0.0",
87+
"locate-character": "^2.0.5",
88+
"magic-string": "^0.25.7",
8589
"mocha": "^9.0.0",
8690
"nyc": "^15.1.0",
8791
"pako": "^2.0.3",

0 commit comments

Comments
 (0)