Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ota-meshi committed Dec 12, 2023
1 parent 6367626 commit 0e707e8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 18 deletions.
10 changes: 4 additions & 6 deletions lib/utils/stylelint.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@ module.exports = {
loadCoreRule,
}

async function loadCoreRule(name) {
// eslint-disable-next-line node/no-unsupported-features/es-syntax -- ignore
const stylelint = await import("stylelint").then(
(mod) => mod.default || mod,
)
function loadCoreRule(name) {
const stylelintMod = require("stylelint")
const stylelint = stylelintMod.default || stylelintMod
const rule = stylelint.rules?.[name]
if (rule) {
return rule
}
return require(`stylelint/lib/rules/${name}`)
return Promise.resolve(require(`stylelint/lib/rules/${name}`))
}
10 changes: 4 additions & 6 deletions tests/runs/integrations/stylelint-v13/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ const { fail } = require("assert")
const cp = require("child_process")
const path = require("path")

const STYLELINT = `.${path.sep}node_modules${path.sep}.bin${path.sep}stylelint`

describe("Integration with stylelint v13", () => {
let originalCwd

Expand All @@ -27,20 +25,20 @@ describe("Integration with stylelint v13", () => {

it("should lint without errors with styl", () => {
cp.execSync(
`${STYLELINT} src/valid.styl --custom-syntax stylelint-stylus/custom-syntax`,
`npx stylelint src/valid.styl --custom-syntax stylelint-stylus/custom-syntax`,
{ stdio: "inherit" },
)
})
it("should lint without errors with stylus", () => {
cp.execSync(
`${STYLELINT} src/valid.stylus --custom-syntax stylelint-stylus/custom-syntax`,
`npx stylelint src/valid.stylus --custom-syntax stylelint-stylus/custom-syntax`,
{ stdio: "inherit" },
)
})
it("should lint with errors with styl", () => {
try {
cp.execSync(
`${STYLELINT} src/invalid.styl --custom-syntax stylelint-stylus/custom-syntax`,
`npx stylelint src/invalid.styl --custom-syntax stylelint-stylus/custom-syntax`,
{ stdio: "inherit" },
)
fail("Expect an error, but without errors")
Expand All @@ -51,7 +49,7 @@ describe("Integration with stylelint v13", () => {
it("should lint with errors with stylus", () => {
try {
cp.execSync(
`${STYLELINT} src/invalid.stylus --custom-syntax stylelint-stylus/custom-syntax`,
`npx stylelint src/invalid.stylus --custom-syntax stylelint-stylus/custom-syntax`,
{ stdio: "inherit" },
)
fail("Expect an error, but without errors")
Expand Down
12 changes: 6 additions & 6 deletions tests/runs/integrations/stylelint-v14/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ const { fail } = require("assert")
const cp = require("child_process")
const path = require("path")

const STYLELINT = `.${path.sep}node_modules${path.sep}.bin${path.sep}stylelint`

describe("Integration with stylelint v14", () => {
let originalCwd

Expand All @@ -26,22 +24,24 @@ describe("Integration with stylelint v14", () => {
})

it("should lint without errors with styl", () => {
cp.execSync(`${STYLELINT} src/valid.styl`, { stdio: "inherit" })
cp.execSync(`npx stylelint src/valid.styl`, { stdio: "inherit" })
})
it("should lint without errors with stylus", () => {
cp.execSync(`${STYLELINT} src/valid.stylus`, { stdio: "inherit" })
cp.execSync(`npx stylelint src/valid.stylus`, { stdio: "inherit" })
})
it("should lint with errors with styl", () => {
try {
cp.execSync(`${STYLELINT} src/invalid.styl`, { stdio: "inherit" })
cp.execSync(`npx stylelint src/invalid.styl`, { stdio: "inherit" })
fail("Expect an error, but without errors")
} catch {
// Expected!s
}
})
it("should lint with errors with stylus", () => {
try {
cp.execSync(`${STYLELINT} src/invalid.stylus`, { stdio: "inherit" })
cp.execSync(`npx stylelint src/invalid.stylus`, {
stdio: "inherit",
})
fail("Expect an error, but without errors")
} catch {
// Expected!s
Expand Down

0 comments on commit 0e707e8

Please sign in to comment.