-
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: improve
svelte/valid-compile
to use svelte.config.js
's `onw…
- Loading branch information
Showing
21 changed files
with
225 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'eslint-plugin-svelte': minor | ||
--- | ||
|
||
feat: improve `svelte/valid-compile` to use `svelte.config.js`'s `onwarn` from the parser. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
...in-svelte/tests/fixtures/rules/valid-compile/invalid/svelte-config-custom-warn/_config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/** | ||
* @typedef {import("svelte/compiler").Warning} Warning | ||
*/ | ||
module.exports = { | ||
languageOptions: { | ||
parserOptions: { | ||
svelteConfig: { | ||
/** | ||
* @param {Warning} warning | ||
* @param {(warning: Warning) => void} handler | ||
* @returns {void} | ||
*/ | ||
onwarn(warning, handler) { | ||
// transform code | ||
handler({ ...warning, code: 'foo' }); | ||
} | ||
} | ||
} | ||
} | ||
}; |
8 changes: 8 additions & 0 deletions
8
...lte/tests/fixtures/rules/valid-compile/invalid/svelte-config-custom-warn/a11y-errors.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
- message: '`<img>` element should have an alt attribute(foo)' | ||
line: 5 | ||
column: 1 | ||
suggestions: null | ||
- message: Avoid using autofocus(foo) | ||
line: 5 | ||
column: 12 | ||
suggestions: null |
5 changes: 5 additions & 0 deletions
5
...te/tests/fixtures/rules/valid-compile/invalid/svelte-config-custom-warn/a11y-input.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<script> | ||
let src = 'tutorial/image.gif'; | ||
</script> | ||
|
||
<img {src} autofocus /> |
3 changes: 3 additions & 0 deletions
3
...sts/fixtures/rules/valid-compile/invalid/svelte-config-custom-warn/a11y-requirements.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"svelte": ">=5.0.0-0" | ||
} |
8 changes: 8 additions & 0 deletions
8
...s/fixtures/rules/valid-compile/invalid/svelte-config-custom-warn/a11y-svelte4-errors.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
- message: 'A11y: <img> element should have an alt attribute(foo)' | ||
line: 5 | ||
column: 1 | ||
suggestions: null | ||
- message: 'A11y: Avoid using autofocus(foo)' | ||
line: 5 | ||
column: 12 | ||
suggestions: null |
5 changes: 5 additions & 0 deletions
5
.../fixtures/rules/valid-compile/invalid/svelte-config-custom-warn/a11y-svelte4-input.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<script> | ||
let src = 'tutorial/image.gif'; | ||
</script> | ||
|
||
<img {src} autofocus /> |
3 changes: 3 additions & 0 deletions
3
...ures/rules/valid-compile/invalid/svelte-config-custom-warn/a11y-svelte4-requirements.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"svelte": "^3.0.0 || ^4.0.0" | ||
} |
24 changes: 24 additions & 0 deletions
24
...-plugin-svelte/tests/fixtures/rules/valid-compile/invalid/svelte-config-ignore/_config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/** | ||
* @typedef {import("svelte/compiler").Warning} Warning | ||
*/ | ||
module.exports = { | ||
languageOptions: { | ||
parserOptions: { | ||
svelteConfig: { | ||
/** | ||
* @param {Warning} warning | ||
* @param {(warning: Warning) => void} handler | ||
* @returns {void} | ||
*/ | ||
onwarn(warning, handler) { | ||
if ( | ||
warning.code === 'a11y_missing_attribute' || | ||
warning.code === 'a11y-missing-attribute' | ||
) | ||
return; | ||
handler(warning); | ||
} | ||
} | ||
} | ||
} | ||
}; |
4 changes: 4 additions & 0 deletions
4
...n-svelte/tests/fixtures/rules/valid-compile/invalid/svelte-config-ignore/a11y-errors.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
- message: Avoid using autofocus(a11y_autofocus) | ||
line: 5 | ||
column: 12 | ||
suggestions: null |
5 changes: 5 additions & 0 deletions
5
...-svelte/tests/fixtures/rules/valid-compile/invalid/svelte-config-ignore/a11y-input.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<script> | ||
let src = 'tutorial/image.gif'; | ||
</script> | ||
|
||
<img {src} autofocus /> |
3 changes: 3 additions & 0 deletions
3
...te/tests/fixtures/rules/valid-compile/invalid/svelte-config-ignore/a11y-requirements.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"svelte": ">=5.0.0-0" | ||
} |
4 changes: 4 additions & 0 deletions
4
.../tests/fixtures/rules/valid-compile/invalid/svelte-config-ignore/a11y-svelte4-errors.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
- message: 'A11y: Avoid using autofocus(a11y-autofocus)' | ||
line: 5 | ||
column: 12 | ||
suggestions: null |
5 changes: 5 additions & 0 deletions
5
...tests/fixtures/rules/valid-compile/invalid/svelte-config-ignore/a11y-svelte4-input.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<script> | ||
let src = 'tutorial/image.gif'; | ||
</script> | ||
|
||
<img {src} autofocus /> |
3 changes: 3 additions & 0 deletions
3
.../fixtures/rules/valid-compile/invalid/svelte-config-ignore/a11y-svelte4-requirements.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"svelte": "^3.0.0 || ^4.0.0" | ||
} |
24 changes: 24 additions & 0 deletions
24
...nt-plugin-svelte/tests/fixtures/rules/valid-compile/valid/svelte-config-ignore/_config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/** | ||
* @typedef {import("svelte/compiler").Warning} Warning | ||
*/ | ||
module.exports = { | ||
languageOptions: { | ||
parserOptions: { | ||
svelteConfig: { | ||
/** | ||
* @param {Warning} warning | ||
* @param {(warning: Warning) => void} handler | ||
* @returns {void} | ||
*/ | ||
onwarn(warning, handler) { | ||
if ( | ||
warning.code === 'a11y_missing_attribute' || | ||
warning.code === 'a11y-missing-attribute' | ||
) | ||
return; | ||
handler(warning); | ||
} | ||
} | ||
} | ||
} | ||
}; |
5 changes: 5 additions & 0 deletions
5
...in-svelte/tests/fixtures/rules/valid-compile/valid/svelte-config-ignore/a11y-input.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<script> | ||
let src = 'tutorial/image.gif'; | ||
</script> | ||
|
||
<img {src} /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters