Skip to content

Commit

Permalink
fix(deps): update dependency eslint-compat-utils to ^0.3.0 (#304)
Browse files Browse the repository at this point in the history
* fix(deps): update dependency eslint-compat-utils to ^0.3.0

* Create brave-lobsters-reply.md

* Create weak-points-boil.md

* fix

* fix

* fix

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Yosuke Ota <otameshiyo23@gmail.com>
  • Loading branch information
renovate[bot] and ota-meshi authored Jan 16, 2024
1 parent ee43850 commit eec7e97
Show file tree
Hide file tree
Showing 10 changed files with 65 additions and 98 deletions.
5 changes: 5 additions & 0 deletions .changeset/brave-lobsters-reply.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"eslint-plugin-astro": patch
---

fix(deps): update dependency eslint-compat-utils to ^0.3.0
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"@jridgewell/sourcemap-codec": "^1.4.14",
"@typescript-eslint/types": "^5.25.0",
"astro-eslint-parser": "^0.16.0",
"eslint-compat-utils": "^0.2.0",
"eslint-compat-utils": "^0.3.3",
"postcss": "^8.4.14",
"postcss-selector-parser": "^6.0.10"
},
Expand Down
4 changes: 2 additions & 2 deletions src/processor/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const clientSideTsProcessor: Linter.Processor = {
function preprocess(
code: string,
filename: string,
vartualFileExt: string,
virtualFileExt: string,
): ReturnType<NonNullable<Linter.Processor["preprocess"]>> {
if (filename) {
const shared = beginShared(filename)
Expand All @@ -53,7 +53,7 @@ function preprocess(
})
return [
code,
...shared.clientScripts.map((cs) => cs.getProcessorFile(vartualFileExt)),
...shared.clientScripts.map((cs) => cs.getProcessorFile(virtualFileExt)),
]
}

Expand Down
2 changes: 1 addition & 1 deletion src/rules/prefer-split-class-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ export default createRule("prefer-split-class-list", {
includeComments: false,
filter: isOpeningParenToken,
})!
const closeToken = sourceCode.getLastToken(callNode)!
const closeToken = sourceCode.getLastToken(callNode)
yield fixer.removeRange([callNode.range[0], openToken.range[1]])
yield fixer.remove(closeToken)
},
Expand Down
7 changes: 6 additions & 1 deletion src/shared/client-script/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,12 @@ export class ClientScript {
}

