|
| 1 | +import cp from "child_process" |
| 2 | +import assert from "assert" |
| 3 | +import path from "path" |
| 4 | +import plugin from "../../lib/index" |
| 5 | + |
| 6 | +// ----------------------------------------------------------------------------- |
| 7 | +// Tests |
| 8 | +// ----------------------------------------------------------------------------- |
| 9 | + |
| 10 | +const TEST_CWD = path.join(__dirname, "../fixtures/eslint-plugin-markdown") |
| 11 | + |
| 12 | +const ESLINT = path.join(TEST_CWD, `./node_modules/eslint`) |
| 13 | + |
| 14 | +describe("Integration with eslint-plugin-markdown", () => { |
| 15 | + let originalCwd: string |
| 16 | + |
| 17 | + before(() => { |
| 18 | + originalCwd = process.cwd() |
| 19 | + process.chdir(TEST_CWD) |
| 20 | + cp.execSync("npm i", { stdio: "inherit" }) |
| 21 | + }) |
| 22 | + after(() => { |
| 23 | + process.chdir(originalCwd) |
| 24 | + }) |
| 25 | + |
| 26 | + it("should lint without errors", () => { |
| 27 | + /* eslint-disable @typescript-eslint/ban-ts-comment, @typescript-eslint/no-var-requires, @typescript-eslint/no-require-imports -- test */ |
| 28 | + // @ts-ignore |
| 29 | + const eslint = require(ESLINT) |
| 30 | + /* eslint-enable @typescript-eslint/ban-ts-comment, @typescript-eslint/no-var-requires, @typescript-eslint/no-require-imports -- test */ |
| 31 | + const engine = new eslint.CLIEngine({ |
| 32 | + cwd: TEST_CWD, |
| 33 | + extensions: [".js", ".json", ".yaml"], |
| 34 | + }) |
| 35 | + engine.addPlugin("eslint-plugin-jsonc", plugin) |
| 36 | + const r = engine.executeOnFiles(["./test.md"]) |
| 37 | + |
| 38 | + assert.strictEqual(r.results.length, 1) |
| 39 | + assert.strictEqual(r.results[0].messages.length, 1) |
| 40 | + assert.strictEqual( |
| 41 | + r.results[0].messages[0].message, |
| 42 | + "[jsonc/array-bracket-newline] There should be no linebreak before ']'.", |
| 43 | + ) |
| 44 | + }) |
| 45 | +}) |
0 commit comments