diff --git a/.release-please-manifest.json b/.release-please-manifest.json
index d95d0ffee..b0ea9c4aa 100644
--- a/.release-please-manifest.json
+++ b/.release-please-manifest.json
@@ -1,8 +1,8 @@
{
"packages/compat": "1.1.1",
"packages/config-array": "0.18.0",
- "packages/core": "0.5.0",
- "packages/migrate-config": "1.2.1",
+ "packages/core": "0.6.0",
+ "packages/migrate-config": "1.3.0",
"packages/object-schema": "2.1.4",
- "packages/plugin-kit": "0.1.0"
+ "packages/plugin-kit": "0.2.0"
}
diff --git a/README.md b/README.md
index 674b38e62..1a1132150 100644
--- a/README.md
+++ b/README.md
@@ -20,7 +20,7 @@ The following companies, organizations, and individuals support ESLint's ongoing
Platinum Sponsors

Gold Sponsors
-

Silver Sponsors
+

Silver Sponsors

Bronze Sponsors

diff --git a/packages/compat/README.md b/packages/compat/README.md
index 65438fb4f..ccd7a5489 100644
--- a/packages/compat/README.md
+++ b/packages/compat/README.md
@@ -195,7 +195,7 @@ The following companies, organizations, and individuals support ESLint's ongoing
Platinum Sponsors

Gold Sponsors
-

Silver Sponsors
+

Silver Sponsors

Bronze Sponsors

diff --git a/packages/config-array/README.md b/packages/config-array/README.md
index b9abf1c68..f09d4e00f 100644
--- a/packages/config-array/README.md
+++ b/packages/config-array/README.md
@@ -347,7 +347,7 @@ The following companies, organizations, and individuals support ESLint's ongoing
Platinum Sponsors

Gold Sponsors
-

Silver Sponsors
+

Silver Sponsors

Bronze Sponsors

