diff --git a/.eslintrc.cjs b/.eslintrc.cjs new file mode 100644 index 0000000000..1843e62bcf --- /dev/null +++ b/.eslintrc.cjs @@ -0,0 +1,39 @@ +module.exports = { + env: { + node: true, + es2021: true, + }, + parser: "@typescript-eslint/parser", + plugins: ["prettier", "@typescript-eslint", "simple-import-sort"], + extends: [ + "eslint:recommended", + "plugin:@typescript-eslint/eslint-recommended", + "plugin:@typescript-eslint/recommended", + "prettier", + ], + parserOptions: { + ecmaVersion: "latest", + sourceType: "module", + ecmaFeatures: { + jsx: true, + }, + }, + rules: { + "no-console": 1, + eqeqeq: 2, + // indent: ["error", 2, { SwitchCase: 1 }], // disabled because it clashes with prettier's indent + quotes: ["error", "double", "avoid-escape"], + "@typescript-eslint/no-explicit-any": "off", + "prettier/prettier": [ + "error", + { + endOfLine: "auto", + tabWidth: 2, + useTabs: false, + }, + ], + "eol-last": ["error", "always"], + "simple-import-sort/imports": "error", + "simple-import-sort/exports": "error", + }, +}; diff --git a/.eslintrc.json b/.eslintrc.json deleted file mode 100644 index f89ad8299f..0000000000 --- a/.eslintrc.json +++ /dev/null @@ -1,122 +0,0 @@ -{ - "$schema": "https://json.schemastore.org/eslintrc.json", - "env": { - "browser": false, - "es2021": true, - "node": true - }, - "extends": [ - "plugin:react/recommended", - "plugin:prettier/recommended", - "plugin:react-hooks/recommended", - "plugin:jsx-a11y/recommended", - "next", - "prettier" - ], - "parser": "@typescript-eslint/parser", - "parserOptions": { - "ecmaFeatures": { - "jsx": true - }, - "ecmaVersion": 12, - "sourceType": "module" - }, - "plugins": [ - "react", - "unused-imports", - "import", - "@typescript-eslint", - "jsx-a11y", - "prettier" - ], - "rules": { - "@typescript-eslint/no-unused-vars": [ - "warn", - { - "args": "after-used", - "argsIgnorePattern": "^_.*?$", - "ignoreRestSiblings": false - } - ], - "import/order": [ - "warn", - { - "groups": [ - "type", - "builtin", - "object", - "external", - "internal", - "parent", - "sibling", - "index" - ], - "newlines-between": "always", - "pathGroups": [ - { - "group": "external", - "pattern": "~/**", - "position": "after" - } - ] - } - ], - "jsx-a11y/click-events-have-key-events": "warn", - "jsx-a11y/interactive-supports-focus": "warn", - "no-console": "warn", - "no-unused-vars": "off", - "padding-line-between-statements": [ - "warn", - { - "blankLine": "always", - "next": "return", - "prev": "*" - }, - { - "blankLine": "always", - "next": "*", - "prev": [ - "const", - "let", - "var" - ] - }, - { - "blankLine": "any", - "next": [ - "const", - "let", - "var" - ], - "prev": [ - "const", - "let", - "var" - ] - } - ], - "prettier/prettier": "warn", - "react-hooks/exhaustive-deps": "off", - "react/jsx-sort-props": [ - "warn", - { - "callbacksLast": true, - "noSortAlphabetically": true, - "reservedFirst": true, - "shorthandFirst": true - } - ], - "react/jsx-uses-react": "off", - "react/no-unescaped-entities": "off", - "react/prop-types": "off", - "react/react-in-jsx-scope": "off", - "react/self-closing-comp": "warn", - "unused-imports/no-unused-imports": "warn", - "unused-imports/no-unused-vars": "off" - }, - "settings": { - "react": { - "version": "detect" - } - } -} diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml new file mode 100644 index 0000000000..af9eee32fd --- /dev/null +++ b/.github/workflows/checks.yml @@ -0,0 +1,27 @@ +name: CI - Code Quality and Health Check + +on: + pull_request: + branches: + - main + +jobs: + test-and-coverage: + runs-on: ubuntu-latest + strategy: + matrix: + os: [ubuntu-latest] + node-version: [20.x] + steps: + - name: Checkout repository + uses: actions/checkout@v3 + with: + persist-credentials: false + - name: Setup Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + - name: Install dependencies + run: npm install + - name: Run Healthcheck + run: npm healthcheck diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 0000000000..b009dfb9d9 --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +lts/* diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000000..40b878db5b --- /dev/null +++ b/.prettierignore @@ -0,0 +1 @@ +node_modules/ \ No newline at end of file diff --git a/.prettierrc.json b/.prettierrc.json new file mode 100644 index 0000000000..b355961f7d --- /dev/null +++ b/.prettierrc.json @@ -0,0 +1,9 @@ +{ + "bracketSpacing": true, + "singleQuote": false, + "trailingComma": "all", + "tabWidth": 2, + "useTabs": false, + "semi": true, + "printWidth": 120 +} \ No newline at end of file diff --git a/package.json b/package.json index 158c6fc650..611c3b9137 100644 --- a/package.json +++ b/package.json @@ -35,15 +35,21 @@ "typescript": "5.0.4" }, "devDependencies": { - "eslint-config-prettier": "^9.1.0" + "eslint-config-prettier": "^9.1.0", + "eslint-plugin-simple-import-sort": "^12.1.1" }, - "name": "next-app-template", + "name": "prowler-next-app", "private": true, "scripts": { - "build": "next build", "dev": "next dev", - "lint": "eslint . --ext .ts,.tsx -c .eslintrc.json --fix", - "start": "next start" + "build": "next build", + "start": "next start", + "typecheck": "tsc", + "healthcheck": "npm run typecheck && npm run lint:check", + "lint:check": "./node_modules/.bin/eslint ./app", + "lint:fix": "eslint . --ext .ts,.tsx -c .eslintrc.cjs --fix", + "format:check": "./node_modules/.bin/prettier --check ./app", + "format:write": "./node_modules/.bin/prettier --config .prettierrc.json --write ./app" }, "version": "0.0.1" }