Skip to content

Commit

Permalink
feat: change basic configuration of eslint and prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
TheFenix2000 committed Sep 25, 2024
1 parent a0d234b commit fd7c0ef
Show file tree
Hide file tree
Showing 20 changed files with 3,902 additions and 338 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
build
25 changes: 0 additions & 25 deletions .eslintrc.cjs

This file was deleted.

64 changes: 64 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{
"env": {
"browser": true,
"es2021": true
},
"extends": [
"eslint:recommended",
"plugin:react/recommended",
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": 12,
"sourceType": "module"
},
"plugins": [
"react",
"@typescript-eslint",
"react-hooks",
"jsx-a11y",
"import",
"prettier"
],
"rules": {
"react/react-in-jsx-scope": "off",
"react/prop-types": "off",
"prettier/prettier": "error",
"@typescript-eslint/no-unused-vars": [
"error",
{ "argsIgnorePattern": "^_" }
],
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "warn",
"jsx-a11y/anchor-is-valid": "warn",
"import/order": [
"error",
{
"groups": ["builtin", "external", "internal"],
"pathGroups": [
{
"pattern": "react",
"group": "external",
"position": "before"
}
],
"pathGroupsExcludedImportTypes": ["react"],
"newlines-between": "always",
"alphabetize": {
"order": "asc",
"caseInsensitive": true
}
}
]
},
"settings": {
"react": {
"version": "detect"
}
}
}
29 changes: 29 additions & 0 deletions .github/workflows/formatting-tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Basic Tests

on: [push]

jobs:
formatting_tests:
name: Formatting Tests
if: github.base_ref != 'develop'
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '21'

- name: Install dependencies
run: npm install

- name: Test Prettier
run: |
npx prettier --check --config .prettierrc --log-level warn .
- name: Test ESLint
run: |
npx eslint --color --max-warnings 0 .
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
Expand Down
9 changes: 1 addition & 8 deletions .husky/.commitlintrc.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
{
"extends": ["@commitlint/config-conventional"],
"rules": {
"type-enum": [
2,
"always",
[
"feat",
"fix"
]
]
"type-enum": [2, "always", ["feat", "fix"]]
}
}
5 changes: 1 addition & 4 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx --no-install commitlint --edit
npx --no-install commitlint --edit
4 changes: 2 additions & 2 deletions .husky/hooks/check-branch-naming.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# !/bin/sh

local_branch_name=$(git rev-parse --abbrev-ref HEAD)
valid_branch_regex='^(fix|feature)\/[a-z-]{1,40}$'
valid_branch_regex='^(fix|feature)\/[a-zA-Z0-9\-]+$'
message="There is something wrong with your branch name. Branch names in this project must adhere to this contract: $valid_branch_regex. Example of correct branch name: fix/myBranchName or feature/myBranchName. Your commit will be rejected. You should rename your branch to a valid name and try again."

if echo "$local_branch_name" | grep -Eq "$valid_branch_regex"; then
Expand All @@ -10,4 +10,4 @@ if echo "$local_branch_name" | grep -Eq "$valid_branch_regex"; then
else
echo "$message"
exit 1
fi
fi
6 changes: 2 additions & 4 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npm run prepare
npx lint-staged
npm run check-branch-name
npm run check-branch-name
4 changes: 2 additions & 2 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"endOfLine": "lf",
"endOfLine": "auto",
"semi": true,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "es5"
"trailingComma": "all"
}
13 changes: 13 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"recommendations": [
"dbaeumer.vscode-eslint",
"mhutchie.git-graph",
"eamodio.gitlens",
"PKief.material-icon-theme",
"esbenp.prettier-vscode",
"Tyriar.sort-lines",
"ChakrounAnas.turbo-console-log",
"dsznajder.es7-react-js-snippets",
"zhang-renyang.vscode-react"
]
}
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
# Univent Planner Frontend
# Univent Planner Frontend
23 changes: 23 additions & 0 deletions commitlint.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const expectedTypes = ['fix', 'feat'];

module.exports = {
// extends: ['@commitlint/config-conventional'],
plugins: [
{
rules: {
'custom-type-enum': ({ type }) => {
if (!expectedTypes.includes(type)) {
return [
false,
`Type must be one of: ${expectedTypes.join(', ')} \nExample: feat: add new feature`,
];
}
return [true];
},
},
},
],
rules: {
'custom-type-enum': [2, 'always'],
},
};
Loading

0 comments on commit fd7c0ef

Please sign in to comment.