Skip to content

Commit

Permalink
feat: add meta object to @eslint/js plugin (#19095)
Browse files Browse the repository at this point in the history
  • Loading branch information
fasttime authored Nov 6, 2024
1 parent 298625e commit 3087c9e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
3 changes: 3 additions & 0 deletions packages/js/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,14 @@ export default [

// apply recommended rules to JS files
{
name: "your-project/recommended-rules",
files: ["**/*.js"],
rules: js.configs.recommended.rules
},

// apply recommended rules to JS files with an override
{
name: "your-project/recommended-rules-with-override",
files: ["**/*.js"],
rules: {
...js.configs.recommended.rules,
Expand All @@ -43,6 +45,7 @@ export default [

// apply all rules to JS files
{
name: "your-project/all-rules",
files: ["**/*.js"],
rules: {
...js.configs.all.rules,
Expand Down
6 changes: 6 additions & 0 deletions packages/js/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,17 @@

"use strict";

const { version } = require("../package.json");

//------------------------------------------------------------------------------
// Public Interface
//------------------------------------------------------------------------------

module.exports = {
meta: {
name: "@eslint/js",
version
},
configs: {
all: require("./configs/eslint-all"),
recommended: require("./configs/eslint-recommended")
Expand Down
6 changes: 5 additions & 1 deletion packages/js/tests/types/types.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,13 @@
* SOFTWARE
*/

import type { Linter } from "eslint";
import type { ESLint, Linter } from "eslint";
import js from "../../";

js satisfies ESLint.Plugin;
js.meta.name satisfies string;
js.meta.version satisfies string;

let config: Linter.Config[];

config = [js.configs.recommended];
Expand Down
4 changes: 4 additions & 0 deletions packages/js/types/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import type { Linter } from "eslint";

declare const js: {
readonly meta: {
readonly name: string;
readonly version: string;
},
readonly configs: {
readonly recommended: { readonly rules: Readonly<Linter.RulesRecord> };
readonly all: { readonly rules: Readonly<Linter.RulesRecord> };
Expand Down

0 comments on commit 3087c9e

Please sign in to comment.