From cbd408b32bf5f768f8091755497ef471daaae708 Mon Sep 17 00:00:00 2001 From: Dennis Oelkers Date: Tue, 28 Nov 2023 14:57:59 +0100 Subject: [PATCH 1/4] Adding prettier + shared config. --- graylog2-web-interface/.prettierrc.json | 1 + graylog2-web-interface/package.json | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 graylog2-web-interface/.prettierrc.json diff --git a/graylog2-web-interface/.prettierrc.json b/graylog2-web-interface/.prettierrc.json new file mode 100644 index 000000000000..567aa914522e --- /dev/null +++ b/graylog2-web-interface/.prettierrc.json @@ -0,0 +1 @@ +"@graylog/prettier-config" diff --git a/graylog2-web-interface/package.json b/graylog2-web-interface/package.json index 38a68d17e9e8..ed893d8bd110 100644 --- a/graylog2-web-interface/package.json +++ b/graylog2-web-interface/package.json @@ -24,7 +24,8 @@ "lint:changes": "./dev/lintChanges.sh", "test": "jest --maxWorkers=50%", "test:integration": "jest --maxWorkers=50% --config jest.it.config.js", - "check-production-build": "node checkProductionBuild.js" + "check-production-build": "node checkProductionBuild.js", + "format": "prettier --write src" }, "eslintConfig": { "extends": "graylog" @@ -116,6 +117,7 @@ "devDependencies": { "@cfaester/enzyme-adapter-react-18": "0.7.1", "@cyclonedx/webpack-plugin": "^3.9.1", + "@graylog/prettier-config": "^1.0.2", "@types/chroma-js": "^2.1.3", "@types/crossfilter": "0.0.38", "@types/enzyme-adapter-react-16": "^1.0.6", @@ -162,6 +164,7 @@ "less": "^4.1.2", "less-loader": "^12.0.0", "node-fetch": "^2.6.1", + "prettier": "^3.3.3", "puppeteer": "^23.0.2", "react-bootstrap": "0.33.1", "style-loader": "3.3.4", From 4e4c46eb06c36458d9122a6d95f6f0636aef2c52 Mon Sep 17 00:00:00 2001 From: Dennis Oelkers Date: Wed, 29 Nov 2023 08:19:03 +0100 Subject: [PATCH 2/4] Removing formatting rules from ESLint. --- graylog2-web-interface/packages/eslint-config-graylog/index.js | 3 ++- .../packages/eslint-config-graylog/package.json | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/graylog2-web-interface/packages/eslint-config-graylog/index.js b/graylog2-web-interface/packages/eslint-config-graylog/index.js index 904d65478c2d..9eea14e21e26 100644 --- a/graylog2-web-interface/packages/eslint-config-graylog/index.js +++ b/graylog2-web-interface/packages/eslint-config-graylog/index.js @@ -72,13 +72,14 @@ module.exports = { ], extends: [ 'eslint:recommended', - 'airbnb', + 'airbnb/react', 'plugin:compat/recommended', 'plugin:import/errors', 'plugin:import/warnings', 'plugin:import/react', 'plugin:jest-formatting/strict', 'plugin:graylog/recommended', + 'prettier', ], plugins: [ 'import', diff --git a/graylog2-web-interface/packages/eslint-config-graylog/package.json b/graylog2-web-interface/packages/eslint-config-graylog/package.json index 47ac29f42653..e142801f497b 100644 --- a/graylog2-web-interface/packages/eslint-config-graylog/package.json +++ b/graylog2-web-interface/packages/eslint-config-graylog/package.json @@ -19,6 +19,7 @@ "@typescript-eslint/parser": "8.12.1", "eslint": "8.57.0", "eslint-config-airbnb": "19.0.4", + "eslint-config-prettier": "9.1.0", "eslint-import-resolver-webpack": "0.13.9", "eslint-plugin-compat": "4.2.0", "eslint-plugin-graylog": "file:../eslint-plugin-graylog", From 67c0ab66d20026f6ef8007b425f1d76fb2cf13d6 Mon Sep 17 00:00:00 2001 From: Dennis Oelkers Date: Tue, 20 Feb 2024 09:09:47 +0100 Subject: [PATCH 3/4] Removing formatting rules conflicting with prettier from ESLint preset. --- .../packages/eslint-config-graylog/index.js | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/graylog2-web-interface/packages/eslint-config-graylog/index.js b/graylog2-web-interface/packages/eslint-config-graylog/index.js index 9eea14e21e26..654325347f7e 100644 --- a/graylog2-web-interface/packages/eslint-config-graylog/index.js +++ b/graylog2-web-interface/packages/eslint-config-graylog/index.js @@ -72,7 +72,7 @@ module.exports = { ], extends: [ 'eslint:recommended', - 'airbnb/react', + 'airbnb', 'plugin:compat/recommended', 'plugin:import/errors', 'plugin:import/warnings', @@ -90,7 +90,6 @@ module.exports = { rules: { 'arrow-body-style': ['error', 'as-needed'], camelcase: 'off', - 'function-paren-newline': 'off', 'import/extensions': 'off', 'import/no-extraneous-dependencies': 'off', 'import/no-unresolved': 'off', @@ -122,18 +121,12 @@ module.exports = { }], }], 'no-underscore-dangle': 'off', - 'object-curly-newline': ['error', { multiline: true, consistent: true }], 'object-shorthand': ['error', 'methods'], 'react/destructuring-assignment': 'off', 'react/forbid-prop-types': 'off', 'react/function-component-definition': 'off', - 'react/jsx-closing-bracket-location': ['warn', 'after-props'], - 'react/jsx-curly-spacing': ['warn', { when: 'never', children: true }], 'react/jsx-filename-extension': [1, { extensions: ['.jsx', '.tsx'] }], - 'react/jsx-first-prop-new-line': ['warn', 'never'], - 'react/jsx-indent-props': ['error', 'first'], 'react/jsx-no-useless-fragment': ['error', { allowExpressions: true }], - 'react/jsx-one-expression-per-line': 'off', 'react/jsx-props-no-spreading': 'off', 'react/prefer-es6-class': 'off', 'react/prefer-stateless-function': 'warn', @@ -163,13 +156,13 @@ module.exports = { }, { blankLine: 'always', - prev: ['block', 'multiline-block-like', 'cjs-export', 'class', 'multiline-expression'], + prev: ['block', 'cjs-export', 'class'], next: '*', }, { blankLine: 'always', prev: '*', - next: ['block', 'multiline-block-like', 'class', 'multiline-expression', 'return'], + next: ['block', 'class', 'return'], }, ], }, From d797edcff5a22b7f31a2f6d5f863fc469b4144d2 Mon Sep 17 00:00:00 2001 From: Dennis Oelkers Date: Fri, 1 Nov 2024 14:17:47 +0100 Subject: [PATCH 4/4] Run `prettier` in auto-fixing job as well. --- .github/workflows/fix-linter-hints.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/fix-linter-hints.yml b/.github/workflows/fix-linter-hints.yml index 8830a5f46f3e..2efe8f782716 100644 --- a/.github/workflows/fix-linter-hints.yml +++ b/.github/workflows/fix-linter-hints.yml @@ -36,6 +36,9 @@ jobs: continue-on-error: true working-directory: graylog2-web-interface run: yarn lint --fix -o /tmp/report.json -f json + - name: Runt prettier + working-directory: graylog2-web-interface + run: yarn format - name: Run lint:styles --fix continue-on-error: true working-directory: graylog2-web-interface @@ -54,7 +57,7 @@ jobs: author: Dr. Lint-a-lot branch: fix/linter-hints committer: Dr. Lint-a-lot - commit-message: Running lint --fix + commit-message: Running lint --fix & prettier delete-branch: true - name: Get headRef and SHA of PR