Skip to content

Commit

Permalink
Fix: overrides pattern for virtual filenames in recommended config (#169
Browse files Browse the repository at this point in the history
)

* Fix: overrides pattern for virtual filenames in recommended config

* Chore: Test settings configured by recommended config

Co-authored-by: Brandon Mills <[email protected]>
  • Loading branch information
mdjermanovic and btmills authored Jan 31, 2021
1 parent 390d508 commit f6a3fad
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
5 changes: 4 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ module.exports = {
overrides: [
{
files: ["*.md"],
processor: "markdown/markdown",
processor: "markdown/markdown"
},
{
files: ["**/*.md/**"],
parserOptions: {
ecmaFeatures: {

Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/recommended.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"root": true,
"extends": "plugin:markdown/recommended",
"extends": ["eslint:recommended", "plugin:markdown/recommended"],
"rules": {
"no-console": "error"
}
Expand Down
21 changes: 20 additions & 1 deletion tests/lib/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const plugin = require("../..");
function initCLI(fixtureConfigName, isAutofixEnabled) {
const fix = isAutofixEnabled || false;
const cli = new CLIEngine({
cwd: path.resolve(__dirname, "../fixtures/"),
fix,
ignore: false,
useEslintrc: false,
Expand All @@ -35,7 +36,8 @@ describe("recommended config", () => {
let cli;
const shortText = [
"```js",
"console.log(42);",
"var unusedVar = console.log(undef);",
"'unused expression';",
"```"
].join("\n");

Expand Down Expand Up @@ -72,6 +74,23 @@ describe("recommended config", () => {
assert.include(config.plugins, "markdown");
});

it("applies convenience configuration", () => {
const config = cli.getConfigForFile("subdir/test.md/0.js");

assert.deepStrictEqual(config.parserOptions, {
ecmaFeatures: {
impliedStrict: true
}
});
assert.deepStrictEqual(config.rules["eol-last"], ["off"]);
assert.deepStrictEqual(config.rules["no-undef"], ["off"]);
assert.deepStrictEqual(config.rules["no-unused-expressions"], ["off"]);
assert.deepStrictEqual(config.rules["no-unused-vars"], ["off"]);
assert.deepStrictEqual(config.rules["padded-blocks"], ["off"]);
assert.deepStrictEqual(config.rules.strict, ["off"]);
assert.deepStrictEqual(config.rules["unicode-bom"], ["off"]);
});

it("overrides configure processor to parse .md file code blocks", () => {
const report = cli.executeOnText(shortText, "test.md");

Expand Down

0 comments on commit f6a3fad

Please sign in to comment.