Skip to content

Add valid-compile rule #39

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

Merged
merged 2 commits into from
Jul 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@
!/.vscode
!/.github
/prettier-playground
/tests/fixtures/rules/indent/invalid/ts
/tests/fixtures/rules/indent/invalid/ts
/tests/fixtures/rules/valid-compile/valid/ts
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ These rules relate to possible syntax or logic errors in Svelte code:
| [@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: |
| [@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: |
| [@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: |
| [@ota-meshi/svelte/valid-compile](https://ota-meshi.github.io/eslint-plugin-svelte/rules/valid-compile.html) | disallow warnings when compiling. | |

## Security Vulnerability

Expand Down
1 change: 1 addition & 0 deletions docs/rules/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ These rules relate to possible syntax or logic errors in Svelte code:
| [@ota-meshi/svelte/no-dupe-else-if-blocks](./no-dupe-else-if-blocks.md) | disallow duplicate conditions in `{#if}` / `{:else if}` chains | :star: |
| [@ota-meshi/svelte/no-not-function-handler](./no-not-function-handler.md) | disallow use of not function in event handler | :star: |
| [@ota-meshi/svelte/no-object-in-text-mustaches](./no-object-in-text-mustaches.md) | disallow objects in text mustache interpolation | :star: |
| [@ota-meshi/svelte/valid-compile](./valid-compile.md) | disallow warnings when compiling. | |

## Security Vulnerability

Expand Down
46 changes: 46 additions & 0 deletions docs/rules/valid-compile.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
pageClass: "rule-details"
sidebarDepth: 0
title: "@ota-meshi/svelte/valid-compile"
description: "disallow warnings when compiling."
---

# @ota-meshi/svelte/valid-compile

> disallow warnings when compiling.

- :exclamation: <badge text="This rule has not been released yet." vertical="middle" type="error"> **_This rule has not been released yet._** </badge>

## :book: Rule Details

This rule uses Svelte compiler to check the source code.

<eslint-code-block>

<!--eslint-skip-->

```svelte
<script>
/* eslint @ota-meshi/svelte/valid-compile: "error" */
let src = "tutorial/image.gif"
</script>

<!-- ✓ GOOD -->
<img {src} alt="Rick Astley dances." />

<!-- ✗ BAD -->
<img {src} />
```

</eslint-code-block>

Note that we exclude reports for some checks, such as `missing-declaration`, which you can check with different ESLint rules.

## :wrench: Options

Nothing.

## :mag: Implementation

- [Rule source](https://github.com/ota-meshi/eslint-plugin-svelte/blob/main/src/rules/valid-compile.ts)
- [Test source](https://github.com/ota-meshi/eslint-plugin-svelte/blob/main/tests/src/rules/valid-compile.ts)
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"dependencies": {
"debug": "^4.3.1",
"eslint-utils": "^3.0.0",
"sourcemap-codec": "^1.4.8",
"svelte-eslint-parser": "^0.4.0"
},
"peerDependencies": {
Expand Down Expand Up @@ -82,6 +83,9 @@
"eslint-plugin-vue": "^7.9.0",
"eslint-plugin-yml": "^0.9.0",
"eslint4b": "^7.25.0",
"estree-walker": "^3.0.0",
"locate-character": "^2.0.5",
"magic-string": "^0.25.7",
"mocha": "^9.0.0",
"nyc": "^15.1.0",
"pako": "^2.0.3",
Expand Down
Loading