From 2e1cbecd9590091f86469f5acc5c158df2278eb7 Mon Sep 17 00:00:00 2001 From: Matt Rakow Date: Sat, 12 Jul 2025 15:43:29 -0700 Subject: [PATCH] Configure several lint rules --- build/eslint-config-shared/js.mjs | 2 +- build/eslint-config-shared/perfectionist.mjs | 40 ++++++++++---------- build/eslint-config-shared/stylistic.mjs | 25 +++++++++--- build/eslint-config-shared/tseslint.mjs | 4 +- examples/webpack.config.js | 6 +-- 5 files changed, 45 insertions(+), 32 deletions(-) diff --git a/build/eslint-config-shared/js.mjs b/build/eslint-config-shared/js.mjs index 34cef85..d94d700 100644 --- a/build/eslint-config-shared/js.mjs +++ b/build/eslint-config-shared/js.mjs @@ -10,7 +10,7 @@ export const jsConfigs = [ "block-scoped-var": "error", "camelcase": "error", // "capitalized-comments": "error", - "class-methods-use-this": "error", // Might need to warn instead to conform with interfaces + // "class-methods-use-this": "error", // Disabled by tseslint's class-methods-use-this "complexity": "error", "consistent-return": "error", "consistent-this": "error", diff --git a/build/eslint-config-shared/perfectionist.mjs b/build/eslint-config-shared/perfectionist.mjs index d12622f..8878f40 100644 --- a/build/eslint-config-shared/perfectionist.mjs +++ b/build/eslint-config-shared/perfectionist.mjs @@ -4,26 +4,26 @@ export const perfectionistConfigs = [ pluginPerfectionist.configs["recommended-natural"], { rules: { - // "sort-array-includes": "error", - // "sort-classes": "error", - // "sort-decorators": "error", - // "sort-enums": "error", - // "sort-exports": "error", - // "sort-heritage-clauses": "error", - // "sort-imports": "error", - // "sort-interfaces": "error", - // "sort-intersection-types": "error", - // "sort-jsx-props": "error", - // "sort-maps": "error", - // "sort-named-exports": "error", - // "sort-modules": "error", - // "sort-named-imports": "error", - // "sort-object-types": "error", - // "sort-objects": "error", - // "sort-sets": "error", - // "sort-switch-case": "error", - // "sort-union-types": "error", - // "sort-variable-declarations": "error", + // "perfectionist/sort-array-includes": "error", + "perfectionist/sort-classes": "off", + // "perfectionist/sort-decorators": "error", + // "perfectionist/sort-enums": "error", + // "perfectionist/sort-exports": "error", + // "perfectionist/sort-heritage-clauses": "error", + // "perfectionist/sort-imports": "error", + // "perfectionist/sort-interfaces": "error", + "perfectionist/sort-intersection-types": "off", + "perfectionist/sort-jsx-props": "off", + // "perfectionist/sort-maps": "error", + // "perfectionist/sort-named-exports": "error", + "perfectionist/sort-modules": "off", + // "perfectionist/sort-named-imports": "error", + "perfectionist/sort-object-types": "off", + "perfectionist/sort-objects": "off", + // "perfectionist/sort-sets": "error", + // "perfectionist/sort-switch-case": "error", + // "perfectionist/sort-union-types": "error", + // "perfectionist/sort-variable-declarations": "error", }, }, ]; diff --git a/build/eslint-config-shared/stylistic.mjs b/build/eslint-config-shared/stylistic.mjs index 68e7622..94dd2e1 100644 --- a/build/eslint-config-shared/stylistic.mjs +++ b/build/eslint-config-shared/stylistic.mjs @@ -20,7 +20,7 @@ export const stylisticConfigs = [ // "@stylistic/eol-last": "error", // Enabled in recommended "@stylistic/function-call-argument-newline": ["error", "consistent"], "@stylistic/function-call-spacing": "error", - "@stylistic/function-paren-newline": "error", + "@stylistic/function-paren-newline": ["error", "multiline-arguments"], // "@stylistic/generator-star-spacing": "error", // Enabled in recommended // "@stylistic/implicit-arrow-linebreak": "error", "@stylistic/indent": ["error", 4], // Enabled in recommended @@ -30,12 +30,12 @@ export const stylisticConfigs = [ // "@stylistic/jsx-closing-tag-location": "error", // Enabled in recommended // "@stylistic/jsx-curly-brace-presence": "error", // Enabled in recommended // "@stylistic/jsx-curly-newline": "error", // Enabled in recommended - // "@stylistic/jsx-curly-spacing": "error", // Enabled in recommended + "@stylistic/jsx-curly-spacing": ["error", { "when": "always" }], // Enabled in recommended // "@stylistic/jsx-equals-spacing": "error", // Enabled in recommended // "@stylistic/jsx-first-prop-new-line": "error", // Enabled in recommended // "@stylistic/jsx-function-call-newline": "error", // Enabled in recommended // "@stylistic/jsx-indent": "error", - // "@stylistic/jsx-indent-props": "error", // Enabled in recommended + "@stylistic/jsx-indent-props": ["error", 4], // Enabled in recommended // "@stylistic/jsx-max-props-per-line": "error", // Enabled in recommended // "@stylistic/jsx-newline": "error", "@stylistic/jsx-one-expression-per-line": "off", // Enabled in recommended @@ -51,10 +51,23 @@ export const stylisticConfigs = [ // "@stylistic/line-comment-position": "error", "@stylistic/linebreak-style": "error", // "@stylistic/lines-around-comment": "error", - // "@stylistic/lines-between-class-members": "error", // Enabled in recommended + "@stylistic/lines-between-class-members": "off", // Enabled in recommended // "@stylistic/max-len": "error", - // "@stylistic/max-statements-per-line": "error", // Enabled in recommended - // "@stylistic/member-delimiter-style": "error", // Enabled in recommended + "@stylistic/max-statements-per-line": "off", // Enabled in recommended + "@stylistic/member-delimiter-style": [ + "error", + { + "multiline": { + "delimiter": "semi", + "requireLast": true + }, + "singleline": { + "delimiter": "semi", + "requireLast": false + }, + "multilineDetection": "brackets" + }, + ], // Enabled in recommended // "@stylistic/multiline-comment-style": "error", // "@stylistic/multiline-ternary": "error", // Enabled in recommended // "@stylistic/new-parens": "error", // Enabled in recommended diff --git a/build/eslint-config-shared/tseslint.mjs b/build/eslint-config-shared/tseslint.mjs index 965b0bc..5aa3c62 100644 --- a/build/eslint-config-shared/tseslint.mjs +++ b/build/eslint-config-shared/tseslint.mjs @@ -45,7 +45,7 @@ export const tseslintConfigs = [ // "@typescript-eslint/consistent-indexed-object-style": "error", // Enabled in stylistic // "@typescript-eslint/consistent-return": "error", // "@typescript-eslint/consistent-type-assertions": "error", // Enabled in stylistic - // "@typescript-eslint/consistent-type-definitions": "error", // Enabled in stylistic + "@typescript-eslint/consistent-type-definitions": ["error", "type"], // Enabled in stylistic // "@typescript-eslint/consistent-type-exports": "error", // "@typescript-eslint/consistent-type-imports": "error", "@typescript-eslint/default-param-last": "error", @@ -53,7 +53,7 @@ export const tseslintConfigs = [ // "@typescript-eslint/explicit-function-return-type": "error", // "@typescript-eslint/explicit-member-accessibility": "error", // "@typescript-eslint/explicit-module-boundary-types": "error", - "@typescript-eslint/init-declarations": "error", + // "@typescript-eslint/init-declarations": "error", // "@typescript-eslint/max-params": "error", // "@typescript-eslint/member-ordering": "error", // "@typescript-eslint/method-signature-style": "error", diff --git a/examples/webpack.config.js b/examples/webpack.config.js index d62c183..d0bf5d7 100644 --- a/examples/webpack.config.js +++ b/examples/webpack.config.js @@ -38,11 +38,11 @@ export default { ], }, output: { - clean: true, filename: "[name].bundle.js", + path: resolve(__dirname, "webpacked"), library: "[name]", libraryTarget: "umd", - path: resolve(__dirname, "webpacked"), + clean: true, }, plugins: [ new HtmlWebpackPlugin({ @@ -61,11 +61,11 @@ export default { }), ], resolve: { + extensions: [".ts", ".tsx", ".js"], extensionAlias: { ".js": [".ts", ".tsx", ".js"], ".mjs": [".mts", ".mtsx", ".mjs"], }, - extensions: [".ts", ".tsx", ".js"], // fallback: { "events": require.resolve("events/") } }, };