From e4de5c8a8dfed08a3ac33fccbe483dc96efb120f Mon Sep 17 00:00:00 2001 From: DigiLive Date: Wed, 23 Apr 2025 06:58:49 +0200 Subject: [PATCH] Refactor tool configurations --- .editorconfig | 32 ++++++++++++++++++----- .eslintrc | 59 +++++++++++++++++++++++++++++++++++++++++++ .gitignore | 1 + .prettierrc | 12 +++++++++ tsconfig.json | 28 ++++++++------------ webpack.config.ts | 14 +++++----- webpack.dev.config.ts | 19 ++++++-------- 7 files changed, 124 insertions(+), 41 deletions(-) create mode 100644 .prettierrc diff --git a/.editorconfig b/.editorconfig index 264be0d..4861cc4 100644 --- a/.editorconfig +++ b/.editorconfig @@ -15,7 +15,7 @@ ij_visual_guides = 120 ij_wrap_on_typing = false [.editorconfig] -ij_visual_guides = +ij_visual_guides = ij_editorconfig_align_group_field_declarations = false ij_editorconfig_space_after_colon = false ij_editorconfig_space_after_comma = true @@ -35,9 +35,9 @@ ij_typescript_align_multiline_chained_methods = true ij_typescript_align_multiline_extends_list = false ij_typescript_align_multiline_for = true ij_typescript_align_multiline_parameters = false -ij_typescript_align_multiline_parameters_in_calls = true +ij_typescript_align_multiline_parameters_in_calls = false ij_typescript_align_multiline_ternary_operation = true -ij_typescript_align_object_properties = 1 +ij_typescript_align_object_properties = 0 ij_typescript_align_union_types = true ij_typescript_align_var_statements = 1 ij_typescript_array_initializer_new_line_after_left_brace = true @@ -46,7 +46,7 @@ ij_typescript_array_initializer_wrap = on_every_item ij_typescript_assignment_wrap = normal ij_typescript_binary_operation_sign_on_next_line = true ij_typescript_binary_operation_wrap = normal -ij_typescript_blacklist_imports = rxjs/Rx,node_modules/**,**/node_modules/**,@angular/material,@angular/material/typings/** +ij_typescript_blacklist_imports = rxjs/Rx, node_modules/**, **/node_modules/**, @angular/material, @angular/material/typings/** ij_typescript_blank_lines_after_imports = 1 ij_typescript_blank_lines_around_class = 1 ij_typescript_blank_lines_around_field = 0 @@ -205,7 +205,7 @@ ij_typescript_while_on_new_line = false ij_typescript_wrap_comments = true [{*.markdown,*.md}] -ij_visual_guides = +ij_visual_guides = ij_markdown_force_one_space_after_blockquote_symbol = true ij_markdown_force_one_space_after_header_symbol = true ij_markdown_force_one_space_after_list_bullet = true @@ -225,7 +225,7 @@ ij_markdown_wrap_text_inside_blockquotes = true [{*.yaml,*.yml}] indent_size = 2 -ij_visual_guides = +ij_visual_guides = ij_yaml_align_values_properties = do_not_align ij_yaml_autoinsert_sequence_marker = true ij_yaml_block_mapping_on_new_line = false @@ -239,3 +239,23 @@ ij_yaml_sequence_on_new_line = false ij_yaml_space_before_colon = false ij_yaml_spaces_within_braces = true ij_yaml_spaces_within_brackets = true + +[{*.json,.eslintrc}] +indent_size = 2 +tab_width = 2 +ij_continuation_indent_size = 4 +ij_visual_guides = +ij_json_array_wrapping = split_into_lines +ij_json_keep_blank_lines_in_code = 0 +ij_json_keep_indents_on_empty_lines = false +ij_json_keep_line_breaks = true +ij_json_keep_trailing_comma = false +ij_json_object_wrapping = split_into_lines +ij_json_property_alignment = do_not_align +ij_json_space_after_colon = true +ij_json_space_after_comma = true +ij_json_space_before_colon = false +ij_json_space_before_comma = false +ij_json_spaces_within_braces = false +ij_json_spaces_within_brackets = false +ij_json_wrap_long_lines = false \ No newline at end of file diff --git a/.eslintrc b/.eslintrc index e69de29..eb966d2 100644 --- a/.eslintrc +++ b/.eslintrc @@ -0,0 +1,59 @@ +{ + "root": true, + "parser": "@typescript-eslint/parser", + "plugins": [ + "@typescript-eslint" + ], + "extends": [ + "eslint:recommended", + "plugin:@typescript-eslint/recommended", + "plugin:prettier/recommended" + ], + "env": { + "es2020": true, + "node": true + }, + "parserOptions": { + "ecmaVersion": 2020, + "sourceType": "module", + "project": "./tsconfig.json" + }, + "rules": { + "no-console": "off", + "no-unused-vars": "off", + "@typescript-eslint/no-unused-vars": [ + "warn", + { + "argsIgnorePattern": "^_" + } + ], + "no-empty-function": "off", + "@typescript-eslint/no-empty-function": "warn", + "semi": [ + "error", + "always" + ], + "quotes": [ + "error", + "single" + ] + }, + "ignorePatterns": [ + "dist/", + "node_modules/", + "*.js", + "src/types/homeassistant/", + "src/types/lovelace-mushroom/" + ], + "overrides": [ + { + "files": [ + "webpack.config.ts", + "webpack.dev.config.ts" + ], + "parserOptions": { + "project": null + } + } + ] +} \ No newline at end of file diff --git a/.gitignore b/.gitignore index 2ccbe46..c85804c 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /node_modules/ +/dist/ \ No newline at end of file diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..24b0a74 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,12 @@ +{ + "semi": true, + "singleQuote": true, + "printWidth": 120, + "tabWidth": 2, + "trailingComma": "all", + "bracketSpacing": true, + "arrowParens": "always", + "endOfLine": "lf", + "proseWrap": "preserve", + "embeddedLanguageFormatting": "auto" +} \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index 551c253..d2cdfaf 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,39 +3,33 @@ "src/**/*" ], "compilerOptions": { - /* Visit https://aka.ms/tsconfig to read more about this file */ - - /* Language and Environment */ + // 1. Language and Environment "target": "ES2020", "jsx": "react", - - /* Modules */ + // 2. Module System "module": "ES2020", "moduleResolution": "Node", - - /* JavaScript Support */ + "outDir": "./dist", + "resolveJsonModule": true, + // 3. JavaScript and Source Maps "allowJs": true, "sourceMap": true, - "outDir": "./dist", + // 4. Interop and Imports "allowSyntheticDefaultImports": true, "esModuleInterop": true, - "forceConsistentCasingInFileNames": true, - - /* Type Checking */ + // 5. Type Checking and Strictness "strict": true, "noImplicitAny": true, "noImplicitThis": true, "noImplicitReturns": true, "strictNullChecks": true, - - /* Completeness */ - "skipLibCheck": true, - - "resolveJsonModule": true, + // 6. Project Structure and Build Integrity + "forceConsistentCasingInFileNames": true, + "skipLibCheck": true }, "ts-node": { "compilerOptions": { "module": "CommonJS" } } -} +} \ No newline at end of file diff --git a/webpack.config.ts b/webpack.config.ts index 1ee2c25..2e30a99 100644 --- a/webpack.config.ts +++ b/webpack.config.ts @@ -4,21 +4,21 @@ import path from 'path'; import webpack from 'webpack'; const config: webpack.Configuration = { - entry: "./src/mushroom-strategy.ts", - mode: "production", + mode: 'production', + entry: './src/mushroom-strategy.ts', output: { - filename: "mushroom-strategy.js", - path: path.resolve(__dirname, "dist"), clean: true, + filename: 'mushroom-strategy.js', + path: path.resolve(__dirname, 'dist'), }, resolve: { - extensions: [".ts", ".tsx", ".js"], + extensions: ['.ts', '.js'], }, module: { rules: [ { - test: /\.tsx?$/, - use: "ts-loader", + test: /\.ts$/, + use: 'ts-loader', exclude: /node_modules/, }, ], diff --git a/webpack.dev.config.ts b/webpack.dev.config.ts index 3a00697..7b13b38 100644 --- a/webpack.dev.config.ts +++ b/webpack.dev.config.ts @@ -4,24 +4,21 @@ import path from 'path'; import webpack from 'webpack'; const config: webpack.Configuration = { - entry: "./src/mushroom-strategy.ts", - mode: "development", - devtool: "source-map", + mode: 'development', + entry: './src/mushroom-strategy.ts', output: { - filename: "mushroom-strategy.js", - path: path.resolve(__dirname, "dist"), + filename: 'mushroom-strategy.js', + path: path.resolve(__dirname, 'dist'), }, + devtool: 'source-map', resolve: { - extensions: [".ts", ".tsx", ".js"], - }, - optimization: { - minimize: false, + extensions: ['.ts', '.js'], }, module: { rules: [ { - test: /\.tsx?$/, - use: "ts-loader", + test: /\.ts$/, + use: 'ts-loader', exclude: /node_modules/, }, ],