From 7a43051ff0a63852a550e82f9b081b9a64823f66 Mon Sep 17 00:00:00 2001 From: jimmy-guzman Date: Thu, 7 Nov 2024 17:51:36 -0600 Subject: [PATCH 1/9] =?UTF-8?q?feat:=20=E2=9C=A8=20rename=20`base`=20confi?= =?UTF-8?q?g=20to=20`javascript`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/configs/javascript.ts | 15 ++++ src/factory.spec.ts | 2 +- src/factory.ts | 10 +-- .../__snapshots__/javascript.spec.ts.snap | 85 +++++++++++++++++++ src/rules/base.spec.ts | 5 -- src/rules/javascript.spec.ts | 5 ++ src/rules/{base.ts => javascript.ts} | 2 +- 7 files changed, 109 insertions(+), 15 deletions(-) create mode 100644 src/configs/javascript.ts create mode 100644 src/rules/__snapshots__/javascript.spec.ts.snap delete mode 100644 src/rules/base.spec.ts create mode 100644 src/rules/javascript.spec.ts rename src/rules/{base.ts => javascript.ts} (92%) diff --git a/src/configs/javascript.ts b/src/configs/javascript.ts new file mode 100644 index 0000000..3610bca --- /dev/null +++ b/src/configs/javascript.ts @@ -0,0 +1,15 @@ +import type { Linter } from "eslint"; + +import { javascriptRules } from "../rules/javascript"; + +export const javascriptConfig = () => { + return [ + { + linterOptions: { + reportUnusedDisableDirectives: true, + }, + name: "jimmy.codes/javascript", + rules: javascriptRules, + }, + ] satisfies Linter.Config[]; +}; diff --git a/src/factory.spec.ts b/src/factory.spec.ts index ec45789..154a0c9 100644 --- a/src/factory.spec.ts +++ b/src/factory.spec.ts @@ -14,7 +14,7 @@ describe("jimmyDotCodes", () => { "eslint-comments", "prettier", "ignores", - "base", + "javascript", ])("should create configuration w/ %s", (input) => { expect(jimmyDotCodes({ autoDetect: false })).toStrictEqual( expect.arrayContaining([ diff --git a/src/factory.ts b/src/factory.ts index 3ba08c7..2f6bcaa 100644 --- a/src/factory.ts +++ b/src/factory.ts @@ -8,6 +8,7 @@ import { astroConfig } from "./configs/astro"; import { commonjsConfig } from "./configs/commonjs"; import eslintCommentsConfig from "./configs/eslint-comments"; import importsConfig from "./configs/imports"; +import { javascriptConfig } from "./configs/javascript"; import nodeConfig from "./configs/node"; import perfectionistConfig from "./configs/perfectionist"; import reactConfig from "./configs/react"; @@ -16,7 +17,6 @@ import typescriptConfig from "./configs/typescript"; import unicornConfig from "./configs/unicorn"; import { GLOB_IGNORES } from "./constants"; import { hasAstro, hasReact, hasTesting, hasTypescript } from "./has-dep"; -import { baseRules } from "./rules/base"; import { getReactOptions, getTestingOptions, @@ -41,13 +41,7 @@ export const jimmyDotCodes = ( const isAstroEnabled = astro || (autoDetect && hasAstro()); return [ - { - linterOptions: { - reportUnusedDisableDirectives: true, - }, - name: "jimmy.codes/base", - rules: baseRules, - }, + ...javascriptConfig(), ...perfectionistConfig(), ...nodeConfig(), ...unicornConfig(), diff --git a/src/rules/__snapshots__/javascript.spec.ts.snap b/src/rules/__snapshots__/javascript.spec.ts.snap new file mode 100644 index 0000000..947c173 --- /dev/null +++ b/src/rules/__snapshots__/javascript.spec.ts.snap @@ -0,0 +1,85 @@ +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html + +exports[`should create javascript rules 1`] = ` +{ + "array-callback-return": [ + "error", + { + "allowImplicit": true, + }, + ], + "arrow-body-style": [ + "error", + "always", + ], + "constructor-super": "error", + "curly": [ + "error", + "all", + ], + "for-direction": "error", + "getter-return": "error", + "no-async-promise-executor": "error", + "no-case-declarations": "error", + "no-class-assign": "error", + "no-compare-neg-zero": "error", + "no-cond-assign": "error", + "no-console": "warn", + "no-const-assign": "error", + "no-constant-binary-expression": "error", + "no-constant-condition": "error", + "no-control-regex": "error", + "no-debugger": "error", + "no-delete-var": "error", + "no-dupe-args": "error", + "no-dupe-class-members": "error", + "no-dupe-else-if": "error", + "no-dupe-keys": "error", + "no-duplicate-case": "error", + "no-empty": "error", + "no-empty-character-class": "error", + "no-empty-pattern": "error", + "no-empty-static-block": "error", + "no-ex-assign": "error", + "no-extra-boolean-cast": "error", + "no-fallthrough": "error", + "no-func-assign": "error", + "no-global-assign": "error", + "no-import-assign": "error", + "no-invalid-regexp": "error", + "no-irregular-whitespace": "error", + "no-loss-of-precision": "error", + "no-misleading-character-class": "error", + "no-new-native-nonconstructor": "error", + "no-nonoctal-decimal-escape": "error", + "no-obj-calls": "error", + "no-octal": "error", + "no-prototype-builtins": "error", + "no-redeclare": "error", + "no-regex-spaces": "error", + "no-self-assign": "error", + "no-setter-return": "error", + "no-shadow-restricted-names": "error", + "no-sparse-arrays": "error", + "no-this-before-super": "error", + "no-undef": "error", + "no-unexpected-multiline": "error", + "no-unreachable": "error", + "no-unsafe-finally": "error", + "no-unsafe-negation": "error", + "no-unsafe-optional-chaining": "error", + "no-unused-labels": "error", + "no-unused-private-class-members": "error", + "no-unused-vars": "error", + "no-useless-backreference": "error", + "no-useless-catch": "error", + "no-useless-escape": "error", + "no-useless-rename": "error", + "no-with": "error", + "object-shorthand": "error", + "prefer-arrow-callback": "error", + "require-yield": "error", + "use-isnan": "error", + "valid-typeof": "error", +} +`; diff --git a/src/rules/base.spec.ts b/src/rules/base.spec.ts deleted file mode 100644 index 6f0b10a..0000000 --- a/src/rules/base.spec.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { baseRules } from "./base"; - -test("should create base rules", () => { - expect(baseRules).toMatchSnapshot(); -}); diff --git a/src/rules/javascript.spec.ts b/src/rules/javascript.spec.ts new file mode 100644 index 0000000..5351975 --- /dev/null +++ b/src/rules/javascript.spec.ts @@ -0,0 +1,5 @@ +import { javascriptRules } from "./javascript"; + +test("should create javascript rules", () => { + expect(javascriptRules).toMatchSnapshot(); +}); diff --git a/src/rules/base.ts b/src/rules/javascript.ts similarity index 92% rename from src/rules/base.ts rename to src/rules/javascript.ts index 22f13d5..8aa6b8a 100644 --- a/src/rules/base.ts +++ b/src/rules/javascript.ts @@ -2,7 +2,7 @@ import eslint from "@eslint/js"; import type { Rules } from "../types"; -export const baseRules = { +export const javascriptRules = { ...eslint.configs.recommended.rules, "array-callback-return": [ "error", From 7590e54326f186c48d57db8681345396e343477d Mon Sep 17 00:00:00 2001 From: jimmy-guzman Date: Thu, 7 Nov 2024 17:55:38 -0600 Subject: [PATCH 2/9] =?UTF-8?q?refactor:=20=E2=99=BB=EF=B8=8F=20use=20name?= =?UTF-8?q?d=20exports=20for=20all=20configs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/configs/eslint-comments.ts | 4 +--- src/configs/imports.spec.ts | 2 +- src/configs/imports.ts | 6 +++--- src/configs/node.ts | 4 +--- src/configs/perfectionist.ts | 4 +--- src/configs/react.spec.ts | 2 +- src/configs/react.ts | 4 +--- src/configs/testing.spec.ts | 2 +- src/configs/testing.ts | 4 +--- src/configs/typescript.spec.ts | 2 +- src/configs/typescript.ts | 4 +--- src/configs/unicorn.ts | 4 +--- src/factory.ts | 16 ++++++++-------- 13 files changed, 22 insertions(+), 36 deletions(-) diff --git a/src/configs/eslint-comments.ts b/src/configs/eslint-comments.ts index e796024..adbd652 100644 --- a/src/configs/eslint-comments.ts +++ b/src/configs/eslint-comments.ts @@ -2,7 +2,7 @@ import comments from "@eslint-community/eslint-plugin-eslint-comments/configs"; import { eslintCommentsRules } from "../rules/eslint-comments"; -const eslintCommentsConfig = () => { +export const eslintCommentsConfig = () => { return [ { ...comments.recommended, @@ -11,5 +11,3 @@ const eslintCommentsConfig = () => { }, ]; }; - -export default eslintCommentsConfig; diff --git a/src/configs/imports.spec.ts b/src/configs/imports.spec.ts index 58e24bf..ae25528 100644 --- a/src/configs/imports.spec.ts +++ b/src/configs/imports.spec.ts @@ -1,4 +1,4 @@ -import importsConfig from "./imports"; +import { importsConfig } from "./imports"; describe("importsConfig", () => { it("should create config w/ flat config parsing fixes", () => { diff --git a/src/configs/imports.ts b/src/configs/imports.ts index 8dd8676..3ec2a04 100644 --- a/src/configs/imports.ts +++ b/src/configs/imports.ts @@ -23,7 +23,9 @@ interface ImportsConfigOptions { typescript?: boolean | TypescriptOptions; } -const importsConfig = ({ typescript = false }: ImportsConfigOptions = {}) => { +export const importsConfig = ({ + typescript = false, +}: ImportsConfigOptions = {}) => { return [ { languageOptions: { @@ -49,5 +51,3 @@ const importsConfig = ({ typescript = false }: ImportsConfigOptions = {}) => { ...(typescript ? [typescriptImports] : []), ] satisfies Linter.Config[]; }; - -export default importsConfig; diff --git a/src/configs/node.ts b/src/configs/node.ts index 432615e..475767b 100644 --- a/src/configs/node.ts +++ b/src/configs/node.ts @@ -4,7 +4,7 @@ import nodePlugin from "eslint-plugin-n"; import { nodeRules } from "../rules/node"; -const nodeConfig = () => { +export const nodeConfig = () => { return [ { name: "jimmy.codes/node", @@ -15,5 +15,3 @@ const nodeConfig = () => { }, ] satisfies Linter.Config[]; }; - -export default nodeConfig; diff --git a/src/configs/perfectionist.ts b/src/configs/perfectionist.ts index 851112e..b6de68e 100644 --- a/src/configs/perfectionist.ts +++ b/src/configs/perfectionist.ts @@ -6,7 +6,7 @@ import type { TypedConfigItem } from "../types"; import { perfectionistRules } from "../rules/perfectionist"; -const perfectionistConfig = () => { +export const perfectionistConfig = () => { return [ { name: "jimmy.codes/perfectionist", @@ -18,5 +18,3 @@ const perfectionistConfig = () => { }, ] satisfies TypedConfigItem[]; }; - -export default perfectionistConfig; diff --git a/src/configs/react.spec.ts b/src/configs/react.spec.ts index fb7a5cb..5e45595 100644 --- a/src/configs/react.spec.ts +++ b/src/configs/react.spec.ts @@ -1,4 +1,4 @@ -import reactConfig from "./react"; +import { reactConfig } from "./react"; describe("reactConfig", () => { it("should create config w/ @tanstack/query rules", () => { diff --git a/src/configs/react.ts b/src/configs/react.ts index 7a278bf..e3125d8 100644 --- a/src/configs/react.ts +++ b/src/configs/react.ts @@ -13,7 +13,7 @@ import { GLOB_JSX, GLOB_TSX } from "../constants"; import { hasReactQuery } from "../has-dep"; import { reactRules } from "../rules/react"; -const reactConfig = ( +export const reactConfig = ( { utilities = [] }: ReactOptions = {}, autoDetect = true, ) => { @@ -67,5 +67,3 @@ const reactConfig = ( : []), ] satisfies TypedConfigItem[]; }; - -export default reactConfig; diff --git a/src/configs/testing.spec.ts b/src/configs/testing.spec.ts index 9ff8e70..81595ff 100644 --- a/src/configs/testing.spec.ts +++ b/src/configs/testing.spec.ts @@ -1,5 +1,5 @@ import { ALLOWED_VITEST_FUNCS } from "../constants"; -import testingConfig from "./testing"; +import { testingConfig } from "./testing"; describe("testingConfig", () => { it("should create default config w/ vitest overrides", () => { diff --git a/src/configs/testing.ts b/src/configs/testing.ts index 916d661..c3333af 100644 --- a/src/configs/testing.ts +++ b/src/configs/testing.ts @@ -7,7 +7,7 @@ import { hasJest, hasTestingLibrary, hasVitest } from "../has-dep"; import { jestRules } from "../rules/jest"; import testingLibraryConfig from "./testing-library"; -const testingConfig = ( +export const testingConfig = ( { framework = "vitest", utilities }: TestingOptions = {}, autoDetect = true, ) => { @@ -64,5 +64,3 @@ const testingConfig = ( ...(includeTestingLibrary ? testingLibraryConfig() : []), ]; }; - -export default testingConfig; diff --git a/src/configs/typescript.spec.ts b/src/configs/typescript.spec.ts index c06fa68..251a0ae 100644 --- a/src/configs/typescript.spec.ts +++ b/src/configs/typescript.spec.ts @@ -1,4 +1,4 @@ -import typescriptConfig from "./typescript"; +import { typescriptConfig } from "./typescript"; describe("typescriptConfig", () => { it("should create config", () => { diff --git a/src/configs/typescript.ts b/src/configs/typescript.ts index cc0d254..9480a3b 100644 --- a/src/configs/typescript.ts +++ b/src/configs/typescript.ts @@ -4,7 +4,7 @@ import type { TypescriptOptions } from "../types"; import { GLOB_JS, GLOB_JSX, GLOB_TESTS } from "../constants"; -const typescriptConfig = (options: TypescriptOptions) => { +export const typescriptConfig = (options: TypescriptOptions) => { return config( ...configs.strictTypeChecked, ...configs.stylisticTypeChecked.filter((config) => { @@ -52,5 +52,3 @@ const typescriptConfig = (options: TypescriptOptions) => { }, ); }; - -export default typescriptConfig; diff --git a/src/configs/unicorn.ts b/src/configs/unicorn.ts index aa9b820..aa3bfac 100644 --- a/src/configs/unicorn.ts +++ b/src/configs/unicorn.ts @@ -4,7 +4,7 @@ import type { TypedConfigItem } from "../types"; import { unicornRules } from "../rules/unicorn"; -const unicornConfig = () => { +export const unicornConfig = () => { return [ { ...eslintPluginUnicorn.configs["flat/recommended"], @@ -13,5 +13,3 @@ const unicornConfig = () => { }, ] satisfies TypedConfigItem[]; }; - -export default unicornConfig; diff --git a/src/factory.ts b/src/factory.ts index 2f6bcaa..add969e 100644 --- a/src/factory.ts +++ b/src/factory.ts @@ -6,15 +6,15 @@ import type { Options, TypedConfigItem } from "./types"; import { astroConfig } from "./configs/astro"; import { commonjsConfig } from "./configs/commonjs"; -import eslintCommentsConfig from "./configs/eslint-comments"; -import importsConfig from "./configs/imports"; +import { eslintCommentsConfig } from "./configs/eslint-comments"; +import { importsConfig } from "./configs/imports"; import { javascriptConfig } from "./configs/javascript"; -import nodeConfig from "./configs/node"; -import perfectionistConfig from "./configs/perfectionist"; -import reactConfig from "./configs/react"; -import testingConfig from "./configs/testing"; -import typescriptConfig from "./configs/typescript"; -import unicornConfig from "./configs/unicorn"; +import { nodeConfig } from "./configs/node"; +import { perfectionistConfig } from "./configs/perfectionist"; +import { reactConfig } from "./configs/react"; +import { testingConfig } from "./configs/testing"; +import { typescriptConfig } from "./configs/typescript"; +import { unicornConfig } from "./configs/unicorn"; import { GLOB_IGNORES } from "./constants"; import { hasAstro, hasReact, hasTesting, hasTypescript } from "./has-dep"; import { From a2461212a67de3a384a5541722a726a4f730672b Mon Sep 17 00:00:00 2001 From: jimmy-guzman Date: Thu, 7 Nov 2024 18:15:58 -0600 Subject: [PATCH 3/9] =?UTF-8?q?refactor:=20=E2=99=BB=EF=B8=8F=20remove=20u?= =?UTF-8?q?nneeded=20config=20from=20typescript-eslint?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/configs/typescript.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/configs/typescript.ts b/src/configs/typescript.ts index 9480a3b..2e981e4 100644 --- a/src/configs/typescript.ts +++ b/src/configs/typescript.ts @@ -1,11 +1,11 @@ -import { config, configs } from "typescript-eslint"; +import { configs } from "typescript-eslint"; import type { TypescriptOptions } from "../types"; import { GLOB_JS, GLOB_JSX, GLOB_TESTS } from "../constants"; export const typescriptConfig = (options: TypescriptOptions) => { - return config( + return [ ...configs.strictTypeChecked, ...configs.stylisticTypeChecked.filter((config) => { return config.name === "typescript-eslint/stylistic-type-checked"; @@ -50,5 +50,5 @@ export const typescriptConfig = (options: TypescriptOptions) => { "@typescript-eslint/no-unsafe-assignment": "off", }, }, - ); + ]; }; From 8c6e258801ffe6a0dbde1f53be4202637a301d62 Mon Sep 17 00:00:00 2001 From: jimmy-guzman Date: Thu, 7 Nov 2024 18:33:01 -0600 Subject: [PATCH 4/9] =?UTF-8?q?refactor:=20=E2=99=BB=EF=B8=8F=20just=20fla?= =?UTF-8?q?tten=20once=20instead=20of=20spreading=20each=20config?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/configs/astro.ts | 10 +++++++-- src/configs/ignores.ts | 12 ++++++++++ src/configs/prettier.ts | 9 ++++++++ src/factory.ts | 50 ++++++++++++++++------------------------- src/utils.spec.ts | 18 ++++++--------- src/utils.ts | 6 ++--- 6 files changed, 58 insertions(+), 47 deletions(-) create mode 100644 src/configs/ignores.ts create mode 100644 src/configs/prettier.ts diff --git a/src/configs/astro.ts b/src/configs/astro.ts index 2622094..1e775fb 100644 --- a/src/configs/astro.ts +++ b/src/configs/astro.ts @@ -4,6 +4,8 @@ import jsxA11y from "eslint-plugin-jsx-a11y"; import globals from "globals"; import { configs, parser as parserTs } from "typescript-eslint"; +import type { TypedConfigItem } from "../types"; + import { GLOB_ASTRO } from "../constants"; export const astroConfig = () => { @@ -46,8 +48,12 @@ export const astroConfig = () => { }, { files, - ...configs.disableTypeChecked, + languageOptions: { + parserOptions: + configs.disableTypeChecked.languageOptions?.parserOptions, + }, name: "jimmy.codes/astro/disable-type-checked", + rules: configs.disableTypeChecked.rules, }, { name: "jimmy.codes/astro/imports", @@ -55,5 +61,5 @@ export const astroConfig = () => { "import-x/core-modules": ["astro:content"], }, }, - ]; + ] satisfies TypedConfigItem[]; }; diff --git a/src/configs/ignores.ts b/src/configs/ignores.ts new file mode 100644 index 0000000..9aca56f --- /dev/null +++ b/src/configs/ignores.ts @@ -0,0 +1,12 @@ +import type { TypedConfigItem } from "../types"; + +import { GLOB_IGNORES } from "../constants"; + +export const ignoresConfig = (ignores: string[]) => { + return [ + { + ignores: [...GLOB_IGNORES, ...ignores], + name: "jimmy.codes/ignores", + }, + ] satisfies TypedConfigItem[]; +}; diff --git a/src/configs/prettier.ts b/src/configs/prettier.ts new file mode 100644 index 0000000..f309040 --- /dev/null +++ b/src/configs/prettier.ts @@ -0,0 +1,9 @@ +import eslintConfigPrettier from "eslint-config-prettier"; + +import type { TypedConfigItem } from "../types"; + +export const prettierConfig = () => { + return [ + { name: "jimmy.codes/prettier", ...eslintConfigPrettier }, + ] satisfies TypedConfigItem[]; +}; diff --git a/src/factory.ts b/src/factory.ts index add969e..42964f7 100644 --- a/src/factory.ts +++ b/src/factory.ts @@ -1,27 +1,22 @@ import type { Linter } from "eslint"; -import eslintConfigPrettier from "eslint-config-prettier"; - import type { Options, TypedConfigItem } from "./types"; import { astroConfig } from "./configs/astro"; import { commonjsConfig } from "./configs/commonjs"; import { eslintCommentsConfig } from "./configs/eslint-comments"; +import { ignoresConfig } from "./configs/ignores"; import { importsConfig } from "./configs/imports"; import { javascriptConfig } from "./configs/javascript"; import { nodeConfig } from "./configs/node"; import { perfectionistConfig } from "./configs/perfectionist"; +import { prettierConfig } from "./configs/prettier"; import { reactConfig } from "./configs/react"; import { testingConfig } from "./configs/testing"; import { typescriptConfig } from "./configs/typescript"; import { unicornConfig } from "./configs/unicorn"; -import { GLOB_IGNORES } from "./constants"; import { hasAstro, hasReact, hasTesting, hasTypescript } from "./has-dep"; -import { - getReactOptions, - getTestingOptions, - getTypescriptOptions, -} from "./utils"; +import { reactOptions, testingOptions, typescriptOptions } from "./utils"; export const jimmyDotCodes = ( { @@ -41,27 +36,20 @@ export const jimmyDotCodes = ( const isAstroEnabled = astro || (autoDetect && hasAstro()); return [ - ...javascriptConfig(), - ...perfectionistConfig(), - ...nodeConfig(), - ...unicornConfig(), - ...eslintCommentsConfig(), - ...importsConfig({ typescript: isTypescriptEnabled }), - ...(isTypescriptEnabled - ? typescriptConfig(getTypescriptOptions(typescript)) - : []), - ...(isReactEnabled ? reactConfig(getReactOptions(react), autoDetect) : []), - ...(isAstroEnabled ? astroConfig() : []), - ...(isTestingEnabled - ? testingConfig(getTestingOptions(testing), autoDetect) - : []), - { name: "jimmy.codes/prettier", ...eslintConfigPrettier }, - ...commonjsConfig(), - { - ignores: [...GLOB_IGNORES, ...ignores], - name: "jimmy.codes/ignores", - }, - ...configs, - ...moreConfigs, - ]; + javascriptConfig(), + perfectionistConfig(), + nodeConfig(), + unicornConfig(), + eslintCommentsConfig(), + importsConfig({ typescript: isTypescriptEnabled }), + isTypescriptEnabled ? typescriptConfig(typescriptOptions(typescript)) : [], + isReactEnabled ? reactConfig(reactOptions(react), autoDetect) : [], + isAstroEnabled ? astroConfig() : [], + isTestingEnabled ? testingConfig(testingOptions(testing), autoDetect) : [], + prettierConfig(), + commonjsConfig(), + ignoresConfig(ignores), + configs, + moreConfigs, + ].flat(); }; diff --git a/src/utils.spec.ts b/src/utils.spec.ts index 8c38d77..3dfbf0a 100644 --- a/src/utils.spec.ts +++ b/src/utils.spec.ts @@ -1,18 +1,14 @@ -import { - getReactOptions, - getTestingOptions, - getTypescriptOptions, -} from "./utils"; +import { reactOptions, testingOptions, typescriptOptions } from "./utils"; describe("getTypescriptOptions", () => { it("should return default options when a boolean is provided", () => { - expect(getTypescriptOptions(true)).toStrictEqual({ + expect(typescriptOptions(true)).toStrictEqual({ project: "./tsconfig.json", }); }); it("should return override options when an object is provided", () => { expect( - getTypescriptOptions({ + typescriptOptions({ project: "./tsconfig.eslint.json", }), ).toStrictEqual({ @@ -23,13 +19,13 @@ describe("getTypescriptOptions", () => { describe("getTestingOptions", () => { it("should return default options when a boolean is provided", () => { - expect(getTestingOptions(true)).toStrictEqual({ + expect(testingOptions(true)).toStrictEqual({ framework: "vitest", }); }); it("should return override options when an object is provided", () => { expect( - getTestingOptions({ + testingOptions({ framework: "jest", utilities: ["testing-library"], }), @@ -42,11 +38,11 @@ describe("getTestingOptions", () => { describe("getReactOptions", () => { it("should return default options when a boolean is provided", () => { - expect(getReactOptions(true)).toStrictEqual({ utilities: [] }); + expect(reactOptions(true)).toStrictEqual({ utilities: [] }); }); it("should return override options when an object is provided", () => { expect( - getReactOptions({ + reactOptions({ utilities: ["@tanstack/query"], }), ).toStrictEqual({ diff --git a/src/utils.ts b/src/utils.ts index 1145112..33c7002 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1,6 +1,6 @@ import type { ReactOptions, TestingOptions, TypescriptOptions } from "./types"; -export const getTypescriptOptions = (options: boolean | TypescriptOptions) => { +export const typescriptOptions = (options: boolean | TypescriptOptions) => { return typeof options === "object" ? options : { @@ -8,7 +8,7 @@ export const getTypescriptOptions = (options: boolean | TypescriptOptions) => { }; }; -export const getTestingOptions = (options: boolean | TestingOptions) => { +export const testingOptions = (options: boolean | TestingOptions) => { return typeof options === "object" ? options : { @@ -16,6 +16,6 @@ export const getTestingOptions = (options: boolean | TestingOptions) => { }; }; -export const getReactOptions = (options: boolean | ReactOptions) => { +export const reactOptions = (options: boolean | ReactOptions) => { return typeof options === "object" ? options : { utilities: [] }; }; From 645d853928ec489877de75f92d7c8d0676c49c81 Mon Sep 17 00:00:00 2001 From: jimmy-guzman Date: Thu, 7 Nov 2024 18:40:54 -0600 Subject: [PATCH 5/9] =?UTF-8?q?feat:=20=E2=9C=A8=20enable=20`no-self-compa?= =?UTF-8?q?re`=20rule?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/rules/__snapshots__/javascript.spec.ts.snap | 1 + src/rules/javascript.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/src/rules/__snapshots__/javascript.spec.ts.snap b/src/rules/__snapshots__/javascript.spec.ts.snap index 947c173..5568271 100644 --- a/src/rules/__snapshots__/javascript.spec.ts.snap +++ b/src/rules/__snapshots__/javascript.spec.ts.snap @@ -58,6 +58,7 @@ exports[`should create javascript rules 1`] = ` "no-redeclare": "error", "no-regex-spaces": "error", "no-self-assign": "error", + "no-self-compare": "error", "no-setter-return": "error", "no-shadow-restricted-names": "error", "no-sparse-arrays": "error", diff --git a/src/rules/javascript.ts b/src/rules/javascript.ts index 8aa6b8a..e8be33c 100644 --- a/src/rules/javascript.ts +++ b/src/rules/javascript.ts @@ -13,6 +13,7 @@ export const javascriptRules = { "arrow-body-style": ["error", "always"], "curly": ["error", "all"], "no-console": "warn", + "no-self-compare": "error", "no-useless-rename": "error", "object-shorthand": "error", "prefer-arrow-callback": "error", From 63f74787ea04c516cee22013227839bac6395062 Mon Sep 17 00:00:00 2001 From: jimmy-guzman Date: Thu, 7 Nov 2024 18:41:34 -0600 Subject: [PATCH 6/9] =?UTF-8?q?feat:=20=E2=9C=A8=20enable=20`no-template-c?= =?UTF-8?q?urly-in-string`=20rule?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/rules/__snapshots__/javascript.spec.ts.snap | 1 + src/rules/javascript.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/src/rules/__snapshots__/javascript.spec.ts.snap b/src/rules/__snapshots__/javascript.spec.ts.snap index 5568271..558b50d 100644 --- a/src/rules/__snapshots__/javascript.spec.ts.snap +++ b/src/rules/__snapshots__/javascript.spec.ts.snap @@ -62,6 +62,7 @@ exports[`should create javascript rules 1`] = ` "no-setter-return": "error", "no-shadow-restricted-names": "error", "no-sparse-arrays": "error", + "no-template-curly-in-string": "error", "no-this-before-super": "error", "no-undef": "error", "no-unexpected-multiline": "error", diff --git a/src/rules/javascript.ts b/src/rules/javascript.ts index e8be33c..2c593da 100644 --- a/src/rules/javascript.ts +++ b/src/rules/javascript.ts @@ -14,6 +14,7 @@ export const javascriptRules = { "curly": ["error", "all"], "no-console": "warn", "no-self-compare": "error", + "no-template-curly-in-string": "error", "no-useless-rename": "error", "object-shorthand": "error", "prefer-arrow-callback": "error", From fc5aaed429e3c4ae47cdea41bad2a927d10ba75b Mon Sep 17 00:00:00 2001 From: jimmy-guzman Date: Thu, 7 Nov 2024 18:43:31 -0600 Subject: [PATCH 7/9] =?UTF-8?q?feat:=20=E2=9C=A8=20enable=20`no-unreachabl?= =?UTF-8?q?e-loop`=20rule?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/rules/__snapshots__/javascript.spec.ts.snap | 1 + src/rules/javascript.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/src/rules/__snapshots__/javascript.spec.ts.snap b/src/rules/__snapshots__/javascript.spec.ts.snap index 558b50d..7e21c5b 100644 --- a/src/rules/__snapshots__/javascript.spec.ts.snap +++ b/src/rules/__snapshots__/javascript.spec.ts.snap @@ -67,6 +67,7 @@ exports[`should create javascript rules 1`] = ` "no-undef": "error", "no-unexpected-multiline": "error", "no-unreachable": "error", + "no-unreachable-loop": "error", "no-unsafe-finally": "error", "no-unsafe-negation": "error", "no-unsafe-optional-chaining": "error", diff --git a/src/rules/javascript.ts b/src/rules/javascript.ts index 2c593da..19c3c1a 100644 --- a/src/rules/javascript.ts +++ b/src/rules/javascript.ts @@ -15,6 +15,7 @@ export const javascriptRules = { "no-console": "warn", "no-self-compare": "error", "no-template-curly-in-string": "error", + "no-unreachable-loop": "error", "no-useless-rename": "error", "object-shorthand": "error", "prefer-arrow-callback": "error", From a04786022403848aa0fbff2f6b2c0685d0f92aff Mon Sep 17 00:00:00 2001 From: jimmy-guzman Date: Thu, 7 Nov 2024 18:44:09 -0600 Subject: [PATCH 8/9] =?UTF-8?q?feat:=20=E2=9C=A8=20enable=20`no-unmodified?= =?UTF-8?q?-loop-condition`=20rule?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/rules/__snapshots__/javascript.spec.ts.snap | 1 + src/rules/javascript.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/src/rules/__snapshots__/javascript.spec.ts.snap b/src/rules/__snapshots__/javascript.spec.ts.snap index 7e21c5b..7cae972 100644 --- a/src/rules/__snapshots__/javascript.spec.ts.snap +++ b/src/rules/__snapshots__/javascript.spec.ts.snap @@ -66,6 +66,7 @@ exports[`should create javascript rules 1`] = ` "no-this-before-super": "error", "no-undef": "error", "no-unexpected-multiline": "error", + "no-unmodified-loop-condition": "error", "no-unreachable": "error", "no-unreachable-loop": "error", "no-unsafe-finally": "error", diff --git a/src/rules/javascript.ts b/src/rules/javascript.ts index 19c3c1a..7be2ca4 100644 --- a/src/rules/javascript.ts +++ b/src/rules/javascript.ts @@ -15,6 +15,7 @@ export const javascriptRules = { "no-console": "warn", "no-self-compare": "error", "no-template-curly-in-string": "error", + "no-unmodified-loop-condition": "error", "no-unreachable-loop": "error", "no-useless-rename": "error", "object-shorthand": "error", From 1e8f79432cefccada0154ed443e7dc5473d139ae Mon Sep 17 00:00:00 2001 From: jimmy-guzman Date: Thu, 7 Nov 2024 18:46:15 -0600 Subject: [PATCH 9/9] =?UTF-8?q?feat:=20=E2=9C=A8=20enable=20`no-use-before?= =?UTF-8?q?-define`=20rule?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/rules/__snapshots__/javascript.spec.ts.snap | 9 +++++++++ src/rules/javascript.ts | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/src/rules/__snapshots__/javascript.spec.ts.snap b/src/rules/__snapshots__/javascript.spec.ts.snap index 7cae972..96f8030 100644 --- a/src/rules/__snapshots__/javascript.spec.ts.snap +++ b/src/rules/__snapshots__/javascript.spec.ts.snap @@ -75,6 +75,15 @@ exports[`should create javascript rules 1`] = ` "no-unused-labels": "error", "no-unused-private-class-members": "error", "no-unused-vars": "error", + "no-use-before-define": [ + "error", + { + "allowNamedExports": false, + "classes": false, + "functions": false, + "variables": true, + }, + ], "no-useless-backreference": "error", "no-useless-catch": "error", "no-useless-escape": "error", diff --git a/src/rules/javascript.ts b/src/rules/javascript.ts index 7be2ca4..f5208fe 100644 --- a/src/rules/javascript.ts +++ b/src/rules/javascript.ts @@ -17,6 +17,15 @@ export const javascriptRules = { "no-template-curly-in-string": "error", "no-unmodified-loop-condition": "error", "no-unreachable-loop": "error", + "no-use-before-define": [ + "error", + { + allowNamedExports: false, + classes: false, + functions: false, + variables: true, + }, + ], "no-useless-rename": "error", "object-shorthand": "error", "prefer-arrow-callback": "error",