Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Migrate stylistic rules to ESLint Stylistic

Alexander Brandon Coles8402231e5788
diff --git a/frontend/eslint.config.mjs b/frontend/eslint.config.mjs
index aa8615537ae..0dbc166a8f6 100644
--- a/frontend/eslint.config.mjs
+++ b/frontend/eslint.config.mjs
@@ -3,6 +3,8 @@ import globals from 'globals';
import tseslint from 'typescript-eslint';
import jasmine from 'eslint-plugin-jasmine';
import angular from 'angular-eslint';
+import stylistic from '@stylistic/eslint-plugin';
+
// import airbnb from 'eslint-config-airbnb-base';
// import tsairbnb from 'eslint-config-airbnb-typescript';
@@ -63,19 +65,9 @@ const config = defineConfig([
'no-unused-vars': ['error', { varsIgnorePattern: '^_', argsIgnorePattern: '^_' }],
'@typescript-eslint/no-unused-vars': ['error', { varsIgnorePattern: '^_', argsIgnorePattern: '^_' }],
- // Who cares about line length
- 'max-len': 'off',
-
- // Disable forcing newlines in braces to prevent empty objects and import errors
- 'object-curly-newline': 'off',
-
// Allow short circuit evaluations
'@typescript-eslint/no-unused-expressions': ['error', { allowShortCircuit: true }],
- // Force single quotes to align with ruby
- quotes: 'off',
- //'@typescript-eslint/quotes': ['error', 'single', { avoidEscape: true }],
-
// Disable webpack loader definitions
'import/no-webpack-loader-syntax': 'off',
// Disable order style as it's not compatible with intellij import organization
@@ -90,9 +82,6 @@ const config = defineConfig([
// destructuring doesn't always look better, only when object/array destructuring
'prefer-destructuring': 'off',
- // Sometimes, arrow functions implicit return looks better below, so allow both
- 'implicit-arrow-linebreak': 'off',
-
// Sometimes, arrow functions look better broken down
'arrow-body-style': 'off',
@@ -104,13 +93,6 @@ const config = defineConfig([
'no-use-before-define': ['error', { functions: false, classes: false }],
'@typescript-eslint/no-use-before-define': ['error', { functions: false, classes: false }],
- // Allow subsequent single fields in typescript classes
- // '@typescript-eslint/lines-between-class-members': ['error', 'always', { exceptAfterSingleLine: true }],
-
- // Disable indentation rule as it breaks in edge cases and is covered by editorconfig
- indent: 'off',
- '@typescript-eslint/indent': 'off',
-
// Allow namespaces, they are generated into flat functions and we don't care about modules for helpers
'@typescript-eslint/no-namespace': 'off',
@@ -120,21 +102,6 @@ const config = defineConfig([
'@typescript-eslint/no-use-before-define': 'off',
*/
- // Whitespace configuration
- // '@typescript-eslint/type-annotation-spacing': [
- // 'error',
- // {
- // before: false,
- // after: false,
- // overrides: {
- // arrow: {
- // before: true,
- // after: true,
- // },
- // },
- // },
- // ],
-
// Allow writing type union and type intersections without space
'@typescript-eslint/space-infix-ops': 'off',
@@ -174,8 +141,6 @@ const config = defineConfig([
// It's common in Angular to wrap even pure functions in classes for injection purposes
'class-methods-use-this': 'off',
-
- 'spaced-comment': 'off',
},
},
{
@@ -205,6 +170,47 @@ const config = defineConfig([
'max-classes-per-file': 'off',
},
},
+ {
+ plugins: { '@stylistic': stylistic },
+ rules: {
+ '@stylistic/semi': ['error', 'always'],
+
+ // Who cares about line length
+ '@stylistic/max-len': 'off',
+
+ // Disable forcing newlines in braces to prevent empty objects and import errors
+ '@stylistic/object-curly-newline': 'off',
+
+ // Force single quotes to align with ruby
+ '@stylistic/quotes': ['error', 'single', { avoidEscape: true }],
+
+ // Sometimes, arrow functions implicit return looks better below, so allow both
+ '@stylistic/implicit-arrow-linebreak': 'off',
+
+ // Allow subsequent single fields in typescript classes
+ '@stylistic/lines-between-class-members': ['error', 'always', { exceptAfterSingleLine: true }],
+
+ // Disable indentation rule as it breaks in edge cases and is covered by editorconfig
+ '@stylistic/indent': 'off',
+
+ // Whitespace configuration
+ '@stylistic/type-annotation-spacing': [
+ 'error',
+ {
+ before: false,
+ after: false,
+ overrides: {
+ arrow: {
+ before: true,
+ after: true,
+ },
+ },
+ },
+ ],
+
+ '@stylistic/spaced-comment': 'off',
+ },
+ },
globalIgnores([
'**/.eslintrc.js',
'**/vendor',
diff --git a/frontend/package-lock.json b/frontend/package-lock.json
index 93691d5e325..426d7b0f577 100644
--- a/frontend/package-lock.json
+++ b/frontend/package-lock.json
@@ -129,6 +129,7 @@
"@html-eslint/eslint-plugin": "^0.43.0",
"@html-eslint/parser": "^0.43.0",
"@jsdevtools/coverage-istanbul-loader": "3.0.5",
+ "@stylistic/eslint-plugin": "^5.2.2",
"@types/codemirror": "5.60.5",
"@types/dom-navigation": "^1.0.3",
"@types/dragula": "^3.7.5",
@@ -7492,6 +7493,67 @@
"@hotwired/stimulus": "^3"
}
},
+ "node_modules/@stylistic/eslint-plugin": {
+ "version": "5.2.2",
+ "resolved": "https://registry.npmjs.org/@stylistic/eslint-plugin/-/eslint-plugin-5.2.2.tgz",
+ "integrity": "sha512-bE2DUjruqXlHYP3Q2Gpqiuj2bHq7/88FnuaS0FjeGGLCy+X6a07bGVuwtiOYnPSLHR6jmx5Bwdv+j7l8H+G97A==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@eslint-community/eslint-utils": "^4.7.0",
+ "@typescript-eslint/types": "^8.37.0",
+ "eslint-visitor-keys": "^4.2.1",
+ "espree": "^10.4.0",
+ "estraverse": "^5.3.0",
+ "picomatch": "^4.0.3"
+ },
+ "engines": {
+ "node": "^18.18.0 || ^20.9.0 || >=21.1.0"
+ },
+ "peerDependencies": {
+ "eslint": ">=9.0.0"
+ }
+ },
+ "node_modules/@stylistic/eslint-plugin/node_modules/@typescript-eslint/types": {
+ "version": "8.38.0",
+ "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.38.0.tgz",
+ "integrity": "sha512-wzkUfX3plUqij4YwWaJyqhiPE5UCRVlFpKn1oCRn2O1bJ592XxWJj8ROQ3JD5MYXLORW84063z3tZTb/cs4Tyw==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": "^18.18.0 || ^20.9.0 || >=21.1.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/typescript-eslint"
+ }
+ },
+ "node_modules/@stylistic/eslint-plugin/node_modules/eslint-visitor-keys": {
+ "version": "4.2.1",
+ "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.2.1.tgz",
+ "integrity": "sha512-Uhdk5sfqcee/9H/rCOJikYz67o0a2Tw2hGRPOG2Y1R2dg7brRe1uG0yaNQDHu+TO/uQPF/5eCapvYSmHUjt7JQ==",
+ "dev": true,
+ "license": "Apache-2.0",
+ "engines": {
+ "node": "^18.18.0 || ^20.9.0 || >=21.1.0"
+ },
+ "funding": {
+ "url": "https://opencollective.com/eslint"
+ }
+ },
+ "node_modules/@stylistic/eslint-plugin/node_modules/picomatch": {
+ "version": "4.0.3",
+ "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz",
+ "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=12"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/jonschlinkert"
+ }
+ },
"node_modules/@tiptap/core": {
"version": "2.22.3",
"resolved": "https://registry.npmjs.org/@tiptap/core/-/core-2.22.3.tgz",
@@ -31345,6 +31407,40 @@
"resolved": "https://registry.npmjs.org/@stimulus-components/auto-submit/-/auto-submit-6.0.0.tgz",
"integrity": "sha512-GBwjjnNuDZey9kdJinTGyrkIMCNVnPrTQvqihC0pBiwieIMfZIp+TT7Giee0Z0DS+pX6WdJweIeo8xEYD/VZJg=="
},
+ "@stylistic/eslint-plugin": {
+ "version": "5.2.2",
+ "resolved": "https://registry.npmjs.org/@stylistic/eslint-plugin/-/eslint-plugin-5.2.2.tgz",
+ "integrity": "sha512-bE2DUjruqXlHYP3Q2Gpqiuj2bHq7/88FnuaS0FjeGGLCy+X6a07bGVuwtiOYnPSLHR6jmx5Bwdv+j7l8H+G97A==",
+ "dev": true,
+ "requires": {
+ "@eslint-community/eslint-utils": "^4.7.0",
+ "@typescript-eslint/types": "^8.37.0",
+ "eslint-visitor-keys": "^4.2.1",
+ "espree": "^10.4.0",
+ "estraverse": "^5.3.0",
+ "picomatch": "^4.0.3"
+ },
+ "dependencies": {
+ "@typescript-eslint/types": {
+ "version": "8.38.0",
+ "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.38.0.tgz",
+ "integrity": "sha512-wzkUfX3plUqij4YwWaJyqhiPE5UCRVlFpKn1oCRn2O1bJ592XxWJj8ROQ3JD5MYXLORW84063z3tZTb/cs4Tyw==",
+ "dev": true
+ },
+ "eslint-visitor-keys": {
+ "version": "4.2.1",
+ "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.2.1.tgz",
+ "integrity": "sha512-Uhdk5sfqcee/9H/rCOJikYz67o0a2Tw2hGRPOG2Y1R2dg7brRe1uG0yaNQDHu+TO/uQPF/5eCapvYSmHUjt7JQ==",
+ "dev": true
+ },
+ "picomatch": {
+ "version": "4.0.3",
+ "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz",
+ "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==",
+ "dev": true
+ }
+ }
+ },
"@tiptap/core": {
"version": "2.22.3",
"resolved": "https://registry.npmjs.org/@tiptap/core/-/core-2.22.3.tgz",
diff --git a/frontend/package.json b/frontend/package.json
index dc76ee2ec8b..4408cc88c3e 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -17,6 +17,7 @@
"@html-eslint/eslint-plugin": "^0.43.0",
"@html-eslint/parser": "^0.43.0",
"@jsdevtools/coverage-istanbul-loader": "3.0.5",
+ "@stylistic/eslint-plugin": "^5.2.2",
"@types/codemirror": "5.60.5",
"@types/dom-navigation": "^1.0.3",
"@types/dragula": "^3.7.5",