generated from nhcarrigan/template
feat: migrate to eslint verison 9 (#1)
This is a pretty sizeable change. It also removes all external configuration sets. Every rule is now defined by us. Additionally, this version will conflict with other formatters, and should not be used in tandem with Prettier. Reviewed-on: https://codeberg.org/nhcarrigan/eslint-config/pulls/1 Co-authored-by: Naomi Carrigan <commits@nhcarrigan.com> Co-committed-by: Naomi Carrigan <commits@nhcarrigan.com>
This commit is contained in:
46
test/eslint.spec.ts
Normal file
46
test/eslint.spec.ts
Normal file
@ -0,0 +1,46 @@
|
||||
/**
|
||||
* @copyright nhcarrigan
|
||||
* @license Naomi's Public License
|
||||
* @author Naomi Carrigan
|
||||
*/
|
||||
|
||||
import { suite, assert, test } from "vitest";
|
||||
import { disabledEslintRules, eslintRules } from "../src/rules/eslint.ts";
|
||||
|
||||
suite("ESLint Configs", () => {
|
||||
test("should not enable disabled rules", () => {
|
||||
const disabled = Object.keys(disabledEslintRules);
|
||||
const enabled = Object.keys(eslintRules);
|
||||
for (const key of disabled) {
|
||||
assert.notInclude(
|
||||
enabled,
|
||||
key,
|
||||
`Disabled rule ${key} has been re-enabled!`,
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
test("all disabled rules should be off", () => {
|
||||
const rules = Object.entries(disabledEslintRules);
|
||||
for (const [ name, rule ] of rules) {
|
||||
if (Array.isArray(rule)) {
|
||||
assert.strictEqual(
|
||||
rule.at(0),
|
||||
"off",
|
||||
`${name} appears to be turned off - this project does not use any external configs, so all rules should be off by default.`,
|
||||
);
|
||||
continue;
|
||||
}
|
||||
if (typeof rule === "string") {
|
||||
assert.strictEqual(
|
||||
rule,
|
||||
"off",
|
||||
`${name} appears to be turned off - this project does not use any external configs, so all rules should be off by default.`,
|
||||
);
|
||||
continue;
|
||||
}
|
||||
assert.fail(`Could not determine rule type for ${name}!`);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
177
test/off.spec.ts
Normal file
177
test/off.spec.ts
Normal file
@ -0,0 +1,177 @@
|
||||
/**
|
||||
* @copyright nhcarrigan
|
||||
* @license Naomi's Public License
|
||||
* @author Naomi Carrigan
|
||||
*/
|
||||
|
||||
import { suite, assert, test } from "vitest";
|
||||
import { eslintRules } from "../src/rules/eslint.ts";
|
||||
import { importRules } from "../src/rules/import.js";
|
||||
import { jsdocRules } from "../src/rules/jsdoc.js";
|
||||
import { noOnlyTestsRules } from "../src/rules/noOnlyTests.js";
|
||||
import { stylisticRules } from "../src/rules/stylistic.ts";
|
||||
import { typescriptEslintRules } from "../src/rules/typescriptEslint.js";
|
||||
import { unicornRules } from "../src/rules/unicorn.js";
|
||||
|
||||
suite("No rules should be turned off in", () => {
|
||||
test("eslint rules", () => {
|
||||
const rules = Object.entries(eslintRules);
|
||||
for (const [ name, rule ] of rules) {
|
||||
if (Array.isArray(rule)) {
|
||||
assert.notStrictEqual(
|
||||
rule.at(0),
|
||||
"off",
|
||||
`${name} appears to be turned off - this project does not use any external configs, so all rules should be off by default.`,
|
||||
);
|
||||
continue;
|
||||
}
|
||||
if (typeof rule === "string") {
|
||||
assert.notStrictEqual(
|
||||
rule,
|
||||
"off",
|
||||
`${name} appears to be turned off - this project does not use any external configs, so all rules should be off by default.`,
|
||||
);
|
||||
continue;
|
||||
}
|
||||
assert.fail(`Could not determine rule type for ${name}!`);
|
||||
}
|
||||
});
|
||||
|
||||
test("import rules", () => {
|
||||
const rules = Object.entries(importRules);
|
||||
for (const [ name, rule ] of rules) {
|
||||
if (Array.isArray(rule)) {
|
||||
assert.notStrictEqual(
|
||||
rule.at(0),
|
||||
"off",
|
||||
`${name} appears to be turned off - this project does not use any external configs, so all rules should be off by default.`,
|
||||
);
|
||||
continue;
|
||||
}
|
||||
if (typeof rule === "string") {
|
||||
assert.notStrictEqual(
|
||||
rule,
|
||||
"off",
|
||||
`${name} appears to be turned off - this project does not use any external configs, so all rules should be off by default.`,
|
||||
);
|
||||
continue;
|
||||
}
|
||||
assert.fail(`Could not determine rule type for ${name}!`);
|
||||
}
|
||||
});
|
||||
|
||||
test("jsdoc rules", () => {
|
||||
const rules = Object.entries(jsdocRules);
|
||||
for (const [ name, rule ] of rules) {
|
||||
if (Array.isArray(rule)) {
|
||||
assert.notStrictEqual(
|
||||
rule.at(0),
|
||||
"off",
|
||||
`${name} appears to be turned off - this project does not use any external configs, so all rules should be off by default.`,
|
||||
);
|
||||
continue;
|
||||
}
|
||||
if (typeof rule === "string") {
|
||||
assert.notStrictEqual(
|
||||
rule,
|
||||
"off",
|
||||
`${name} appears to be turned off - this project does not use any external configs, so all rules should be off by default.`,
|
||||
);
|
||||
continue;
|
||||
}
|
||||
assert.fail(`Could not determine rule type for ${name}!`);
|
||||
}
|
||||
});
|
||||
|
||||
test("no-only-tests rules", () => {
|
||||
const rules = Object.entries(noOnlyTestsRules);
|
||||
for (const [ name, rule ] of rules) {
|
||||
if (Array.isArray(rule)) {
|
||||
assert.notStrictEqual(
|
||||
rule.at(0),
|
||||
"off",
|
||||
`${name} appears to be turned off - this project does not use any external configs, so all rules should be off by default.`,
|
||||
);
|
||||
continue;
|
||||
}
|
||||
if (typeof rule === "string") {
|
||||
assert.notStrictEqual(
|
||||
rule,
|
||||
"off",
|
||||
`${name} appears to be turned off - this project does not use any external configs, so all rules should be off by default.`,
|
||||
);
|
||||
continue;
|
||||
}
|
||||
assert.fail(`Could not determine rule type for ${name}!`);
|
||||
}
|
||||
});
|
||||
|
||||
test("stylistic rules", () => {
|
||||
const rules = Object.entries(stylisticRules);
|
||||
for (const [ name, rule ] of rules) {
|
||||
if (Array.isArray(rule)) {
|
||||
assert.notStrictEqual(
|
||||
rule.at(0),
|
||||
"off",
|
||||
`${name} appears to be turned off - this project does not use any external configs, so all rules should be off by default.`,
|
||||
);
|
||||
continue;
|
||||
}
|
||||
if (typeof rule === "string") {
|
||||
assert.notStrictEqual(
|
||||
rule,
|
||||
"off",
|
||||
`${name} appears to be turned off - this project does not use any external configs, so all rules should be off by default.`,
|
||||
);
|
||||
continue;
|
||||
}
|
||||
assert.fail(`Could not determine rule type for ${name}!`);
|
||||
}
|
||||
});
|
||||
|
||||
test("typescript-eslint rules", () => {
|
||||
const rules = Object.entries(typescriptEslintRules);
|
||||
for (const [ name, rule ] of rules) {
|
||||
if (Array.isArray(rule)) {
|
||||
assert.notStrictEqual(
|
||||
rule.at(0),
|
||||
"off",
|
||||
`${name} appears to be turned off - this project does not use any external configs, so all rules should be off by default.`,
|
||||
);
|
||||
continue;
|
||||
}
|
||||
if (typeof rule === "string") {
|
||||
assert.notStrictEqual(
|
||||
rule,
|
||||
"off",
|
||||
`${name} appears to be turned off - this project does not use any external configs, so all rules should be off by default.`,
|
||||
);
|
||||
continue;
|
||||
}
|
||||
assert.fail(`Could not determine rule type for ${name}!`);
|
||||
}
|
||||
});
|
||||
|
||||
test("unicorn rules", () => {
|
||||
const rules = Object.entries(unicornRules);
|
||||
for (const [ name, rule ] of rules) {
|
||||
if (Array.isArray(rule)) {
|
||||
assert.notStrictEqual(
|
||||
rule.at(0),
|
||||
"off",
|
||||
`${name} appears to be turned off - this project does not use any external configs, so all rules should be off by default.`,
|
||||
);
|
||||
continue;
|
||||
}
|
||||
if (typeof rule === "string") {
|
||||
assert.notStrictEqual(
|
||||
rule,
|
||||
"off",
|
||||
`${name} appears to be turned off - this project does not use any external configs, so all rules should be off by default.`,
|
||||
);
|
||||
continue;
|
||||
}
|
||||
assert.fail(`Could not determine rule type for ${name}!`);
|
||||
}
|
||||
});
|
||||
});
|
33
test/stylistic.spec.ts
Normal file
33
test/stylistic.spec.ts
Normal file
@ -0,0 +1,33 @@
|
||||
/**
|
||||
* @copyright nhcarrigan
|
||||
* @license Naomi's Public License
|
||||
* @author Naomi Carrigan
|
||||
*/
|
||||
|
||||
import { suite, assert, test } from "vitest";
|
||||
import { stylisticRules } from "../src/rules/stylistic.ts";
|
||||
|
||||
suite("Stylistic Configs", () => {
|
||||
test("should never be an error", () => {
|
||||
const rules = Object.entries(stylisticRules);
|
||||
for (const [ name, rule ] of rules) {
|
||||
if (Array.isArray(rule)) {
|
||||
assert.include(
|
||||
[ "off", "warn" ],
|
||||
rule.at(0),
|
||||
`${name} appears to be set to an error!`,
|
||||
);
|
||||
continue;
|
||||
}
|
||||
if (typeof rule === "string") {
|
||||
assert.include(
|
||||
[ "off", "warn" ],
|
||||
rule,
|
||||
`${name} appears to be set to an error!`,
|
||||
);
|
||||
continue;
|
||||
}
|
||||
assert.fail(`Could not determine rule type for ${name}!`);
|
||||
}
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user