Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add meta property #233

Merged
merged 1 commit into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Loading