diff --git a/src/__snapshots__/factory.spec.ts.snap b/src/__snapshots__/factory.spec.ts.snap index 3176318..2b155a1 100644 --- a/src/__snapshots__/factory.spec.ts.snap +++ b/src/__snapshots__/factory.spec.ts.snap @@ -1921,12 +1921,18 @@ exports[`jimmyDotCodes > should create configuration w/ jest & react & testing l "rules": { "import-x/default": "error", "import-x/export": "error", + "import-x/first": "error", "import-x/named": "error", "import-x/namespace": "off", + "import-x/newline-after-import": "error", + "import-x/no-absolute-path": "error", "import-x/no-duplicates": "warn", + "import-x/no-empty-named-blocks": "error", "import-x/no-named-as-default": "warn", "import-x/no-named-as-default-member": "warn", + "import-x/no-self-import": "error", "import-x/no-unresolved": "error", + "import-x/no-useless-path-segments": "error", "node-import/prefer-node-protocol": "error", "simple-import-sort/exports": "error", "simple-import-sort/imports": "error", @@ -10041,6 +10047,16 @@ If your function does not access \`this\`, you can annotate it with \`this: void "jest-dom/prefer-to-have-value": "error", }, }, + { + "files": [ + "**/e2e/**/*.spec.?([cm])[jt]s?(x)", + "**/e2e/**/*.test.?([cm])[jt]s?(x)", + ], + "name": "jimmy.codes/jest/disabled", + "rules": { + "jest/require-hook": "off", + }, + }, { "files": [ "**/__tests__/**/*.?([cm])[jt]s?(x)", @@ -13416,12 +13432,18 @@ exports[`jimmyDotCodes > should create configuration w/ jest 1`] = ` "rules": { "import-x/default": "error", "import-x/export": "error", + "import-x/first": "error", "import-x/named": "error", "import-x/namespace": "off", + "import-x/newline-after-import": "error", + "import-x/no-absolute-path": "error", "import-x/no-duplicates": "warn", + "import-x/no-empty-named-blocks": "error", "import-x/no-named-as-default": "warn", "import-x/no-named-as-default-member": "warn", + "import-x/no-self-import": "error", "import-x/no-unresolved": "error", + "import-x/no-useless-path-segments": "error", "node-import/prefer-node-protocol": "error", "simple-import-sort/exports": "error", "simple-import-sort/imports": "error", @@ -15308,6 +15330,16 @@ If your function does not access \`this\`, you can annotate it with \`this: void "jest-dom/prefer-to-have-value": "error", }, }, + { + "files": [ + "**/e2e/**/*.spec.?([cm])[jt]s?(x)", + "**/e2e/**/*.test.?([cm])[jt]s?(x)", + ], + "name": "jimmy.codes/jest/disabled", + "rules": { + "jest/require-hook": "off", + }, + }, { "name": "jimmy.codes/disabled", "rules": { @@ -17451,12 +17483,18 @@ exports[`jimmyDotCodes > should create configuration w/ react 1`] = ` "rules": { "import-x/default": "error", "import-x/export": "error", + "import-x/first": "error", "import-x/named": "error", "import-x/namespace": "off", + "import-x/newline-after-import": "error", + "import-x/no-absolute-path": "error", "import-x/no-duplicates": "warn", + "import-x/no-empty-named-blocks": "error", "import-x/no-named-as-default": "warn", "import-x/no-named-as-default-member": "warn", + "import-x/no-self-import": "error", "import-x/no-unresolved": "error", + "import-x/no-useless-path-segments": "error", "node-import/prefer-node-protocol": "error", "simple-import-sort/exports": "error", "simple-import-sort/imports": "error", @@ -25833,12 +25871,18 @@ exports[`jimmyDotCodes > should create configuration w/ typescript 1`] = ` "rules": { "import-x/default": "error", "import-x/export": "error", + "import-x/first": "error", "import-x/named": "error", "import-x/namespace": "off", + "import-x/newline-after-import": "error", + "import-x/no-absolute-path": "error", "import-x/no-duplicates": "warn", + "import-x/no-empty-named-blocks": "error", "import-x/no-named-as-default": "warn", "import-x/no-named-as-default-member": "warn", + "import-x/no-self-import": "error", "import-x/no-unresolved": "error", + "import-x/no-useless-path-segments": "error", "node-import/prefer-node-protocol": "error", "simple-import-sort/exports": "error", "simple-import-sort/imports": "error", @@ -49226,12 +49270,18 @@ exports[`jimmyDotCodes > should create configuration w/ vitest & react & testing "rules": { "import-x/default": "error", "import-x/export": "error", + "import-x/first": "error", "import-x/named": "error", "import-x/namespace": "off", + "import-x/newline-after-import": "error", + "import-x/no-absolute-path": "error", "import-x/no-duplicates": "warn", + "import-x/no-empty-named-blocks": "error", "import-x/no-named-as-default": "warn", "import-x/no-named-as-default-member": "warn", + "import-x/no-self-import": "error", "import-x/no-unresolved": "error", + "import-x/no-useless-path-segments": "error", "node-import/prefer-node-protocol": "error", "simple-import-sort/exports": "error", "simple-import-sort/imports": "error", @@ -57346,6 +57396,16 @@ If your function does not access \`this\`, you can annotate it with \`this: void "jest-dom/prefer-to-have-value": "error", }, }, + { + "files": [ + "**/e2e/**/*.spec.?([cm])[jt]s?(x)", + "**/e2e/**/*.test.?([cm])[jt]s?(x)", + ], + "name": "jimmy.codes/vitest/disabled", + "rules": { + "jest/require-hook": "off", + }, + }, { "files": [ "**/__tests__/**/*.?([cm])[jt]s?(x)", @@ -60721,12 +60781,18 @@ exports[`jimmyDotCodes > should create configuration w/ vitest 1`] = ` "rules": { "import-x/default": "error", "import-x/export": "error", + "import-x/first": "error", "import-x/named": "error", "import-x/namespace": "off", + "import-x/newline-after-import": "error", + "import-x/no-absolute-path": "error", "import-x/no-duplicates": "warn", + "import-x/no-empty-named-blocks": "error", "import-x/no-named-as-default": "warn", "import-x/no-named-as-default-member": "warn", + "import-x/no-self-import": "error", "import-x/no-unresolved": "error", + "import-x/no-useless-path-segments": "error", "node-import/prefer-node-protocol": "error", "simple-import-sort/exports": "error", "simple-import-sort/imports": "error", @@ -62613,6 +62679,16 @@ If your function does not access \`this\`, you can annotate it with \`this: void "jest-dom/prefer-to-have-value": "error", }, }, + { + "files": [ + "**/e2e/**/*.spec.?([cm])[jt]s?(x)", + "**/e2e/**/*.test.?([cm])[jt]s?(x)", + ], + "name": "jimmy.codes/vitest/disabled", + "rules": { + "jest/require-hook": "off", + }, + }, { "name": "jimmy.codes/disabled", "rules": { @@ -65053,12 +65129,18 @@ exports[`jimmyDotCodes > should create default configuration 1`] = ` "rules": { "import-x/default": "error", "import-x/export": "error", + "import-x/first": "error", "import-x/named": "error", "import-x/namespace": "off", + "import-x/newline-after-import": "error", + "import-x/no-absolute-path": "error", "import-x/no-duplicates": "warn", + "import-x/no-empty-named-blocks": "error", "import-x/no-named-as-default": "warn", "import-x/no-named-as-default-member": "warn", + "import-x/no-self-import": "error", "import-x/no-unresolved": "error", + "import-x/no-useless-path-segments": "error", "node-import/prefer-node-protocol": "error", "simple-import-sort/exports": "error", "simple-import-sort/imports": "error", diff --git a/src/__snapshots__/index.spec.ts.snap b/src/__snapshots__/index.spec.ts.snap index d86c43f..66f188c 100644 --- a/src/__snapshots__/index.spec.ts.snap +++ b/src/__snapshots__/index.spec.ts.snap @@ -1921,12 +1921,18 @@ exports[`should create default configuration 1`] = ` "rules": { "import-x/default": "error", "import-x/export": "error", + "import-x/first": "error", "import-x/named": "error", "import-x/namespace": "off", + "import-x/newline-after-import": "error", + "import-x/no-absolute-path": "error", "import-x/no-duplicates": "warn", + "import-x/no-empty-named-blocks": "error", "import-x/no-named-as-default": "warn", "import-x/no-named-as-default-member": "warn", + "import-x/no-self-import": "error", "import-x/no-unresolved": "error", + "import-x/no-useless-path-segments": "error", "node-import/prefer-node-protocol": "error", "simple-import-sort/exports": "error", "simple-import-sort/imports": "error", diff --git a/src/configs/imports.ts b/src/configs/imports.ts index bec13c2..2d00968 100644 --- a/src/configs/imports.ts +++ b/src/configs/imports.ts @@ -2,6 +2,8 @@ import importX from "eslint-plugin-import-x"; import nodeImport from "eslint-plugin-node-import"; import simpleImportSort from "eslint-plugin-simple-import-sort"; +import { importsRules } from "../rules/imports"; + const typescriptImports = { name: "jimmy.codes/imports/typescript", settings: { @@ -27,14 +29,7 @@ const importsConfig = ({ typescript = false }: ImportsConfigOptions = {}) => { "simple-import-sort": simpleImportSort, "node-import": nodeImport, }, - rules: { - ...importX.configs.recommended.rules, - // ! can't get this rule to work - "import-x/namespace": "off", - "simple-import-sort/imports": "error", - "simple-import-sort/exports": "error", - "node-import/prefer-node-protocol": "error", - }, + rules: importsRules, }, ...(typescript ? [typescriptImports] : []), ]; diff --git a/src/configs/jest.ts b/src/configs/jest.ts index 13538bd..4ab72b3 100644 --- a/src/configs/jest.ts +++ b/src/configs/jest.ts @@ -1,7 +1,7 @@ import jest from "eslint-plugin-jest"; import * as jestDom from "eslint-plugin-jest-dom"; -import { GLOB_TESTS } from "../constants"; +import { GLOB_E2E, GLOB_TESTS } from "../constants"; import { jestRules } from "../rules/jest"; import testingLibraryConfig from "./testing-library"; @@ -26,6 +26,13 @@ const jestConfig = ({ files: GLOB_TESTS, ...jestDom.configs["flat/recommended"], }, + { + name: "jimmy.codes/jest/disabled", + files: GLOB_E2E, + rules: { + "jest/require-hook": "off", + }, + }, ...(testingLibrary && react ? testingLibraryConfig() : []), ]; }; diff --git a/src/configs/vitest.ts b/src/configs/vitest.ts index 1688879..c861580 100644 --- a/src/configs/vitest.ts +++ b/src/configs/vitest.ts @@ -1,7 +1,7 @@ import jest from "eslint-plugin-jest"; import * as jestDom from "eslint-plugin-jest-dom"; -import { GLOB_TESTS } from "../constants"; +import { GLOB_E2E, GLOB_TESTS } from "../constants"; import { jestRules } from "../rules/jest"; import testingLibraryConfig from "./testing-library"; @@ -29,6 +29,13 @@ const vitestConfig = ({ files: GLOB_TESTS, ...jestDom.configs["flat/recommended"], }, + { + name: "jimmy.codes/vitest/disabled", + files: GLOB_E2E, + rules: { + "jest/require-hook": "off", + }, + }, ...(testingLibrary && react ? testingLibraryConfig() : []), ]; }; diff --git a/src/rules/__snapshots__/imports.spec.ts.snap b/src/rules/__snapshots__/imports.spec.ts.snap new file mode 100644 index 0000000..0cf3006 --- /dev/null +++ b/src/rules/__snapshots__/imports.spec.ts.snap @@ -0,0 +1,23 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`should create imports rules 1`] = ` +{ + "import-x/default": "error", + "import-x/export": "error", + "import-x/first": "error", + "import-x/named": "error", + "import-x/namespace": "off", + "import-x/newline-after-import": "error", + "import-x/no-absolute-path": "error", + "import-x/no-duplicates": "warn", + "import-x/no-empty-named-blocks": "error", + "import-x/no-named-as-default": "warn", + "import-x/no-named-as-default-member": "warn", + "import-x/no-self-import": "error", + "import-x/no-unresolved": "error", + "import-x/no-useless-path-segments": "error", + "node-import/prefer-node-protocol": "error", + "simple-import-sort/exports": "error", + "simple-import-sort/imports": "error", +} +`; diff --git a/src/rules/imports.spec.ts b/src/rules/imports.spec.ts new file mode 100644 index 0000000..1a2dc85 --- /dev/null +++ b/src/rules/imports.spec.ts @@ -0,0 +1,5 @@ +import { importsRules } from "./imports"; + +test("should create imports rules", () => { + expect(importsRules).toMatchSnapshot(); +}); diff --git a/src/rules/imports.ts b/src/rules/imports.ts new file mode 100644 index 0000000..89aa5f6 --- /dev/null +++ b/src/rules/imports.ts @@ -0,0 +1,17 @@ +import { type Linter } from "eslint"; +import importX from "eslint-plugin-import-x"; + +export const importsRules = { + ...importX.configs.recommended.rules, + // ! can't get this rule to work + "import-x/namespace": "off", + "import-x/newline-after-import": "error", + "import-x/first": "error", + "import-x/no-absolute-path": "error", + "import-x/no-useless-path-segments": "error", + "import-x/no-empty-named-blocks": "error", + "import-x/no-self-import": "error", + "simple-import-sort/imports": "error", + "simple-import-sort/exports": "error", + "node-import/prefer-node-protocol": "error", +} satisfies Linter.RulesRecord;