From 126e55249f78b1db7fe52cdbb6cd9cbdd3dc3095 Mon Sep 17 00:00:00 2001 From: Antoine Clausse Date: Fri, 21 Jun 2024 09:23:57 +0200 Subject: [PATCH] Add an ESLint rule enforcing kebab-case in URL paths (#18913) * Add a tsconfig.json to the eslint-plugin folder so it can be linted too * Create eslint rule `prefer-kebab-url` * Add prefer-kebab-url to service/web * Ignore lowercased strings Prevents from trying to change `v0` to `v-0` * Ignore parts between brackets or parenthesis * Record in URL paths by case lower: 241 kebab: 60 snake: 43 camel: 22 other: 5 * Revert "Record in URL paths by case" This reverts commit 262f483aafb0daa1a01e9025488cdc33f31ef67c. * Showcase how the autofix would change the code * Revert "Showcase how the autofix would change the code" This reverts commit f045292bf01623de2df5b89fc0d68737a39913dc. * Add ignored words so we don't have to update old code * Change the rule so it suggests instead of fixing This prevents eslint autofix from creating bugs * Move list of ignored words to its own file Per https://github.com/overleaf/internal/pull/18913#discussion_r1644204034 * Add comment explaining the ignore list GitOrigin-RevId: d13918b0bcba9d77120f1b61b354a79dc8fb4b4e --- package-lock.json | 6 ++++-- services/web/.eslintrc.js | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index db5e3609a2..b81526625e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -98,7 +98,8 @@ "version": "0.1.0", "license": "AGPL-3.0-only", "dependencies": { - "eslint": "^8.51.0" + "eslint": "^8.51.0", + "lodash": "^4.17.21" }, "devDependencies": { "@typescript-eslint/parser": "^6.7.5" @@ -52218,7 +52219,8 @@ "version": "file:libraries/eslint-plugin", "requires": { "@typescript-eslint/parser": "^6.7.5", - "eslint": "^8.51.0" + "eslint": "^8.51.0", + "lodash": "^4.17.21" } }, "@overleaf/fetch-utils": { diff --git a/services/web/.eslintrc.js b/services/web/.eslintrc.js index 0aefd86d0c..ffb26f5fd0 100644 --- a/services/web/.eslintrc.js +++ b/services/web/.eslintrc.js @@ -23,6 +23,8 @@ module.exports = { // do not allow importing of implicit dependencies. 'import/no-extraneous-dependencies': 'error', + '@overleaf/prefer-kebab-url': 'error', + // disable some TypeScript rules '@typescript-eslint/no-var-requires': 'off', '@typescript-eslint/no-unused-vars': 'off',