Skip to content

Commit

Permalink
feat: export meta object (#217)
Browse files Browse the repository at this point in the history
* feat: export meta object

* Create hungry-geckos-dance.md

* fix

* fix
  • Loading branch information
ota-meshi committed May 9, 2023
1 parent c6b5e85 commit 0791e40
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/hungry-geckos-dance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"eslint-plugin-json-schema-validator": minor
---

feat: export meta object
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { RuleModule } from "./types";
import { rules as ruleList } from "./utils/rules";
import base from "./configs/base";
import recommended from "./configs/recommended";
import * as meta from "./meta";

const configs = {
base,
Expand All @@ -14,6 +15,7 @@ const rules = ruleList.reduce((obj, r) => {
}, {} as { [key: string]: RuleModule });

export = {
meta,
configs,
rules,
};
3 changes: 3 additions & 0 deletions src/meta.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// note - cannot migrate this to an import statement because it will make TSC copy the package.json to the dist folder
// eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires -- Get meta data
export const { name, version } = require("../package.json");
14 changes: 14 additions & 0 deletions tests/src/meta.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import assert from "assert";
import plugin from "../../src";
import { version } from "../../package.json";
const expectedMeta = {
name: "eslint-plugin-json-schema-validator",
version,
};

describe("Test for meta object", () => {
it("A plugin should have a meta object.", () => {
assert.strictEqual(plugin.meta.name, expectedMeta.name);
assert.strictEqual(plugin.meta.version, expectedMeta.version);
});
});
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
// },
"esModuleInterop": true,
"outDir": "lib",
"resolveJsonModule": true,
"skipLibCheck": true
},
"include": [
Expand Down

0 comments on commit 0791e40

Please sign in to comment.