private isIgnoreMessage(message: Linter.LintMessage) {
if (message.ruleId === "eol-last" && message.messageId === "unexpected") {
if (
(message.ruleId === "eol-last" ||
// for test case
message.ruleId === "rule-to-test/eol-last") &&
message.messageId === "unexpected"
) {
// Ignore this report as it is not possible to remove the EOF of a block.
return true
}
Expand Down
40 changes: 13 additions & 27 deletions tests/src/integration/eol-last.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { ESLint } from "eslint"
import { RuleTester } from "../../utils/eslint-compat"
import { astroProcessor } from "../../../src/processor"
import { getCoreRule } from "./get-core-rule"
import semver from "semver"

describe("Integration test for eol-last", () => {
const eolLast = getCoreRule("eol-last")!
Expand All @@ -17,36 +15,26 @@ describe("Integration test for eol-last", () => {
tester.run("eol-last", eolLast, {
valid: [
{
filename: {
filename: "foo.astro",
...astroProcessor,
} as any,
filename: "foo.astro",
processor: astroProcessor,
code: `
<script define:vars={{ foo: 42 }}>
console.log(foo)
</script>\n`,
} as any,

...(semver.lt(ESLint.version, "9.0.0-0")
? [
{
filename: {
filename: "foo.astro",
...astroProcessor,
},
code: `
{
filename: "foo.astro",
processor: astroProcessor,
code: `
<script define:vars={{ foo: 42 }}>
console.log(foo)
</script>`,
options: ["never"],
},
]
: []),
options: ["never"],
},
{
filename: {
filename: "foo.astro",
...astroProcessor,
},
filename: "foo.astro",
processor: astroProcessor,
code: `
<script define:vars={{ foo: 42 }}>
console.log(foo)</script>`,
Expand All @@ -55,11 +43,9 @@ describe("Integration test for eol-last", () => {
],
invalid: [
{
// @ts-expect-error -- fine name with processor
filename: {
filename: "foo.astro",
...astroProcessor,
},
filename: "foo.astro",
// @ts-expect-error -- missing V9 type
processor: astroProcessor,
code: `
<script define:vars={{ foo: 42 }}>
console.log(foo)</script>\n`,
Expand Down
52 changes: 17 additions & 35 deletions tests/src/integration/linebreak-style.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { RuleTester } from "../../utils/eslint-compat"
import { Linter } from "eslint"
import { RuleTester, testRuleIdPrefix } from "../../utils/eslint-compat"
import { astroProcessor } from "../../../src/processor"
import { getCoreRule } from "./get-core-rule"
import semver from "semver"

describe("Integration test for linebreak-style", () => {
const ruleNoUnusedVars = getCoreRule("linebreak-style")!
Expand All @@ -20,23 +18,19 @@ describe("Integration test for linebreak-style", () => {
tester.run("linebreak-style", ruleNoUnusedVars, {
valid: [
{
// @ts-expect-error -- fine name with processor
filename: {
filename: "foo.astro",
...astroProcessor,
},
filename: "foo.astro",
// @ts-expect-error -- missing V9 type
processor: astroProcessor,
code: `
<script define:vars={{ foo: 42, bar: 42 }}>
console.log(foo)
</script>
`,
},
{
// @ts-expect-error -- fine name with processor
filename: {
filename: "foo.astro",
...astroProcessor,
},
filename: "foo.astro",
// @ts-expect-error -- missing V9 type
processor: astroProcessor,
code: `
<script define:vars={{ bar: 42 }}>
Expand All @@ -49,46 +43,34 @@ describe("Integration test for linebreak-style", () => {
],
invalid: [
{
// @ts-expect-error -- fine name with processor
filename: {
filename: "foo.astro",
...astroProcessor,
},
code: `{/*eslint ${
semver.gte(Linter.version, "9.0.0-0") ? "rule-to-test/" : ""
}linebreak-style:0*/}
filename: "foo.astro",
// @ts-expect-error -- missing V9 type
processor: astroProcessor,
code: `{/*eslint ${testRuleIdPrefix}linebreak-style:0*/}
<script define:vars={{ bar: 42 }}>
console.log(foo)\r
</script>
`,
output: `{/*eslint ${
semver.gte(Linter.version, "9.0.0-0") ? "rule-to-test/" : ""
}linebreak-style:0*/}
output: `{/*eslint ${testRuleIdPrefix}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",
...astroProcessor,
},
code: `{/*eslint ${
semver.gte(Linter.version, "9.0.0-0") ? "rule-to-test/" : ""
}linebreak-style:0*/}
filename: "foo.astro",
// @ts-expect-error -- missing V9 type
processor: astroProcessor,
code: `{/*eslint ${testRuleIdPrefix}linebreak-style:0*/}
<script define:vars={{ bar: 42 }}>\r
\r
\r
// empty lines\r
console.log(foo)\r
</script>
`,
output: `{/*eslint ${
semver.gte(Linter.version, "9.0.0-0") ? "rule-to-test/" : ""
}linebreak-style:0*/}
output: `{/*eslint ${testRuleIdPrefix}linebreak-style:0*/}
<script define:vars={{ bar: 42 }}>\r
\r
Expand Down
32 changes: 12 additions & 20 deletions tests/src/integration/no-undef.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,9 @@ describe("Integration test for no-undef", () => {
tester.run("no-undef", ruleNoUnusedVars, {
valid: [
{
// @ts-expect-error -- fine name with processor
filename: {
filename: "foo.astro",
...astroProcessor,
},
filename: "foo.astro",
// @ts-expect-error -- missing V9 type
processor: astroProcessor,
code: `
<script define:vars={{ foo: 42, bar: 42 }}>
console.log(foo)
Expand All @@ -32,11 +30,9 @@ describe("Integration test for no-undef", () => {
],
invalid: [
{
// @ts-expect-error -- fine name with processor
filename: {
filename: "foo.astro",
...astroProcessor,
},
filename: "foo.astro",
// @ts-expect-error -- missing V9 type
processor: astroProcessor,
code: `
<script define:vars={{ bar: 42 }}>
console.log(foo)
Expand All @@ -51,11 +47,9 @@ describe("Integration test for no-undef", () => {
],
},
{
// @ts-expect-error -- fine name with processor
filename: {
filename: "foo.astro",
...astroProcessor,
},
filename: "foo.astro",
// @ts-expect-error -- missing V9 type
processor: astroProcessor,
code: `
<script define:vars={{ bar: 42 }}>
Expand All @@ -73,11 +67,9 @@ describe("Integration test for no-undef", () => {
],
},
{
// @ts-expect-error -- fine name with processor
filename: {
filename: "foo.astro",
...astroProcessor,
},
filename: "foo.astro",
// @ts-expect-error -- missing V9 type
processor: astroProcessor,
code: `
<script define:vars={{ bar: 42 }}>
Expand Down
16 changes: 6 additions & 10 deletions tests/src/integration/no-unused-vars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,9 @@ describe("Integration test for no-unused-vars", () => {
tester.run("no-unused-vars", ruleNoUnusedVars, {
valid: [
{
// @ts-expect-error -- fine name with processor
filename: {
filename: "foo.astro",
...astroProcessor,
},
filename: "foo.astro",
// @ts-expect-error -- missing V9 type
processor: astroProcessor,
code: `
<script define:vars={{ foo: 42 }}>
console.log(foo)
Expand All @@ -29,11 +27,9 @@ describe("Integration test for no-unused-vars", () => {
],
invalid: [
{
// @ts-expect-error -- fine name with processor
filename: {
filename: "foo.astro",
...astroProcessor,
},
filename: "foo.astro",
// @ts-expect-error -- missing V9 type
processor: astroProcessor,
code: `
<script define:vars={{ foo: 42, bar: 42 }}>
console.log(foo)
Expand Down
3 changes: 2 additions & 1 deletion tests/utils/eslint-compat.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ESLint as OriginalESLint } from "eslint"
import { getRuleTester } from "eslint-compat-utils/rule-tester"
import { getRuleIdPrefix, getRuleTester } from "eslint-compat-utils/rule-tester"
// @ts-expect-error -- missing type
import { FlatCompat } from "@eslint/eslintrc"
import astroPlugin from "../../src/index"
Expand All @@ -9,6 +9,7 @@ export const LegacyESLint: typeof OriginalESLint =
getUnsupported().LegacyESLint || OriginalESLint
// eslint-disable-next-line @typescript-eslint/naming-convention -- class name
export const RuleTester = getRuleTester()
export const testRuleIdPrefix = getRuleIdPrefix()

function getUnsupported() {
try {
Expand Down

0 comments on commit eec7e97

Please sign in to comment.