feat: add rules for eslint-disable directives (#11)

### Explanation

_No response_

### Issue

_No response_

### Attestations

- [x] I have read and agree to the [Code of Conduct](https://docs.nhcarrigan.com/community/coc/)
- [x] I have read and agree to the [Community Guidelines](https://docs.nhcarrigan.com/community/guide/).
- [x] My contribution complies with the [Contributor Covenant](https://docs.nhcarrigan.com/dev/covenant/).

### Dependencies

- [x] I have pinned the dependencies to a specific patch version.

### Style

- [x] I have run the linter and resolved any errors.
- [x] My pull request uses an appropriate title, matching the conventional commit standards.
- [x] My scope of feat/fix/chore/etc. correctly matches the nature of changes in my pull request.

### Tests

- [x] My contribution adds new code, and I have added tests to cover it.
- [x] My contribution modifies existing code, and I have updated the tests to reflect these changes.
- [x] All new and existing tests pass locally with my changes.
- [x] Code coverage remains at or above the configured threshold.

### Documentation

_No response_

### Versioning

Minor - My pull request introduces a new non-breaking feature.

Reviewed-on: https://codeberg.org/nhcarrigan/eslint-config/pulls/11
Co-authored-by: Naomi Carrigan <commits@nhcarrigan.com>
Co-committed-by: Naomi Carrigan <commits@nhcarrigan.com>
This commit is contained in:
2025-01-05 21:25:03 +00:00
committed by Naomi the Technomancer
parent 75d02a9931
commit 39e29181a0
7 changed files with 65 additions and 15 deletions
+11 -9
View File
@@ -6,6 +6,7 @@
import { describe, expect, it } from "vitest";
import config from "../src/index.ts";
import { commentsRules } from "../src/rules/comments.ts";
import { deprecationRules } from "../src/rules/deprecation.ts";
import { eslintRules } from "../src/rules/eslint.ts";
import { importRules } from "../src/rules/import.ts";
@@ -39,7 +40,7 @@ expect.extend({
const pass = missingRules.length === 0 && mismatchedRules.length === 0;
let message = "";
// eslint-disable-next-line no-negated-condition
// eslint-disable-next-line no-negated-condition -- This is a test.
if (!pass) {
message = `${message}Expected rules to contain all specified rules.\n`;
if (missingRules.length > 0) {
@@ -121,13 +122,14 @@ const baseProperties = (
ruleset?.rules,
"missing typescript-eslint rules with types",
).toContainRules(typescriptEslintRulesWithTypes);
expect(ruleset?.rules, "missing comment rules").toContainRules(commentsRules);
};
// #endregion
describe("global config", () => {
// #region Typescript
it("should apply the expected plugins for typescript", () => {
expect.assertions(26);
expect.assertions(27);
const ruleset = config.find((rule) => {
return rule?.files?.includes("src/**/*.ts");
});
@@ -159,13 +161,13 @@ describe("global config", () => {
expect(
Object.keys(ruleset?.plugins ?? {}),
"should not have extraneous plugins",
).toHaveLength(7);
).toHaveLength(8);
});
// #endregion
// #region Vitest
it("should apply the expected plugins for vitest files", () => {
expect.assertions(26);
expect.assertions(27);
const ruleset = config.find((rule) => {
return rule?.files?.includes("test/**/*.spec.ts");
});
@@ -192,13 +194,13 @@ describe("global config", () => {
expect(
Object.keys(ruleset?.plugins ?? {}),
"should not have extraneous plugins",
).toHaveLength(7);
).toHaveLength(8);
});
// #endregion
// #region Playwright
it("should apply the expected plugins for playwright", () => {
expect.assertions(26);
expect.assertions(27);
const ruleset = config.find((rule) => {
return rule?.files?.includes("e2e/**/*.spec.ts");
});
@@ -228,13 +230,13 @@ describe("global config", () => {
expect(
Object.keys(ruleset?.plugins ?? {}),
"should not have extraneous plugins",
).toHaveLength(7);
).toHaveLength(8);
});
// #endregion
// #region React
it("should apply the expected plugins for react", () => {
expect.assertions(26);
expect.assertions(27);
const ruleset = config.find((rule) => {
return rule?.files?.includes("src/**/*.tsx");
});
@@ -262,7 +264,7 @@ describe("global config", () => {
expect(
Object.keys(ruleset?.plugins ?? {}),
"should not have extraneous plugins",
).toHaveLength(8);
).toHaveLength(9);
});
// #endregion
});