From f25f979bc3e26a87f2ab5034852486c4a718e57d Mon Sep 17 00:00:00 2001 From: Nikolai Evseev Date: Wed, 29 May 2024 13:44:38 +0100 Subject: [PATCH] (refactor) Using custom logic for lint command --- .eslintrc.js | 5 +++-- .prettierrc | 3 ++- package.json | 2 +- run-eslint.js | 21 +++++++++++++++++++++ 4 files changed, 27 insertions(+), 4 deletions(-) create mode 100644 run-eslint.js diff --git a/.eslintrc.js b/.eslintrc.js index 1930749473..b0bfa0b4fd 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -8,17 +8,18 @@ module.exports = { 'eslint:recommended', 'plugin:@typescript-eslint/eslint-recommended', 'plugin:@typescript-eslint/recommended', - 'prettier', + 'plugin:prettier/recommended', ], rules: { 'no-console': 'off', '@typescript-eslint/no-explicit-any': 'off', '@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }], semi: [2, 'always'], - 'prettier/prettier': 'error', + 'prettier/prettier': ['error', { trailingComma: 'es5' }], '@typescript-eslint/no-var-requires': 'off', '@typescript-eslint/explicit-module-boundary-types': 'off', '@typescript-eslint/no-inferrable-types': 'off', '@typescript-eslint/no-namespace': 'off', + 'comma-dangle': 'off', }, }; diff --git a/.prettierrc b/.prettierrc index 1d296fb672..92f97e7562 100644 --- a/.prettierrc +++ b/.prettierrc @@ -1,5 +1,6 @@ { "semi": true, "singleQuote": true, - "tabWidth": 2 + "tabWidth": 2, + "trailingComma": "es5" } diff --git a/package.json b/package.json index ef6c88127c..8d0cc0ecc2 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "clean": "rm -rf ./node_modules && rm -rf ./coverage && rm -rf ./logs && yarn run clean:config", "clean:config": "find ./conf -maxdepth 1 -regextype posix-extended -regex '.*.*' -delete", "format": "prettier . --write", - "lint": "eslint src test test-scripts --format table --fix", + "lint": "node ./run-eslint.js", "dev": "nodemon src/index.ts", "dev:debug": "NODE_ENV=dev DEBUG=* nodemon src/index.ts", "start": "/bin/bash ./startup.sh", diff --git a/run-eslint.js b/run-eslint.js new file mode 100644 index 0000000000..249a12f5ff --- /dev/null +++ b/run-eslint.js @@ -0,0 +1,21 @@ +// This script runs eslint on the src and test directories synchronously, and logs the output to the console. +// We can use async way but for now this is better for tracking the output. +const { execSync } = require('child_process'); + +// TODO: 'test-bronze' is a directory is too big to check all at once, keep it separate for now +const directories = ['src', 'test', 'test-helpers']; + +directories.forEach((dir) => { + console.log(`Checking directory: ${dir}`); + try { + const result = execSync(`eslint ${dir} --format table --fix`, { + stdio: 'inherit', + }); + console.log(result.toString()); + } catch (err) { + console.error( + `Error checking directory ${dir}:`, + err.stdout?.toString() || err.message || err + ); + } +});