diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..57becb87 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,16 @@ +# For more information about the properties used in +# this file, please see the EditorConfig documentation: +# https://editorconfig.org/ + +root = true + +[*] +charset = utf-8 +end_of_line = lf +indent_size = 4 +indent_style = space +insert_final_newline = true +trim_trailing_whitespace = true + +[*.md] +trim_trailing_whitespace = false diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 291f5b23..96a3e636 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -1,18 +1,103 @@ module.exports = { - root: true, - env: { browser: true, es2020: true }, - extends: [ - 'eslint:recommended', - 'plugin:@typescript-eslint/recommended', - 'plugin:react-hooks/recommended', - ], - ignorePatterns: ['dist', '.eslintrc.js'], - parser: '@typescript-eslint/parser', - plugins: ['react-refresh'], - rules: { - 'react-refresh/only-export-components': [ - 'warn', - { allowConstantExport: true }, + extends: [ + 'eslint:recommended', + 'plugin:@typescript-eslint/recommended', + 'plugin:import/errors', + 'plugin:import/react', + 'plugin:import/warnings', + 'plugin:react/recommended', + 'plugin:react-hooks/recommended', + 'plugin:prettier/recommended', ], - }, + + // unignore implicit rules about what types of files can be linted + ignorePatterns: ['!.*', 'dist'], + + env: { + browser: true, + node: true, + jest: true, + es2020: true, + }, + + parser: '@typescript-eslint/parser', + + settings: { + react: { + version: 'detect', + }, + "import/resolver": { + "node": { + "extensions": [".js", ".jsx", ".ts", ".tsx"] + } + } + }, + + parserOptions: { + // latest standard is ok, eq. to 9 + ecmaVersion: 2018, + ecmaFeatures: { + jsx: true, + }, + sourceType: 'module', + }, + + rules: { + 'react/react-in-jsx-scope': 'off', + 'max-params': [ + 'error', + { + max: 3, + }, + ], + 'prefer-const': [ + 'error', + { + destructuring: 'any', + ignoreReadBeforeAssign: false, + }, + ], + 'no-mixed-spaces-and-tabs': ['error'], + 'import/order': [ + 'error', + { + 'newlines-between': 'never', + alphabetize: { + order: 'asc', + caseInsensitive: true, + }, + }, + ], + curly: ['error'], + 'import/extensions': ['error', 'ignorePackages', { '': 'never' }], + 'react-hooks/rules-of-hooks': 'error', + 'react-hooks/exhaustive-deps': 'warn', + 'react/sort-prop-types': [ + 'error', + { + requiredFirst: true, + sortShapeProp: true, + callbacksLast: true, + }, + ], + 'react/no-unused-prop-types': 'error', + }, + + // old + // root: true, + // env: { browser: true, es2020: true }, + // extends: [ + // 'eslint:recommended', + // 'plugin:@typescript-eslint/recommended', + // 'plugin:react-hooks/recommended', + // ], + // ignorePatterns: ['dist', '.eslintrc.js'], + // parser: '@typescript-eslint/parser', + // plugins: ['react-refresh'], + // rules: { + // 'react-refresh/only-export-components': [ + // 'warn', + // { allowConstantExport: true }, + // ], + // }, } diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 00000000..03cdc9b0 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,6 @@ +# The following files are yaml templates and produce SyntaxErrors with prettier +helm/chart/templates/deployment.yaml +helm/chart/templates/hpa.yaml +helm/chart/templates/ingress.yaml +helm/chart/templates/serviceaccount.yaml +helm/chart/templates/tests/test-connection.yaml diff --git a/.prettierrc.cjs b/.prettierrc.cjs new file mode 100644 index 00000000..452f8d27 --- /dev/null +++ b/.prettierrc.cjs @@ -0,0 +1,45 @@ +// const { config } = require('@dhis2/cli-style') +// const defaultConfig = require(config.prettier) + +// module.exports = { +// ...defaultConfig, +// printWidth: 180, +// overrides: [ +// { +// files: '**/*.yml', +// options: { +// singleQuote: false, +// }, +// }, +// ], +// } + +module.exports = { + printWidth: 80, + tabWidth: 4, + useTabs: false, + semi: false, + singleQuote: true, + quoteProps: 'as-needed', + jsxSingleQuote: false, + trailingComma: 'es5', + bracketSpacing: true, + bracketSameLine: false, + arrowParens: 'always', + rangeStart: 0, + rangeEnd: Infinity, + requirePragma: false, + insertPragma: false, + proseWrap: 'preserve', + htmlWhitespaceSensitivity: 'css', + endOfLine: 'lf', + embeddedLanguageFormatting: 'auto', + overrides: [ + { + files: '**/*.yml', + options: { + singleQuote: false, + }, + }, + ], +} diff --git a/.prettierrc.js b/.prettierrc.js deleted file mode 100644 index f1a44cac..00000000 --- a/.prettierrc.js +++ /dev/null @@ -1,15 +0,0 @@ -const { config } = require('@dhis2/cli-style') -const defaultConfig = require(config.prettier) - -module.exports = { - ...defaultConfig, - printWidth: 180, - overrides: [ - { - files: '**/*.yml', - options: { - singleQuote: false, - }, - }, - ], -} diff --git a/package.json b/package.json index 245fc798..47b14cef 100644 --- a/package.json +++ b/package.json @@ -2,15 +2,16 @@ "name": "my-vue-app", "private": true, "version": "0.0.0", - "__type": "module ;; doesn't work with our tooling setup, should be updated as it's deprecated! See https://vitejs.dev/guide/troubleshooting.html#vite-cjs-node-api-deprecated", + "type": "module", "scripts": { "start": "vite --port 3000", "build": "tsc -b && vite build", "preview": "vite preview", "test": "jest test", - "format": "yarn _lint --fix && yarn d2-style apply", - "_lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0", - "lint": "yarn _lint && yarn d2-style check", + "eslint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0", + "prettier": "prettier .", + "lint": "yarn eslint && yarn prettier --check", + "format": "yarn eslint --fix && yarn prettier --write", "e2e": "yarn playwright test --ui", "generate-types": "rm -rf ./src/types/generated && yarn openapi --input https://dev.api.im.dhis2.org/swagger.yaml --output ./src/types/generated --client axios --useOptions --useUnionTypes --exportCore false --exportServices false --exportModels true --exportSchemas false && yarn prettier src/types/generated --write --loglevel silent" }, @@ -48,12 +49,17 @@ "dotenv": "^16.4.5", "dotenv-expand": "^11.0.6", "eslint": "^8.57.0", + "eslint-config-prettier": "^9.1.0", + "eslint-plugin-import": "^2.29.1", + "eslint-plugin-prettier": "^5.2.1", + "eslint-plugin-react": "^7.35.0", "eslint-plugin-react-hooks": "^4.6.2", "eslint-plugin-react-refresh": "^0.4.7", "jest": "^29.7.0", "openapi-typescript-codegen": "^0.29.0", "playwright": "1.44.1", "playwright-core": "1.44.1", + "prettier": "^3.3.3", "styled-jsx": "^5.1.6", "ts-jest": "^29.2.2", "typescript": "^5.2.2", diff --git a/yarn.lock b/yarn.lock index e8c122ae..1cf9ad12 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2629,6 +2629,11 @@ "@nodelib/fs.scandir" "2.1.5" fastq "^1.6.0" +"@pkgr/core@^0.1.0": + version "0.1.1" + resolved "https://registry.yarnpkg.com/@pkgr/core/-/core-0.1.1.tgz#1ec17e2edbec25c8306d424ecfbf13c7de1aaa31" + integrity sha512-cq8o4cWH0ibXh9VGi5P20Tu9XF/0fFXl9EUinr9QfTM7a7p0oTA4iJRCQWppXR1Pg8dSM0UCItCkPwsk9qWWYA== + "@playwright/test@1.44.1": version "1.44.1" resolved "https://registry.yarnpkg.com/@playwright/test/-/test-1.44.1.tgz#cc874ec31342479ad99838040e99b5f604299bcb" @@ -4531,6 +4536,11 @@ eslint-config-prettier@^8.3.0: resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-8.10.0.tgz#3a06a662130807e2502fc3ff8b4143d8a0658e11" integrity sha512-SM8AMJdeQqRYT9O9zguiruQZaN7+z+E4eAP9oiLNGKMtomwaB1E9dcgUD6ZAn/eQAb52USbvezbiljfZUhbJcg== +eslint-config-prettier@^9.1.0: + version "9.1.0" + resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-9.1.0.tgz#31af3d94578645966c082fcb71a5846d3c94867f" + integrity sha512-NSWl5BFQWEPi1j4TjVNItzYV7dZXZ+wP6I6ZhrBGpChQhZRUaElihE9uRRkcbRnNb76UMKDF3r+WTmNcGPKsqw== + eslint-import-resolver-node@^0.3.9: version "0.3.9" resolved "https://registry.yarnpkg.com/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.9.tgz#d4eaac52b8a2e7c3cd1903eb00f7e053356118ac" @@ -4547,7 +4557,7 @@ eslint-module-utils@^2.8.0: dependencies: debug "^3.2.7" -eslint-plugin-import@^2.22.1: +eslint-plugin-import@^2.22.1, eslint-plugin-import@^2.29.1: version "2.29.1" resolved "https://registry.yarnpkg.com/eslint-plugin-import/-/eslint-plugin-import-2.29.1.tgz#d45b37b5ef5901d639c15270d74d46d161150643" integrity sha512-BbPC0cuExzhiMo4Ff1BTVwHpjjv28C5R+btTOGaCRC7UEz801up0JadwkeSk5Ued6TG34uaczuVuH6qyy5YUxw== @@ -4570,6 +4580,14 @@ eslint-plugin-import@^2.22.1: semver "^6.3.1" tsconfig-paths "^3.15.0" +eslint-plugin-prettier@^5.2.1: + version "5.2.1" + resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-5.2.1.tgz#d1c8f972d8f60e414c25465c163d16f209411f95" + integrity sha512-gH3iR3g4JfF+yYPaJYkN7jEl9QbweL/YfkoRlNnuIEHEz1vHVlCmWOS+eGGiRuzHQXdJFCOTxRgvju9b8VUmrw== + dependencies: + prettier-linter-helpers "^1.0.0" + synckit "^0.9.1" + eslint-plugin-react-hooks@^4.6.2: version "4.6.2" resolved "https://registry.yarnpkg.com/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-4.6.2.tgz#c829eb06c0e6f484b3fbb85a97e57784f328c596" @@ -4605,6 +4623,30 @@ eslint-plugin-react@^7.31.10: string.prototype.matchall "^4.0.11" string.prototype.repeat "^1.0.0" +eslint-plugin-react@^7.35.0: + version "7.35.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-react/-/eslint-plugin-react-7.35.0.tgz#00b1e4559896710e58af6358898f2ff917ea4c41" + integrity sha512-v501SSMOWv8gerHkk+IIQBkcGRGrO2nfybfj5pLxuJNFTPxxA3PSryhXTK+9pNbtkggheDdsC0E9Q8CuPk6JKA== + dependencies: + array-includes "^3.1.8" + array.prototype.findlast "^1.2.5" + array.prototype.flatmap "^1.3.2" + array.prototype.tosorted "^1.1.4" + doctrine "^2.1.0" + es-iterator-helpers "^1.0.19" + estraverse "^5.3.0" + hasown "^2.0.2" + jsx-ast-utils "^2.4.1 || ^3.0.0" + minimatch "^3.1.2" + object.entries "^1.1.8" + object.fromentries "^2.0.8" + object.values "^1.2.0" + prop-types "^15.8.1" + resolve "^2.0.0-next.5" + semver "^6.3.1" + string.prototype.matchall "^4.0.11" + string.prototype.repeat "^1.0.0" + eslint-scope@^5.1.1: version "5.1.1" resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-5.1.1.tgz#e786e59a66cb92b3f6c1fb0d508aab174848f48c" @@ -4858,6 +4900,11 @@ fast-deep-equal@^3.1.1, fast-deep-equal@^3.1.3: resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525" integrity sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q== +fast-diff@^1.1.2: + version "1.3.0" + resolved "https://registry.yarnpkg.com/fast-diff/-/fast-diff-1.3.0.tgz#ece407fa550a64d638536cd727e129c61616e0f0" + integrity sha512-VxPP4NqbUjj6MaAOafWeUn2cXWLcCtljklUtZf0Ind4XQ+QPtmA0b18zZy0jIQx+ExRVCR/ZQpBmik5lXshNsw== + fast-glob@^3.2.5, fast-glob@^3.2.9, fast-glob@^3.3.2: version "3.3.2" resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.3.2.tgz#a904501e57cfdd2ffcded45e99a54fef55e46129" @@ -7176,11 +7223,23 @@ prepend-http@^2.0.0: resolved "https://registry.yarnpkg.com/prepend-http/-/prepend-http-2.0.0.tgz#e92434bfa5ea8c19f41cdfd401d741a3c819d897" integrity sha512-ravE6m9Atw9Z/jjttRUZ+clIXogdghyZAuWJ3qEzjT+jI/dL1ifAqhZeC5VHzQp1MSt1+jxKkFNemj/iO7tVUA== +prettier-linter-helpers@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz#d23d41fe1375646de2d0104d3454a3008802cf7b" + integrity sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w== + dependencies: + fast-diff "^1.1.2" + prettier@^2.4.1: version "2.8.8" resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.8.8.tgz#e8c5d7e98a4305ffe3de2e1fc4aca1a71c28b1da" integrity sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q== +prettier@^3.3.3: + version "3.3.3" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.3.3.tgz#30c54fe0be0d8d12e6ae61dbb10109ea00d53105" + integrity sha512-i2tDNA0O5IrMO757lfrdQZCc2jPNDVntV0m/+4whiDfWaTKfMNgR7Qz0NAeGz/nRqF4m5/6CLzbP4/liHt12Ew== + pretty-format@^27.0.2: version "27.5.1" resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-27.5.1.tgz#2181879fdea51a7a5851fb39d920faa63f01d88e" @@ -8159,6 +8218,14 @@ svg-tags@^1.0.0: resolved "https://registry.yarnpkg.com/svg-tags/-/svg-tags-1.0.0.tgz#58f71cee3bd519b59d4b2a843b6c7de64ac04764" integrity sha512-ovssysQTa+luh7A5Weu3Rta6FJlFBBbInjOh722LIt6klpU2/HtdUbszju/G4devcvk8PGt7FCLv5wftu3THUA== +synckit@^0.9.1: + version "0.9.1" + resolved "https://registry.yarnpkg.com/synckit/-/synckit-0.9.1.tgz#febbfbb6649979450131f64735aa3f6c14575c88" + integrity sha512-7gr8p9TQP6RAHusBOSLs46F4564ZrjV8xFmw5zCmgmhGUcw2hxsShhJ6CEiHQMgPDwAQ1fWHPM0ypc4RMAig4A== + dependencies: + "@pkgr/core" "^0.1.0" + tslib "^2.6.2" + table@^6.0.9, table@^6.8.2: version "6.8.2" resolved "https://registry.yarnpkg.com/table/-/table-6.8.2.tgz#c5504ccf201213fa227248bdc8c5569716ac6c58" @@ -8298,7 +8365,7 @@ tslib@^1.9.0: resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00" integrity sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg== -tslib@^2.3.1: +tslib@^2.3.1, tslib@^2.6.2: version "2.6.3" resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.6.3.tgz#0438f810ad7a9edcde7a241c3d80db693c8cbfe0" integrity sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ==