diff --git a/README.md b/README.md index 3a54b29145..fba9e96129 100644 --- a/README.md +++ b/README.md @@ -129,6 +129,24 @@ Enhance your collaborative experience with diagrams, drawings, and more using th make deploy YOUR_USERNAME=${username} YOUR_PASSWORD=${password} ``` +## Code style + +We maintain a consistent code style and adhere to best practices using ESLint. Our lint rules are enforced through a pre-commit hook to ensure commits follow the established guidelines. + +To check for code style issues in both the client and whiteboard directories, you can use the following command: + +```sh +npm run lint +``` + +To automatically fix some of the linting issues, you can use the following command: + +```sh +npm run lint:fix +``` + +These commands help maintain a clean and uniform codebase, ensuring readability and adherence to coding standards. + ## Gitpod Setup Guide Follow these steps to set up your development environment using Gitpod: diff --git a/client/.eslintric.json b/client/.eslintric.json new file mode 100644 index 0000000000..788435adf5 --- /dev/null +++ b/client/.eslintric.json @@ -0,0 +1,23 @@ +{ + "env": { + "browser": true, + "es2021": true + }, + "extends": [ + "eslint:recommended", + "plugin:@typescript-eslint/recommended", + "plugin:react/recommended" + ], + "settings": { + "react": { + "version": "detect" + } + }, + "parser": "@typescript-eslint/parser", + "parserOptions": { + "ecmaVersion": "latest", + "sourceType": "module" + }, + "plugins": ["@typescript-eslint", "react"], + "rules": {} + } \ No newline at end of file diff --git a/client/package.json b/client/package.json index 727a088736..bd8ec95592 100644 --- a/client/package.json +++ b/client/package.json @@ -6,7 +6,9 @@ "scripts": { "dev": "webpack serve", "build": "webpack --mode development", - "build:excalidraw": "node scripts/build.js" + "build:excalidraw": "node scripts/build.js", + "lint": "eslint --ext .js,.ts,.jsx,.tsx src", + "lint:fix": "eslint --ext .js,.ts,.jsx,.tsx src --fix" }, "dependencies": { "@dwelle/tunnel-rat": "^0.1.1", diff --git a/whiteboard/.eslintric.json b/whiteboard/.eslintric.json new file mode 100644 index 0000000000..3a70c56a73 --- /dev/null +++ b/whiteboard/.eslintric.json @@ -0,0 +1,23 @@ +{ + "env": { + "browser": true, + "es2021": true + }, + "extends": [ + "eslint:recommended", + "plugin:@typescript-eslint/recommended", + "plugin:react/recommended" + ], + "settings": { + "react": { + "version": "detect" + } + }, + "parser": "@typescript-eslint/parser", + "parserOptions": { + "ecmaVersion": "latest", + "sourceType": "module" + }, + "plugins": ["@typescript-eslint", "react"], + "rules": {} +} diff --git a/whiteboard/package.json b/whiteboard/package.json index 6600b40372..bbad356488 100644 --- a/whiteboard/package.json +++ b/whiteboard/package.json @@ -1,7 +1,17 @@ { + "scripts": { + "lint": "eslint .", + "lint:fix": "eslint . --fix" + }, "devDependencies": { "@rocket.chat/apps-engine": "^1.40.0", "@types/node": "14.14.6", + "@typescript-eslint/eslint-plugin": "^5.62.0", + "@typescript-eslint/parser": "^5.62.0", + "eslint": "^8.56.0", + "eslint-plugin-react": "^7.33.2", + "eslint-plugin-react-hooks": "^4.6.0", + "eslint-plugin-react-refresh": "^0.4.5", "tslint": "^5.10.0", "typescript": "^4.0.5" }