diff --git a/packages/core/CHANGELOG.md b/packages/core/CHANGELOG.md
index 3e2a303a6..6f86d27f7 100644
--- a/packages/core/CHANGELOG.md
+++ b/packages/core/CHANGELOG.md
@@ -1,5 +1,12 @@
# Changelog
+## [0.6.0](https://github.com/eslint/rewrite/compare/core-v0.5.0...core-v0.6.0) (2024-08-30)
+
+
+### Features
+
+* Add Directive and DirectiveType ([#112](https://github.com/eslint/rewrite/issues/112)) ([e5bbcf1](https://github.com/eslint/rewrite/commit/e5bbcf148874be07d5667f34ed395faaf8c72972))
+
## [0.5.0](https://github.com/eslint/rewrite/compare/core-v0.4.0...core-v0.5.0) (2024-08-27)
diff --git a/packages/core/README.md b/packages/core/README.md
index 2b28267e7..f0ca8dcdc 100644
--- a/packages/core/README.md
+++ b/packages/core/README.md
@@ -18,7 +18,7 @@ The following companies, organizations, and individuals support ESLint's ongoing
Platinum Sponsors

Gold Sponsors
-

Silver Sponsors
+

Silver Sponsors

Bronze Sponsors

diff --git a/packages/core/jsr.json b/packages/core/jsr.json
index ceb749991..8b4e224f6 100644
--- a/packages/core/jsr.json
+++ b/packages/core/jsr.json
@@ -1,6 +1,6 @@
{
"name": "@eslint/core",
- "version": "0.5.0",
+ "version": "0.6.0",
"exports": "./dist/esm/types.d.ts",
"publish": {
"include": [
diff --git a/packages/core/package.json b/packages/core/package.json
index df3b7da65..fa7223da2 100644
--- a/packages/core/package.json
+++ b/packages/core/package.json
@@ -1,6 +1,6 @@
{
"name": "@eslint/core",
- "version": "0.5.0",
+ "version": "0.6.0",
"description": "Runtime-agnostic core of ESLint",
"type": "module",
"types": "./dist/esm/types.d.ts",
diff --git a/packages/core/src/types.ts b/packages/core/src/types.ts
index b2c22a867..45a111663 100644
--- a/packages/core/src/types.ts
+++ b/packages/core/src/types.ts
@@ -419,6 +419,15 @@ export interface CallTraversalStep {
export type TraversalStep = VisitTraversalStep | CallTraversalStep;
+/**
+ * The type of disable directive. This determines how ESLint will disable rules.
+ */
+export type DirectiveType =
+ | "disable"
+ | "enable"
+ | "disable-line"
+ | "disable-next-line";
+
/**
* Represents a disable directive.
*/
@@ -426,12 +435,12 @@ export interface Directive {
/**
* The type of directive.
*/
- type: "disable" | "enable" | "disable-line" | "disable-next-line";
+ type: DirectiveType;
/**
* The node of the directive. May be in the AST or a comment/token.
*/
- node: object;
+ node: unknown;
/**
* The value of the directive.
diff --git a/packages/migrate-config/CHANGELOG.md b/packages/migrate-config/CHANGELOG.md
index 4478b4ea4..627f99ee5 100644
--- a/packages/migrate-config/CHANGELOG.md
+++ b/packages/migrate-config/CHANGELOG.md
@@ -1,5 +1,12 @@
# Changelog
+## [1.3.0](https://github.com/eslint/rewrite/compare/migrate-config-v1.2.1...migrate-config-v1.3.0) (2024-08-30)
+
+
+### Features
+
+* Add eslint-plugin-flowtype to compat plugins ([#115](https://github.com/eslint/rewrite/issues/115)) ([5cb3919](https://github.com/eslint/rewrite/commit/5cb3919085ed60331e253c472c72a5870a9b9c11))
+
## [1.2.1](https://github.com/eslint/rewrite/compare/migrate-config-v1.2.0...migrate-config-v1.2.1) (2024-08-27)
diff --git a/packages/migrate-config/README.md b/packages/migrate-config/README.md
index 5525704e6..7f3081a22 100644
--- a/packages/migrate-config/README.md
+++ b/packages/migrate-config/README.md
@@ -99,7 +99,7 @@ The following companies, organizations, and individuals support ESLint's ongoing
Platinum Sponsors

Gold Sponsors
-

Silver Sponsors
+

Silver Sponsors

Bronze Sponsors

diff --git a/packages/migrate-config/package.json b/packages/migrate-config/package.json
index 12812ed48..cc82ca7c5 100644
--- a/packages/migrate-config/package.json
+++ b/packages/migrate-config/package.json
@@ -1,6 +1,6 @@
{
"name": "@eslint/migrate-config",
- "version": "1.2.1",
+ "version": "1.3.0",
"description": "Configuration migration for ESLint",
"type": "module",
"bin": {
diff --git a/packages/migrate-config/src/compat-plugins.js b/packages/migrate-config/src/compat-plugins.js
index d9ef25333..66c87d0aa 100644
--- a/packages/migrate-config/src/compat-plugins.js
+++ b/packages/migrate-config/src/compat-plugins.js
@@ -7,4 +7,5 @@ export default [
"eslint-plugin-ava",
"eslint-plugin-react-hooks",
"eslint-plugin-import",
+ "eslint-plugin-flowtype",
];
diff --git a/packages/object-schema/README.md b/packages/object-schema/README.md
index 35329f743..36b4faf3e 100644
--- a/packages/object-schema/README.md
+++ b/packages/object-schema/README.md
@@ -231,7 +231,7 @@ The following companies, organizations, and individuals support ESLint's ongoing
Platinum Sponsors

Gold Sponsors
-

Silver Sponsors
+

Silver Sponsors

Bronze Sponsors

diff --git a/packages/plugin-kit/CHANGELOG.md b/packages/plugin-kit/CHANGELOG.md
index fcdf394f4..3a72491dd 100644
--- a/packages/plugin-kit/CHANGELOG.md
+++ b/packages/plugin-kit/CHANGELOG.md
@@ -1,5 +1,19 @@
# Changelog
+## [0.2.0](https://github.com/eslint/rewrite/compare/plugin-kit-v0.1.0...plugin-kit-v0.2.0) (2024-08-30)
+
+
+### Features
+
+* Add Directive and DirectiveType ([#112](https://github.com/eslint/rewrite/issues/112)) ([e5bbcf1](https://github.com/eslint/rewrite/commit/e5bbcf148874be07d5667f34ed395faaf8c72972))
+
+
+### Dependencies
+
+* The following workspace dependencies were updated
+ * devDependencies
+ * @eslint/core bumped from ^0.5.0 to ^0.6.0
+
## 0.1.0 (2024-08-27)
diff --git a/packages/plugin-kit/README.md b/packages/plugin-kit/README.md
index 6d68d42b4..6ebbbf78e 100644
--- a/packages/plugin-kit/README.md
+++ b/packages/plugin-kit/README.md
@@ -30,6 +30,7 @@ This package exports the following utilities:
- `ConfigCommentParser` - used to parse ESLint configuration comments (i.e., `/* eslint-disable rule */`)
- `VisitNodeStep` and `CallMethodStep` - used to help implement `SourceCode#traverse()`
+- `Directive` - used to help implement `SourceCode#getDisableDirectives()`
- `TextSourceCodeBase` - base class to help implement the `SourceCode` interface
### `ConfigCommentParser`
@@ -151,6 +152,55 @@ class MySourceCode {
}
```
+### `Directive`
+
+The `Directive` class represents a disable directive in the source code and implements the `Directive` interface from `@eslint/core`. You can tell ESLint about disable directives using the `SourceCode#getDisableDirectives()` method, where part of the return value is an array of `Directive` objects. Here's an example:
+
+```js
+import { Directive, ConfigCommentParser } from "@eslint/plugin-kit";
+
+class MySourceCode {
+ getDisableDirectives() {
+ const directives = [];
+ const problems = [];
+ const commentParser = new ConfigCommentParser();
+
+ // read in the inline config nodes to check each one
+ this.getInlineConfigNodes().forEach(comment => {
+ // Step 1: Parse the directive
+ const { label, value, justification } =
+ commentParser.parseDirective(comment.value);
+
+ // Step 2: Extract the directive value and create the `Directive` object
+ switch (label) {
+ case "eslint-disable":
+ case "eslint-enable":
+ case "eslint-disable-next-line":
+ case "eslint-disable-line": {
+ const directiveType = label.slice("eslint-".length);
+
+ directives.push(
+ new Directive({
+ type: directiveType,
+ node: comment,
+ value,
+ justification,
+ }),
+ );
+ }
+
+ // ignore any comments that don't begin with known labels
+ }
+ });
+
+ return {
+ directives,
+ problems,
+ };
+ }
+}
+```
+
### `TextSourceCodeBase`
The `TextSourceCodeBase` class is intended to be a base class that has several of the common members found in `SourceCode` objects already implemented. Those members are:
@@ -212,7 +262,7 @@ The following companies, organizations, and individuals support ESLint's ongoing
Platinum Sponsors

Gold Sponsors
-

Silver Sponsors
+

Silver Sponsors

Bronze Sponsors

diff --git a/packages/plugin-kit/jsr.json b/packages/plugin-kit/jsr.json
index a9d8bfac9..86ad4c274 100644
--- a/packages/plugin-kit/jsr.json
+++ b/packages/plugin-kit/jsr.json
@@ -1,6 +1,6 @@
{
"name": "@eslint/plugin-kit",
- "version": "0.1.0",
+ "version": "0.2.0",
"exports": "./dist/esm/index.js",
"publish": {
"include": [
diff --git a/packages/plugin-kit/package.json b/packages/plugin-kit/package.json
index bb04a1216..82fa406bb 100644
--- a/packages/plugin-kit/package.json
+++ b/packages/plugin-kit/package.json
@@ -1,6 +1,6 @@
{
"name": "@eslint/plugin-kit",
- "version": "0.1.0",
+ "version": "0.2.0",
"description": "Utilities for building ESLint plugins.",
"author": "Nicholas C. Zakas",
"type": "module",
@@ -46,7 +46,7 @@
],
"license": "Apache-2.0",
"devDependencies": {
- "@eslint/core": "^0.5.0",
+ "@eslint/core": "^0.6.0",
"c8": "^9.1.0",
"mocha": "^10.4.0",
"rollup": "^4.16.2",
diff --git a/packages/plugin-kit/src/index.js b/packages/plugin-kit/src/index.js
index 908fa3209..26302befc 100644
--- a/packages/plugin-kit/src/index.js
+++ b/packages/plugin-kit/src/index.js
@@ -8,4 +8,5 @@ export {
CallMethodStep,
VisitNodeStep,
TextSourceCodeBase,
+ Directive,
} from "./source-code.js";
diff --git a/packages/plugin-kit/src/source-code.js b/packages/plugin-kit/src/source-code.js
index a19853491..13854ccba 100644
--- a/packages/plugin-kit/src/source-code.js
+++ b/packages/plugin-kit/src/source-code.js
@@ -16,6 +16,8 @@
/** @typedef {import("@eslint/core").SourceLocation} SourceLocation */
/** @typedef {import("@eslint/core").SourceLocationWithOffset} SourceLocationWithOffset */
/** @typedef {import("@eslint/core").SourceRange} SourceRange */
+/** @typedef {import("@eslint/core").Directive} IDirective */
+/** @typedef {import("@eslint/core").DirectiveType} DirectiveType */
//-----------------------------------------------------------------------------
// Helpers
@@ -158,6 +160,56 @@ export class CallMethodStep {
}
}
+/**
+ * A class to represent a directive comment.
+ * @implements {IDirective}
+ */
+export class Directive {
+ /**
+ * The type of directive.
+ * @type {DirectiveType}
+ * @readonly
+ */
+ type;
+
+ /**
+ * The node representing the directive.
+ * @type {unknown}
+ * @readonly
+ */
+ node;
+
+ /**
+ * Everything after the "eslint-disable" portion of the directive,
+ * but before the "--" that indicates the justification.
+ * @type {string}
+ * @readonly
+ */
+ value;
+
+ /**
+ * The justification for the directive.
+ * @type {string}
+ * @readonly
+ */
+ justification;
+
+ /**
+ * Creates a new instance.
+ * @param {Object} options The options for the directive.
+ * @param {"disable"|"enable"|"disable-next-line"|"disable-line"} options.type The type of directive.
+ * @param {unknown} options.node The node representing the directive.
+ * @param {string} options.value The value of the directive.
+ * @param {string} options.justification The justification for the directive.
+ */
+ constructor({ type, node, value, justification }) {
+ this.type = type;
+ this.node = node;
+ this.value = value;
+ this.justification = justification;
+ }
+}
+
/**
* Source Code Base Object
* @implements {TextSourceCode}
diff --git a/packages/plugin-kit/tests/source-code.test.js b/packages/plugin-kit/tests/source-code.test.js
index 369f5e373..dcb908428 100644
--- a/packages/plugin-kit/tests/source-code.test.js
+++ b/packages/plugin-kit/tests/source-code.test.js
@@ -11,6 +11,7 @@ import assert from "node:assert";
import {
CallMethodStep,
VisitNodeStep,
+ Directive,
TextSourceCodeBase,
} from "../src/source-code.js";
@@ -63,6 +64,27 @@ describe("source-code", () => {
});
});
+ describe("Directive", () => {
+ it("should create a new instance", () => {
+ const type = "disable";
+ const node = { foo: "bar" };
+ const value = "baz";
+ const justification = "qux";
+
+ const directive = new Directive({
+ type,
+ node,
+ value,
+ justification,
+ });
+
+ assert.strictEqual(directive.type, type);
+ assert.strictEqual(directive.node, node);
+ assert.strictEqual(directive.value, value);
+ assert.strictEqual(directive.justification, justification);
+ });
+ });
+
describe("TextSourceCodeBase", () => {
describe("new TextSourceCodeBase", () => {
it("should create a new instance", () => {
diff --git a/release-please-config.json b/release-please-config.json
index 324ab0942..ad6fa8748 100644
--- a/release-please-config.json
+++ b/release-please-config.json
@@ -48,7 +48,6 @@
},
"packages/plugin-kit": {
"release-type": "node",
- "release-as": "0.1.0",
"extra-files": [
{
"type": "json",