Explorar el Código

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
Antoine Clausse hace 2 años
padre
commit
3d5418611b
Se han modificado 2 ficheros con 6 adiciones y 2 borrados
  1. 4 2
      package-lock.json
  2. 2 0
      services/web/.eslintrc.js

+ 4 - 2
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": {

+ 2 - 0
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',