Skip to content

Commit

Permalink
feat: add meta property (#233)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdjermanovic committed Feb 15, 2024
1 parent 313959b commit eedda96
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/index.js
Expand Up @@ -6,6 +6,7 @@
"use strict";

const processor = require("./processor");
const pkg = require("../package.json");

const rulesConfig = {

Expand All @@ -31,6 +32,10 @@ const rulesConfig = {
};

const plugin = {
meta: {
name: pkg.name,
version: pkg.version
},
processors: {
markdown: processor
},
Expand Down
5 changes: 5 additions & 0 deletions lib/processor.js
Expand Up @@ -28,6 +28,7 @@
"use strict";

const parse = require("mdast-util-from-markdown");
const pkg = require("../package.json");

const UNSATISFIABLE_RULES = new Set([
"eol-last", // The Markdown parser strips trailing newlines in code fences
Expand Down Expand Up @@ -398,6 +399,10 @@ function postprocess(messages, filename) {
}

module.exports = {
meta: {
name: `${pkg.name}/markdown`,
version: pkg.version
},
preprocess,
postprocess,
supportsAutofix: SUPPORTS_AUTOFIX
Expand Down
7 changes: 7 additions & 0 deletions tests/lib/plugin.js
Expand Up @@ -13,6 +13,7 @@ const assert = require("chai").assert;
const { LegacyESLint, FlatESLint } = require("eslint/use-at-your-own-risk");
const path = require("path");
const plugin = require("../..");
const pkg = require("../../package.json");

//-----------------------------------------------------------------------------
// Helpers
Expand Down Expand Up @@ -55,6 +56,12 @@ function initFlatESLint(fixtureConfigName, options = {}) {
// Tests
//-----------------------------------------------------------------------------

describe("meta", () => {
it("should export meta property", () => {
assert.deepStrictEqual(plugin.meta, { name: "eslint-plugin-markdown", version: pkg.version });
});
});

describe("LegacyESLint", () => {


Expand Down
7 changes: 7 additions & 0 deletions tests/lib/processor.js
Expand Up @@ -7,9 +7,16 @@

const assert = require("chai").assert;
const processor = require("../../lib/processor");
const pkg = require("../../package.json");

describe("processor", () => {

describe("meta", () => {
it("should have meta property", () => {
assert.deepStrictEqual(processor.meta, { name: "eslint-plugin-markdown/markdown", version: pkg.version });
});
});

describe("preprocess", () => {

it("should not crash", () => {
Expand Down

0 comments on commit eedda96

Please sign in to comment.