From e7bce8f1a312d8f9411c04b005f66dbf0f96d887 Mon Sep 17 00:00:00 2001 From: Daniele Debernardi Date: Sat, 8 Jun 2024 01:17:14 +0200 Subject: [PATCH] Add eslint and migrate to yarn --- .editorconfig | 8 +- .github/workflows/integration-tests.yml | 4 + .github/workflows/release.yml | 9 +- .github/workflows/unit-tests.yml | 4 +- .gitignore | 3 + .vscode/extensions.json | 8 + .vscode/settings.json | 16 + .vscode/tasks.json | 17 +- CreateInstallerCommon.bat | 24 +- CreateInstallerLinux.bat | 2 +- CreateInstallerOSX.bat | 20 +- CreateInstallerWin.bat | 10 +- SQLSchemaCompare.UI/.eslintrc.js | 269 - .../Pages/Project/_DataSourcesTab.cshtml | 8 +- .../Pages/ToolbarPageModel.cshtml | 4 +- .../Pages/WelcomePageModel.cshtml | 8 +- SQLSchemaCompare.UI/Pages/_ScriptSetup.cshtml | 1 + .../SQLSchemaCompare.UI.csproj | 37 +- SQLSchemaCompare.UI/bundleconfig.json | 3 +- SQLSchemaCompare.UI/eslint.config.js | 25 + SQLSchemaCompare.UI/package.json | 21 + SQLSchemaCompare.UI/tsconfig.json | 19 +- .../wwwroot/js/Entities/ApiResponse.ts | 52 +- .../js/Entities/CompareResultItemScripts.ts | 7 +- SQLSchemaCompare.UI/wwwroot/js/Enums.ts | 175 + SQLSchemaCompare.UI/wwwroot/js/Index.ts | 18 +- .../wwwroot/js/Localization.ts | 25 +- SQLSchemaCompare.UI/wwwroot/js/Logger.ts | 1 + SQLSchemaCompare.UI/wwwroot/js/Main.ts | 60 +- .../wwwroot/js/Managers/DialogManager.ts | 40 +- .../wwwroot/js/Managers/EditorManager.ts | 42 +- .../wwwroot/js/Managers/MenuManager.ts | 92 +- .../wwwroot/js/Managers/PageManager.ts | 55 +- .../wwwroot/js/Managers/TaskManager.ts | 13 +- SQLSchemaCompare.UI/wwwroot/js/Project.ts | 211 +- SQLSchemaCompare.UI/wwwroot/js/Settings.ts | 15 +- SQLSchemaCompare.UI/wwwroot/js/Utility.ts | 62 +- SQLSchemaCompare.UI/yarn.lock | 857 +++ SQLSchemaCompare.sln | 2 - SQLSchemaCompare/SQLSchemaCompare.esproj | 6 +- SQLSchemaCompare/app.ts | 97 +- SQLSchemaCompare/eslint.config.js | 22 + SQLSchemaCompare/package-lock.json | 5028 ----------------- SQLSchemaCompare/package.json | 20 +- SQLSchemaCompare/tsconfig.json | 21 +- SQLSchemaCompare/yarn.lock | 2564 +++++++++ pre-commit-hook.sh | 3 +- tslint.json | 271 - tslint.targets | 66 - 49 files changed, 4074 insertions(+), 6271 deletions(-) create mode 100644 .vscode/extensions.json create mode 100644 .vscode/settings.json delete mode 100644 SQLSchemaCompare.UI/.eslintrc.js create mode 100644 SQLSchemaCompare.UI/eslint.config.js create mode 100644 SQLSchemaCompare.UI/package.json create mode 100644 SQLSchemaCompare.UI/wwwroot/js/Enums.ts create mode 100644 SQLSchemaCompare.UI/yarn.lock create mode 100644 SQLSchemaCompare/eslint.config.js delete mode 100644 SQLSchemaCompare/package-lock.json create mode 100644 SQLSchemaCompare/yarn.lock delete mode 100644 tslint.json delete mode 100644 tslint.targets diff --git a/.editorconfig b/.editorconfig index 00a00553..4f96bb3d 100644 --- a/.editorconfig +++ b/.editorconfig @@ -26,12 +26,12 @@ indent_size = 4 indent_style = tab # XML Project Files -[*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj}] +[*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj,esproj}] indent_size = 2 # Configuration Files -[*.{json,xml,yml,config,props,targets,nuspec,resx,ruleset}] -indent_size = 4 +[*.{json,xml,yml,config,props,targets,nuspec,resx,ruleset,js}] +indent_size = 2 # .NET Config Files [*.{config}] @@ -43,7 +43,7 @@ charset = utf-8-bom trim_trailing_whitespace = false # Web Files -[*.{htm,html,js,ts,css,scss,less}] +[*.{htm,html,ts,css,scss,less}] indent_size = 4 insert_final_newline = true diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index 1f46609a..bc03e46b 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -7,6 +7,7 @@ on: jobs: microsoft_sql: + if: github.event.pull_request.draft == false runs-on: ubuntu-latest env: RunDockerTests: true @@ -43,6 +44,7 @@ jobs: files: SQLSchemaCompare.Test/TestResults/*.trx my_sql: + if: github.event.pull_request.draft == false runs-on: ubuntu-latest env: RunDockerTests: true @@ -81,6 +83,7 @@ jobs: files: SQLSchemaCompare.Test/TestResults/*.trx postgre_sql: + if: github.event.pull_request.draft == false runs-on: ubuntu-latest env: RunDockerTests: true @@ -121,6 +124,7 @@ jobs: files: SQLSchemaCompare.Test/TestResults/*.trx maria_db: + if: github.event.pull_request.draft == false runs-on: ubuntu-latest env: RunDockerTests: true diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d1c90f85..03a6675d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -16,9 +16,6 @@ jobs: dotnet-version: 8.0.x - name: Add msbuild to PATH uses: microsoft/setup-msbuild@v1.0.2 - - name: Install npm dependencies - run: npm install - working-directory: SQLSchemaCompare - name: Restore win-x64 dependencies run: dotnet restore -r win-x64 @@ -86,7 +83,7 @@ jobs: name: publish-win path: .publish - name: Create installer - run: npm run dist-win-x64 + run: yarn dist-win-x64 working-directory: SQLSchemaCompare - name: Upload installer to release uses: svenstaro/upload-release-action@v2 @@ -123,7 +120,7 @@ jobs: chmod +x .publish/TiCodeX.SQLSchemaCompare.UI chmod +x .publish/TiCodeX.SQLSchemaCompare.CLI - name: Create installer - run: npm run dist-linux-x64 + run: yarn dist-linux-x64 working-directory: SQLSchemaCompare - name: Upload installer to release uses: svenstaro/upload-release-action@v2 @@ -160,7 +157,7 @@ jobs: chmod +x .publish/TiCodeX.SQLSchemaCompare.UI chmod +x .publish/TiCodeX.SQLSchemaCompare.CLI - name: Create installer - run: npm run dist-osx-x64 + run: yarn dist-osx-x64 working-directory: SQLSchemaCompare - name: Upload installer to release uses: svenstaro/upload-release-action@v2 diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index 8467329e..f64f4cc1 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -7,6 +7,7 @@ on: jobs: unit_tests: + if: github.event.pull_request.draft == false runs-on: windows-latest steps: - uses: actions/checkout@v2 @@ -18,9 +19,6 @@ jobs: uses: microsoft/setup-msbuild@v1.0.2 - name: Restore dependencies run: dotnet restore - - name: Install npm dependencies - run: npm install - working-directory: SQLSchemaCompare - name: Build run: msbuild SQLSchemaCompare.sln /p:Configuration=Release - name: Test diff --git a/.gitignore b/.gitignore index cdcad25a..ab2969d5 100644 --- a/.gitignore +++ b/.gitignore @@ -333,6 +333,9 @@ ASALocalRun/ # Local History for Visual Studio .localhistory/ +# ESLint +.eslintcache + # Custom rules SQLSchemaCompare/app.js SQLSchemaCompare/app.js.map diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 00000000..3996a3b2 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,8 @@ +{ + "recommendations": [ + "ms-dotnettools.csharp", + "ms-dotnettools.csdevkit", + "EditorConfig.EditorConfig", + "dbaeumer.vscode-eslint", + ] +} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..9ae9ec6f --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,16 @@ +{ + "editor.formatOnSave": true, + "eslint.enable": true, + "eslint.format.enable": true, + "eslint.validate": [ + "typescript", + ], + "eslint.experimental.useFlatConfig": true, + "eslint.workingDirectories": [{ "mode": "auto" }], + "eslint.options": { + "overrideConfigFile": "./eslint.config.js" + }, + "editor.codeActionsOnSave": { + "source.fixAll.eslint": "explicit" + } +} diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 662d087b..38721701 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -53,13 +53,16 @@ "group": { "kind": "build" }, - "problemMatcher": { - "base": "$tsc", - "fileLocation": [ - "relative", - "${workspaceFolder}/SQLSchemaCompare" - ] - } + "problemMatcher": [ + "$eslint-stylish", + { + "base": "$tsc", + "fileLocation": [ + "relative", + "${workspaceFolder}/SQLSchemaCompare" + ] + } + ] }, { "label": "Build CLI", diff --git a/CreateInstallerCommon.bat b/CreateInstallerCommon.bat index 23c47246..cb02e39d 100644 --- a/CreateInstallerCommon.bat +++ b/CreateInstallerCommon.bat @@ -2,6 +2,9 @@ REM Bring dev tools into the PATH. set "VsDevCmdPath=C:\Program Files\Microsoft Visual Studio\2022\Professional\Common7\Tools\VsDevCmd.bat" +if not exist "%VsDevCmdPath%" ( + set "VsDevCmdPath=C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\VsDevCmd.bat" +) if not exist "%VsDevCmdPath%" ( set "VsDevCmdPath=C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\Common7\Tools\VsDevCmd.bat" ) @@ -40,18 +43,13 @@ if ERRORLEVEL 1 exit /b %ERRORLEVEL% echo. echo ___________________________ -echo /\ \ -echo \_^| Building ^| -echo ^| SQLSchemaCompare ^| -echo ^| _______________________^|_ +echo /\ \ +echo \_^| Building ^| +echo ^| SQLSchemaCompare ^| +echo ^| _______________________^|_ echo \_/_________________________/ echo. -pushd %~dp0\SQLSchemaCompare -rd /Q /S node_modules -call npm install -popd - dotnet restore -r %targetdotnet% if ERRORLEVEL 1 exit /b %ERRORLEVEL% @@ -60,10 +58,10 @@ if ERRORLEVEL 1 exit /b %ERRORLEVEL% echo. echo ____________________________ -echo /\ \ -echo \_^| Publishing ^| -echo ^| SQLSchemaCompare ^| -echo ^| _______________________^|_ +echo /\ \ +echo \_^| Publishing ^| +echo ^| SQLSchemaCompare ^| +echo ^| _______________________^|_ echo \_/_________________________/ echo. diff --git a/CreateInstallerLinux.bat b/CreateInstallerLinux.bat index 825f8afa..89e97513 100644 --- a/CreateInstallerLinux.bat +++ b/CreateInstallerLinux.bat @@ -30,7 +30,7 @@ docker run --rm^ --env ELECTRON_CACHE="/root/.cache/electron"^ --env ELECTRON_BUILDER_CACHE="/root/.cache/electron-builder"^ electronuserland/builder^ - npm run dist-%target% + yarn dist-%target% if ERRORLEVEL 1 goto:error diff --git a/CreateInstallerOSX.bat b/CreateInstallerOSX.bat index 57a4c6cf..d608dc6b 100644 --- a/CreateInstallerOSX.bat +++ b/CreateInstallerOSX.bat @@ -14,10 +14,10 @@ if ERRORLEVEL 1 goto:error echo. echo _____________________ -echo /\ \ -echo \_^| Preparing ^| -echo ^| OSX ^| -echo ^| _________________^|_ +echo /\ \ +echo \_^| Preparing ^| +echo ^| OSX ^| +echo ^| _________________^|_ echo \_/___________________/ echo. @@ -37,11 +37,11 @@ if ERRORLEVEL 1 goto:error echo. echo _____________________ -echo /\ \ -echo \_^| Packaging ^| -echo ^| electron ^| -echo ^| OSX ^| -echo ^| _________________^|_ +echo /\ \ +echo \_^| Packaging ^| +echo ^| electron ^| +echo ^| OSX ^| +echo ^| _________________^|_ echo \_/___________________/ echo. @@ -51,7 +51,7 @@ plink -pw %remotePass% %remoteUser%@%remoteIp% (^ cd %remoteDir%/SQLSchemaCompare;^ chmod -R a+rwx ./node_modules;^ chmod +x ../.publish/TiCodeX.SQLSchemaCompare.UI;^ - npm run dist-%target%;^ + yarn dist-%target%;^ ) if ERRORLEVEL 1 goto:error diff --git a/CreateInstallerWin.bat b/CreateInstallerWin.bat index 7969e99c..3793c5a7 100644 --- a/CreateInstallerWin.bat +++ b/CreateInstallerWin.bat @@ -9,17 +9,17 @@ if ERRORLEVEL 1 goto:error echo. echo _____________________ -echo /\ \ -echo \_^| Packaging ^| -echo ^| electron ^| -echo ^| _________________^|_ +echo /\ \ +echo \_^| Packaging ^| +echo ^| electron ^| +echo ^| _________________^|_ echo \_/___________________/ echo. REM Cleanup folders if exist %~dp0\installer\win-unpacked ( rmdir /S /Q %~dp0\installer\win-unpacked ) -call npm --prefix SQLSchemaCompare run dist-%target% +call yarn --cwd SQLSchemaCompare dist-%target% if ERRORLEVEL 1 goto:error diff --git a/SQLSchemaCompare.UI/.eslintrc.js b/SQLSchemaCompare.UI/.eslintrc.js deleted file mode 100644 index 49385738..00000000 --- a/SQLSchemaCompare.UI/.eslintrc.js +++ /dev/null @@ -1,269 +0,0 @@ -module.exports = { - "extends": "eslint:recommended", - rules: { - "accessor-pairs": "off", - "array-bracket-newline": "off", - "array-bracket-spacing": "off", - "array-callback-return": "off", - "array-element-newline": "off", - "arrow-body-style": "off", - "arrow-parens": "off", - "arrow-spacing": "off", - "block-scoped-var": "off", - "block-spacing": "off", - "brace-style": "off", - "callback-return": "off", - "camelcase": "off", - "capitalized-comments": "off", - "class-methods-use-this": "off", - "comma-dangle": "off", - "comma-spacing": "off", - "comma-style": "off", - "complexity": "off", - "computed-property-spacing": "off", - "consistent-return": "off", - "consistent-this": "off", - "constructor-super": "off", - "curly": "off", - "default-case": "off", - "dot-location": "off", - "dot-notation": "off", - "eol-last": "off", - "eqeqeq": "off", - "for-direction": "off", - "func-call-spacing": "off", - "func-name-matching": "off", - "func-names": "off", - "func-style": "off", - "function-paren-newline": "off", - "generator-star-spacing": "off", - "getter-return": "off", - "global-require": "off", - "guard-for-in": "off", - "handle-callback-err": "off", - "id-blacklist": "off", - "id-length": "off", - "id-match": "off", - "implicit-arrow-linebreak": "off", - "indent": "off", - "indent-legacy": "off", - "init-declarations": "off", - "jsx-quotes": "off", - "key-spacing": "off", - "keyword-spacing": "off", - "line-comment-position": "off", - "linebreak-style": "off", - "lines-around-comment": "off", - "lines-around-directive": "off", - "lines-between-class-members": "off", - "max-classes-per-file": "off", - "max-depth": "off", - "max-len": "off", - "max-lines": "off", - "max-lines-per-function": "off", - "max-nested-callbacks": "off", - "max-params": "off", - "max-statements": "off", - "max-statements-per-line": "off", - "multiline-comment-style": "off", - "multiline-ternary": "off", - "new-cap": "off", - "new-parens": "off", - "newline-after-var": "off", - "newline-before-return": "off", - "newline-per-chained-call": "off", - "no-alert": "off", - "no-array-constructor": "off", - "no-async-promise-executor": "off", - "no-await-in-loop": "off", - "no-bitwise": "off", - "no-buffer-constructor": "off", - "no-caller": "off", - "no-case-declarations": "off", - "no-catch-shadow": "off", - "no-class-assign": "off", - "no-compare-neg-zero": "off", - "no-cond-assign": "off", - "no-confusing-arrow": "off", - "no-console": "off", - "no-const-assign": "off", - "no-constant-condition": "off", - "no-continue": "off", - "no-control-regex": "off", - "no-debugger": "off", - "no-delete-var": "off", - "no-div-regex": "off", - "no-dupe-args": "off", - "no-dupe-class-members": "off", - "no-dupe-keys": "off", - "no-duplicate-case": "off", - "no-duplicate-imports": "off", - "no-else-return": "off", - "no-empty": "off", - "no-empty-character-class": "off", - "no-empty-function": "off", - "no-empty-pattern": "off", - "no-eq-null": "off", - "no-eval": "off", - "no-ex-assign": "off", - "no-extend-native": "off", - "no-extra-bind": "off", - "no-extra-boolean-cast": "off", - "no-extra-label": "off", - "no-extra-parens": "off", - "no-extra-semi": "off", - "no-fallthrough": "off", - "no-floating-decimal": "off", - "no-func-assign": "off", - "no-global-assign": "off", - "no-implicit-coercion": "off", - "no-implicit-globals": "off", - "no-implied-eval": "off", - "no-inline-comments": "off", - "no-inner-declarations": "off", - "no-invalid-regexp": "off", - "no-invalid-this": "off", - "no-irregular-whitespace": "off", - "no-iterator": "off", - "no-label-var": "off", - "no-labels": "off", - "no-lone-blocks": "off", - "no-lonely-if": "off", - "no-loop-func": "off", - "no-magic-numbers": "off", - "no-misleading-character-class": "off", - "no-mixed-operators": "off", - "no-mixed-requires": "off", - "no-mixed-spaces-and-tabs": "off", - "no-multi-assign": "off", - "no-multi-spaces": "off", - "no-multi-str": "off", - "no-multiple-empty-lines": "off", - "no-native-reassign": "off", - "no-negated-condition": "off", - "no-negated-in-lhs": "off", - "no-nested-ternary": "off", - "no-new": "off", - "no-new-func": "off", - "no-new-object": "off", - "no-new-require": "off", - "no-new-symbol": "off", - "no-new-wrappers": "off", - "no-obj-calls": "off", - "no-octal": "off", - "no-octal-escape": "off", - "no-param-reassign": "off", - "no-path-concat": "off", - "no-plusplus": "off", - "no-process-env": "off", - "no-process-exit": "off", - "no-proto": "off", - "no-prototype-builtins": "off", - "no-redeclare": "off", - "no-regex-spaces": "off", - "no-restricted-globals": "off", - "no-restricted-imports": "off", - "no-restricted-modules": "off", - "no-restricted-properties": "off", - "no-restricted-syntax": "off", - "no-return-assign": "off", - "no-return-await": "off", - "no-script-url": "off", - "no-self-assign": "off", - "no-self-compare": "off", - "no-sequences": "off", - "no-shadow": "off", - "no-shadow-restricted-names": "off", - "no-spaced-func": "off", - "no-sparse-arrays": "off", - "no-sync": "off", - "no-tabs": "off", - "no-template-curly-in-string": "off", - "no-ternary": "off", - "no-this-before-super": "off", - "no-throw-literal": "off", - "no-trailing-spaces": "off", - "no-undef": "off", - "no-undef-init": "off", - "no-undefined": "off", - "no-underscore-dangle": "off", - "no-unexpected-multiline": "off", - "no-unmodified-loop-condition": "off", - "no-unneeded-ternary": "off", - "no-unreachable": "off", - "no-unsafe-finally": "off", - "no-unsafe-negation": "off", - "no-unused-expressions": "off", - "no-unused-labels": "off", - "no-unused-vars": "off", - "no-use-before-define": "off", - "no-useless-call": "off", - "no-useless-computed-key": "off", - "no-useless-concat": "off", - "no-useless-constructor": "off", - "no-useless-escape": "off", - "no-useless-rename": "off", - "no-useless-return": "off", - "no-var": "off", - "no-void": "off", - "no-warning-comments": "off", - "no-whitespace-before-property": "off", - "no-with": "off", - "nonblock-statement-body-position": "off", - "object-curly-newline": "off", - "object-curly-spacing": "off", - "object-property-newline": "off", - "object-shorthand": "off", - "one-var": "off", - "one-var-declaration-per-line": "off", - "operator-assignment": "off", - "operator-linebreak": "off", - "padded-blocks": "off", - "padding-line-between-statements": "off", - "prefer-arrow-callback": "off", - "prefer-const": "off", - "prefer-destructuring": "off", - "prefer-numeric-literals": "off", - "prefer-object-spread": "off", - "prefer-promise-reject-errors": "off", - "prefer-reflect": "off", - "prefer-rest-params": "off", - "prefer-spread": "off", - "prefer-template": "off", - "quote-props": "off", - "quotes": "off", - "radix": "off", - "require-atomic-updates": "off", - "require-await": "off", - "require-jsdoc": "off", - "require-unicode-regexp": "off", - "require-yield": "off", - "rest-spread-spacing": "off", - "semi": "off", - "semi-spacing": "off", - "semi-style": "off", - "sort-imports": "off", - "sort-keys": "off", - "sort-vars": "off", - "space-before-blocks": "off", - "space-before-function-paren": "off", - "space-in-parens": "off", - "space-infix-ops": "off", - "space-unary-ops": "off", - "spaced-comment": "off", - "strict": "off", - "switch-colon-spacing": "off", - "symbol-description": "off", - "template-curly-spacing": "off", - "template-tag-spacing": "off", - "unicode-bom": "off", - "use-isnan": "off", - "valid-jsdoc": "off", - "valid-typeof": "off", - "vars-on-top": "off", - "wrap-iife": "off", - "wrap-regex": "off", - "yield-star-spacing": "off", - "yoda": "off" - } -} \ No newline at end of file diff --git a/SQLSchemaCompare.UI/Pages/Project/_DataSourcesTab.cshtml b/SQLSchemaCompare.UI/Pages/Project/_DataSourcesTab.cshtml index 32861e3a..2d99fe83 100644 --- a/SQLSchemaCompare.UI/Pages/Project/_DataSourcesTab.cshtml +++ b/SQLSchemaCompare.UI/Pages/Project/_DataSourcesTab.cshtml @@ -12,19 +12,19 @@ @if (Model.EditableDatabaseType) {