-
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: wrong report position in client script with empty lines (#220)
* fix: wrong report position in client script with empty lines * Create forty-files-add.md
- Loading branch information
Showing
4 changed files
with
160 additions
and
5 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-astro": patch | ||
--- | ||
|
||
fix: wrong report position in client script with empty lines |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
import { RuleTester, Linter } from "eslint" | ||
import { processor } from "../../../src/processor" | ||
|
||
describe("Integration test for linebreak-style", () => { | ||
const ruleNoUnusedVars = new Linter().getRules().get("linebreak-style")! | ||
const tester = new RuleTester({ | ||
parser: require.resolve("./auto-parser"), | ||
parserOptions: { | ||
ecmaVersion: 2020, | ||
sourceType: "module", | ||
}, | ||
globals: { | ||
console: false, | ||
}, | ||
}) | ||
tester.run("linebreak-style", ruleNoUnusedVars, { | ||
valid: [ | ||
{ | ||
// @ts-expect-error -- fine name with processor | ||
filename: { | ||
filename: "foo.astro", | ||
...processor, | ||
}, | ||
code: ` | ||
<script define:vars={{ foo: 42, bar: 42 }}> | ||
console.log(foo) | ||
</script> | ||
`, | ||
}, | ||
{ | ||
// @ts-expect-error -- fine name with processor | ||
filename: { | ||
filename: "foo.astro", | ||
...processor, | ||
}, | ||
code: ` | ||
<script define:vars={{ bar: 42 }}> | ||
// empty lines | ||
console.log(foo) | ||
</script> | ||
`, | ||
}, | ||
], | ||
invalid: [ | ||
{ | ||
// @ts-expect-error -- fine name with processor | ||
filename: { | ||
filename: "foo.astro", | ||
...processor, | ||
}, | ||
code: `{/*eslint linebreak-style:0*/} | ||
<script define:vars={{ bar: 42 }}> | ||
console.log(foo)\r | ||
</script> | ||
`, | ||
output: `{/*eslint linebreak-style:0*/} | ||
<script define:vars={{ bar: 42 }}> | ||
console.log(foo) | ||
</script> | ||
`, | ||
errors: 1, | ||
}, | ||
{ | ||
// @ts-expect-error -- fine name with processor | ||
filename: { | ||
filename: "foo.astro", | ||
...processor, | ||
}, | ||
code: `{/*eslint linebreak-style:0*/} | ||
<script define:vars={{ bar: 42 }}>\r | ||
\r | ||
\r | ||
// empty lines\r | ||
console.log(foo)\r | ||
</script> | ||
`, | ||
output: `{/*eslint linebreak-style:0*/} | ||
<script define:vars={{ bar: 42 }}>\r | ||
\r | ||
// empty lines | ||
console.log(foo) | ||
</script> | ||
`, | ||
errors: 4, | ||
}, | ||
], | ||
}) | ||
}) |
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