From b10f3cc78f0c85c4f68e8d55a53187d2ce6b1a8d Mon Sep 17 00:00:00 2001 From: Anissa3005 Date: Tue, 30 Jan 2024 16:07:29 +0900 Subject: [PATCH] chore: migrate to Eslint Stylistic Eslint has desided to deprecated their formatting rules. So for formatting we will use a plugin, Eslint Stylistic to be able to use the formatting rules. --- __tests__/auth.test.ts | 2 +- eslint.config.js | 223 +++---- package-lock.json | 560 +++++++++++++++++- package.json | 2 + src/resolvers.ts | 12 +- src/result.ts | 2 +- src/services/facilityService.ts | 8 +- src/services/healthcareProfessionalService.ts | 4 +- src/services/submissionService.ts | 4 +- 9 files changed, 692 insertions(+), 125 deletions(-) diff --git a/__tests__/auth.test.ts b/__tests__/auth.test.ts index b072ed22..d0c1ac32 100644 --- a/__tests__/auth.test.ts +++ b/__tests__/auth.test.ts @@ -45,7 +45,7 @@ describe('auth', () => { }) }) -export async function createTestUser() : Promise<{response: request.Response, testUserId: string}> { +export async function createTestUser() : Promise<{ response: request.Response, testUserId: string }> { const requestData = { formFields: [{ id: 'email', diff --git a/eslint.config.js b/eslint.config.js index aa908036..9fea4589 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -1,15 +1,16 @@ -import globals from 'globals' -import ts from '@typescript-eslint/eslint-plugin' -import tsParser from '@typescript-eslint/parser' -import * as graphqlESLint from '@graphql-eslint/eslint-plugin' -import eslintJsPlugin from '@eslint/js' +import globals from "globals"; +import ts from "@typescript-eslint/eslint-plugin"; +import tsParser from "@typescript-eslint/parser"; +import * as graphqlESLint from "@graphql-eslint/eslint-plugin"; +import eslintJsPlugin from "@eslint/js"; +import stylistic from "@stylistic/eslint-plugin"; -const gqlSchemaPath = './src/typeDefs/schema.graphql' +const gqlSchemaPath = "./src/typeDefs/schema.graphql"; export default [ // GLOBAL configuration { - ignores: ['dist/*'] + ignores: ["dist/*"], }, // TODO: get this linter working. For some reason, it's not picking up the schema file // GraphQL Linter for Operations and Fragments within code files @@ -42,18 +43,15 @@ export default [ { // Setup GraphQL Parser // files: ['src/**/*.{graphql,gql}'], - files: [ - '__tests__/*.ts', - 'src/*.ts' - ], + files: ["__tests__/*.ts", "src/*.ts"], plugins: { - '@graphql-eslint': graphqlESLint + "@graphql-eslint": graphqlESLint, }, languageOptions: { parser: graphqlESLint, parserOptions: { - schema: gqlSchemaPath - } + schema: gqlSchemaPath, + }, }, rules: { // ...graphqlESLint.flatConfigs['schema-recommended'].rules, @@ -61,7 +59,7 @@ export default [ // '@graphql-eslint/no-anonymous-operations': 'error', // '@graphql-eslint/no-duplicate-fields': 'error', // '@graphql-eslint/no-unreachable-types': 'error' - } + }, }, //TODO: get this linter working. Currently, when the linter runs, it wrecks the file with the wrong quotes // JSON Linter @@ -102,113 +100,126 @@ export default [ // sourceType: 'module', globals: { ...globals.node, - ...globals.es6 - } - }, - files: [ - '__tests__/**/*.ts', - 'src/**/*.ts', - 'src/**/*.js', - ], - plugins: { - '@typescript-eslint': ts, - ts + ...globals.es6, + }, }, - ignores: [ - 'src/typeDefs/gqlTypes.ts', - 'typesgeneratorconfig.ts' - ], + files: ["__tests__/**/*.ts", "src/**/*.ts", "src/**/*.js"], + plugins: { "@typescript-eslint": ts, ts, "@stylistic": stylistic }, + ignores: ["src/typeDefs/gqlTypes.ts", "typesgeneratorconfig.ts"], // 'off' or 0 - turn the rule off // 'warn' or 1 - turn the rule on as a warning (doesn’t affect exit code) // 'error' or 2 - turn the rule on as an error (exit code will be 1) rules: { // TS specific rules - ...ts.configs['eslint-recommended'].rules, + ...ts.configs["eslint-recommended"].rules, ...ts.configs.recommended.rules, - '@typescript-eslint/no-shadow': 'error', - '@typescript-eslint/no-unused-vars': 'error', - + "@typescript-eslint/no-shadow": "error", + "@typescript-eslint/no-unused-vars": "error", + // JS specific rules ...eslintJsPlugin.configs.recommended.rules, // HACK: this eslint core rule is turned off so that the typescript-eslint version can be used instead - 'no-unused-vars': 'off', - 'block-scoped-var': 'error', - complexity: ['error', { max: 40 }], - 'consistent-return': 'error', - curly: 'error', - 'dot-location': ['error', 'property'], - 'dot-notation': ['error', { allowPattern: '^[a-z]+(_[a-z]+)+$' }], - 'no-alert': 'error', - 'no-multi-spaces': 'error', - 'no-redeclare': 'error', - 'no-unused-expressions': ['error', { allowShortCircuit: true, allowTernary: true }], - 'vars-on-top': 'off', - yoda: ['error', 'never', { exceptRange: true }], - 'no-console': 'error', // we should use the logger instead + "no-unused-vars": "off", + "block-scoped-var": "error", + complexity: ["error", { max: 40 }], + "consistent-return": "error", + curly: "error", + "dot-location": ["error", "property"], + "dot-notation": ["error", { allowPattern: "^[a-z]+(_[a-z]+)+$" }], + "no-alert": "error", + "no-multi-spaces": "error", + "no-redeclare": "error", + "no-unused-expressions": [ + "error", + { allowShortCircuit: true, allowTernary: true }, + ], + "vars-on-top": "off", + yoda: ["error", "never", { exceptRange: true }], + "no-console": "error", // we should use the logger instead // Stylistic Issues and Opinions - 'arrow-body-style': 'error', - 'array-bracket-spacing': ['error', 'never'], - 'arrow-parens': ['error', 'as-needed'], - 'arrow-spacing': 'error', - 'block-spacing': ['error', 'always'], - 'brace-style': ['error', '1tbs', { allowSingleLine: true }], - camelcase: ['error', { allow: ['639_3'] }], - 'comma-dangle': ['error', 'never'], - 'comma-spacing': ['error', { before: false, after: true }], - 'comma-style': 'error', - 'computed-property-spacing': ['error', 'never'], - 'function-paren-newline': ['error', 'consistent'], - indent: [ - 'error', + // arrow-body-style is not supported by @stylistic, TypeError said to use '@/arrow-body-style', so for now I have added it like that + "@/arrow-body-style": "error", + "@stylistic/quotes": ["error", "single"], + "@stylistic/array-bracket-spacing": ["error", "never"], + "@stylistic/arrow-parens": ["error", "as-needed"], + "@stylistic/arrow-spacing": "error", + "@stylistic/block-spacing": ["error", "always"], + "brace-style": ["error", "1tbs", { allowSingleLine: true }], + camelcase: ["error", { allow: ["639_3"] }], + "@stylistic/comma-dangle": ["error", "never"], + "@stylistic/comma-spacing": [ + "error", + { before: false, after: true }, + ], + "@stylistic/comma-style": "error", + "@stylistic/computed-property-spacing": ["error", "never"], + "@stylistic/function-paren-newline": ["error", "consistent"], + "@stylistic/indent": [ + "error", 4, { MemberExpression: 1, SwitchCase: 1, - ArrayExpression: 'first', + ArrayExpression: "first", ObjectExpression: 1, - FunctionDeclaration: { parameters: 'off' }, + FunctionDeclaration: { parameters: "off" }, VariableDeclarator: { var: 2, let: 2, const: 3 }, - CallExpression: { arguments: 'first' } - } + CallExpression: { arguments: "first" }, + }, + ], + "@stylistic/key-spacing": [ + "error", + { beforeColon: false, afterColon: true }, ], - 'key-spacing': ['error', { beforeColon: false, afterColon: true }], - 'keyword-spacing': ['error', { before: true, after: true }], - 'linebreak-style': ['error', 'unix'], // no carriage returns - 'max-len': ['error', { - code: 120, - ignoreComments: true, - ignoreTrailingComments: true, - ignoreUrls: true, - ignoreStrings: true, - ignoreTemplateLiterals: true, - ignoreRegExpLiterals: true - }], // be friendly to laptops - 'newline-after-var': 'error', - 'require-atomic-updates': 'warn', - 'no-constant-condition': 'error', - 'no-dupe-class-members': 'error', - 'no-lonely-if': 'error', - 'no-multiple-empty-lines': ['error', { max: 1, maxEOF: 1 }], - 'no-underscore-dangle': 'error', - 'no-var': 'error', - 'object-curly-newline': ['error', { consistent: true }], - 'object-property-newline': ['error', { allowAllPropertiesOnSameLine: true }], - 'object-shorthand': ['error', 'methods'], - 'operator-linebreak': [0, 'before'], - 'padded-blocks': ['error', 'never'], - 'prefer-arrow-callback': 'error', - 'prefer-const': 'error', - 'prefer-spread': 'error', - 'prefer-template': 'error', - 'quote-props': ['error', 'as-needed'], - quotes: ['error', 'single', 'avoid-escape'], - semi: ['error', 'never'], - 'semi-spacing': 'error', - 'space-before-blocks': 'error', - 'space-before-function-paren': ['error', { anonymous: 'never', named: 'never', asyncArrow: 'always' }], - 'space-in-parens': 'error', - 'space-infix-ops': 'error' - } - } -] + "@stylistic/keyword-spacing": [ + "error", + { before: true, after: true }, + ], + "@stylistic/linebreak-style": ["error", "unix"], // no carriage returns + "@stylistic/max-len": [ + "error", + { + code: 120, + ignoreComments: true, + ignoreTrailingComments: true, + ignoreUrls: true, + ignoreStrings: true, + ignoreTemplateLiterals: true, + ignoreRegExpLiterals: true, + }, + ], // be friendly to laptops + "newline-after-var": "error", + "require-atomic-updates": "warn", + "no-constant-condition": "error", + "no-dupe-class-members": "error", + "no-lonely-if": "error", + "no-multiple-empty-lines": ["error", { max: 1, maxEOF: 1 }], + "no-underscore-dangle": "error", + "no-var": "error", + "object-curly-newline": ["error", { consistent: true }], + "object-property-newline": [ + "error", + { allowAllPropertiesOnSameLine: true }, + ], + "object-shorthand": ["error", "methods"], + "operator-linebreak": [0, "before"], + "padded-blocks": ["error", "never"], + "prefer-arrow-callback": "error", + "prefer-const": "error", + "prefer-spread": "error", + "prefer-template": "error", + "quote-props": ["error", "as-needed"], + quotes: ["error", "single", "avoid-escape"], + semi: ["error", "never"], + "semi-spacing": "error", + "space-before-blocks": "error", + "space-before-function-paren": [ + "error", + { anonymous: "never", named: "never", asyncArrow: "always" }, + ], + "space-in-parens": "error", + "space-infix-ops": "error", + }, + }, +]; diff --git a/package-lock.json b/package-lock.json index bbb140d2..12b779f4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -41,6 +41,8 @@ "@graphql-eslint/eslint-plugin": "^3.20.1", "@graphql-tools/mock": "^9.0.0", "@graphql-tools/schema": "^10.0.0", + "@stylistic/eslint-plugin": "^1.5.4", + "@stylistic/eslint-plugin-migrate": "^1.5.4", "@swc/core": "^1.3.95", "@types/node": "^20.8.10", "@types/supertest": "^2.0.12", @@ -1947,6 +1949,12 @@ "node": "^12.0.0 || ^14.0.0 || >=16.0.0" } }, + "node_modules/@eslint-stylistic/metadata": { + "version": "1.5.4", + "resolved": "https://registry.npmjs.org/@eslint-stylistic/metadata/-/metadata-1.5.4.tgz", + "integrity": "sha512-i/Y6fJ+uZ6y/AiDkSlV67hO2nP0XUQLORdWEKiC4k+Ch3kGxZ1YV2GO+bwuyk8ajKIHlVSDhPSvyDy0GuZn6pw==", + "dev": true + }, "node_modules/@eslint/eslintrc": { "version": "2.1.4", "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.1.4.tgz", @@ -5299,6 +5307,552 @@ "integrity": "sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA==", "dev": true }, + "node_modules/@stylistic/eslint-plugin": { + "version": "1.5.4", + "resolved": "https://registry.npmjs.org/@stylistic/eslint-plugin/-/eslint-plugin-1.5.4.tgz", + "integrity": "sha512-zWPXr+O67GC9KDAFkbL1U9UVqE6Iv69YMKhkIECCmE0GvClUJwdfsimm4XebEDondV7kfjMrTDZaYfrI5aS0Jg==", + "dev": true, + "dependencies": { + "@stylistic/eslint-plugin-js": "1.5.4", + "@stylistic/eslint-plugin-jsx": "1.5.4", + "@stylistic/eslint-plugin-plus": "1.5.4", + "@stylistic/eslint-plugin-ts": "1.5.4" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "peerDependencies": { + "eslint": ">=8.40.0" + } + }, + "node_modules/@stylistic/eslint-plugin-js": { + "version": "1.5.4", + "resolved": "https://registry.npmjs.org/@stylistic/eslint-plugin-js/-/eslint-plugin-js-1.5.4.tgz", + "integrity": "sha512-3ctWb3NvJNV1MsrZN91cYp2EGInLPSoZKphXIbIRx/zjZxKwLDr9z4LMOWtqjq14li/OgqUUcMq5pj8fgbLoTw==", + "dev": true, + "dependencies": { + "acorn": "^8.11.3", + "escape-string-regexp": "^4.0.0", + "eslint-visitor-keys": "^3.4.3", + "espree": "^9.6.1" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "peerDependencies": { + "eslint": ">=8.40.0" + } + }, + "node_modules/@stylistic/eslint-plugin-jsx": { + "version": "1.5.4", + "resolved": "https://registry.npmjs.org/@stylistic/eslint-plugin-jsx/-/eslint-plugin-jsx-1.5.4.tgz", + "integrity": "sha512-JUfrpCkeBCqt1IZ4QsP4WgxGza4PhK4LPbc0VnCjHKygl+rgqoDAovqOuzFJ49wJ4Ix3r6OIHFuwiBGswZEVvg==", + "dev": true, + "dependencies": { + "@stylistic/eslint-plugin-js": "^1.5.4", + "estraverse": "^5.3.0" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "peerDependencies": { + "eslint": ">=8.40.0" + } + }, + "node_modules/@stylistic/eslint-plugin-migrate": { + "version": "1.5.4", + "resolved": "https://registry.npmjs.org/@stylistic/eslint-plugin-migrate/-/eslint-plugin-migrate-1.5.4.tgz", + "integrity": "sha512-1M6dJJJ9UDCV0XyVsmqUD7+59aSRdk0WIMib5mUcXVpVjPISCnmuHTzxQja6p3ZQU4lwkQz9S2dyD+xDertXLw==", + "dev": true, + "dependencies": { + "@eslint-stylistic/metadata": "1.5.4", + "@typescript-eslint/utils": "^6.19.0" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + } + }, + "node_modules/@stylistic/eslint-plugin-migrate/node_modules/@typescript-eslint/scope-manager": { + "version": "6.20.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.20.0.tgz", + "integrity": "sha512-p4rvHQRDTI1tGGMDFQm+GtxP1ZHyAh64WANVoyEcNMpaTFn3ox/3CcgtIlELnRfKzSs/DwYlDccJEtr3O6qBvA==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "6.20.0", + "@typescript-eslint/visitor-keys": "6.20.0" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@stylistic/eslint-plugin-migrate/node_modules/@typescript-eslint/types": { + "version": "6.20.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.20.0.tgz", + "integrity": "sha512-MM9mfZMAhiN4cOEcUOEx+0HmuaW3WBfukBZPCfwSqFnQy0grXYtngKCqpQN339X3RrwtzspWJrpbrupKYUSBXQ==", + "dev": true, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@stylistic/eslint-plugin-migrate/node_modules/@typescript-eslint/typescript-estree": { + "version": "6.20.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.20.0.tgz", + "integrity": "sha512-RnRya9q5m6YYSpBN7IzKu9FmLcYtErkDkc8/dKv81I9QiLLtVBHrjz+Ev/crAqgMNW2FCsoZF4g2QUylMnJz+g==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "6.20.0", + "@typescript-eslint/visitor-keys": "6.20.0", + "debug": "^4.3.4", + "globby": "^11.1.0", + "is-glob": "^4.0.3", + "minimatch": "9.0.3", + "semver": "^7.5.4", + "ts-api-utils": "^1.0.1" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@stylistic/eslint-plugin-migrate/node_modules/@typescript-eslint/utils": { + "version": "6.20.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-6.20.0.tgz", + "integrity": "sha512-/EKuw+kRu2vAqCoDwDCBtDRU6CTKbUmwwI7SH7AashZ+W+7o8eiyy6V2cdOqN49KsTcASWsC5QeghYuRDTyOOg==", + "dev": true, + "dependencies": { + "@eslint-community/eslint-utils": "^4.4.0", + "@types/json-schema": "^7.0.12", + "@types/semver": "^7.5.0", + "@typescript-eslint/scope-manager": "6.20.0", + "@typescript-eslint/types": "6.20.0", + "@typescript-eslint/typescript-estree": "6.20.0", + "semver": "^7.5.4" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^7.0.0 || ^8.0.0" + } + }, + "node_modules/@stylistic/eslint-plugin-migrate/node_modules/@typescript-eslint/visitor-keys": { + "version": "6.20.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.20.0.tgz", + "integrity": "sha512-E8Cp98kRe4gKHjJD4NExXKz/zOJ1A2hhZc+IMVD6i7w4yjIvh6VyuRI0gRtxAsXtoC35uGMaQ9rjI2zJaXDEAw==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "6.20.0", + "eslint-visitor-keys": "^3.4.1" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@stylistic/eslint-plugin-migrate/node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/@stylistic/eslint-plugin-migrate/node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/@stylistic/eslint-plugin-migrate/node_modules/minimatch": { + "version": "9.0.3", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.3.tgz", + "integrity": "sha512-RHiac9mvaRw0x3AYRgDC1CxAP7HTcNrrECeA8YYJeWnpo+2Q5CegtZjaotWTWxDG3UeGA1coE05iH1mPjT/2mg==", + "dev": true, + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/@stylistic/eslint-plugin-migrate/node_modules/semver": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "dev": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/@stylistic/eslint-plugin-plus": { + "version": "1.5.4", + "resolved": "https://registry.npmjs.org/@stylistic/eslint-plugin-plus/-/eslint-plugin-plus-1.5.4.tgz", + "integrity": "sha512-dI0Cs5vYX/0uMhQDY+NK0cKQ0Pe9B6jWYxd0Ndud+mNloDaVLrsmJocK4zn+YfhGEDs1E4Nk5uAPZEumIpDuSg==", + "dev": true, + "dependencies": { + "@typescript-eslint/utils": "^6.19.0" + }, + "peerDependencies": { + "eslint": "*" + } + }, + "node_modules/@stylistic/eslint-plugin-plus/node_modules/@typescript-eslint/scope-manager": { + "version": "6.20.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.20.0.tgz", + "integrity": "sha512-p4rvHQRDTI1tGGMDFQm+GtxP1ZHyAh64WANVoyEcNMpaTFn3ox/3CcgtIlELnRfKzSs/DwYlDccJEtr3O6qBvA==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "6.20.0", + "@typescript-eslint/visitor-keys": "6.20.0" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@stylistic/eslint-plugin-plus/node_modules/@typescript-eslint/types": { + "version": "6.20.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.20.0.tgz", + "integrity": "sha512-MM9mfZMAhiN4cOEcUOEx+0HmuaW3WBfukBZPCfwSqFnQy0grXYtngKCqpQN339X3RrwtzspWJrpbrupKYUSBXQ==", + "dev": true, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@stylistic/eslint-plugin-plus/node_modules/@typescript-eslint/typescript-estree": { + "version": "6.20.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.20.0.tgz", + "integrity": "sha512-RnRya9q5m6YYSpBN7IzKu9FmLcYtErkDkc8/dKv81I9QiLLtVBHrjz+Ev/crAqgMNW2FCsoZF4g2QUylMnJz+g==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "6.20.0", + "@typescript-eslint/visitor-keys": "6.20.0", + "debug": "^4.3.4", + "globby": "^11.1.0", + "is-glob": "^4.0.3", + "minimatch": "9.0.3", + "semver": "^7.5.4", + "ts-api-utils": "^1.0.1" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@stylistic/eslint-plugin-plus/node_modules/@typescript-eslint/utils": { + "version": "6.20.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-6.20.0.tgz", + "integrity": "sha512-/EKuw+kRu2vAqCoDwDCBtDRU6CTKbUmwwI7SH7AashZ+W+7o8eiyy6V2cdOqN49KsTcASWsC5QeghYuRDTyOOg==", + "dev": true, + "dependencies": { + "@eslint-community/eslint-utils": "^4.4.0", + "@types/json-schema": "^7.0.12", + "@types/semver": "^7.5.0", + "@typescript-eslint/scope-manager": "6.20.0", + "@typescript-eslint/types": "6.20.0", + "@typescript-eslint/typescript-estree": "6.20.0", + "semver": "^7.5.4" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^7.0.0 || ^8.0.0" + } + }, + "node_modules/@stylistic/eslint-plugin-plus/node_modules/@typescript-eslint/visitor-keys": { + "version": "6.20.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.20.0.tgz", + "integrity": "sha512-E8Cp98kRe4gKHjJD4NExXKz/zOJ1A2hhZc+IMVD6i7w4yjIvh6VyuRI0gRtxAsXtoC35uGMaQ9rjI2zJaXDEAw==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "6.20.0", + "eslint-visitor-keys": "^3.4.1" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@stylistic/eslint-plugin-plus/node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/@stylistic/eslint-plugin-plus/node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/@stylistic/eslint-plugin-plus/node_modules/minimatch": { + "version": "9.0.3", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.3.tgz", + "integrity": "sha512-RHiac9mvaRw0x3AYRgDC1CxAP7HTcNrrECeA8YYJeWnpo+2Q5CegtZjaotWTWxDG3UeGA1coE05iH1mPjT/2mg==", + "dev": true, + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/@stylistic/eslint-plugin-plus/node_modules/semver": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "dev": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/@stylistic/eslint-plugin-ts": { + "version": "1.5.4", + "resolved": "https://registry.npmjs.org/@stylistic/eslint-plugin-ts/-/eslint-plugin-ts-1.5.4.tgz", + "integrity": "sha512-NZDFVIlVNjuPvhT+0Cidm5IS3emtx338xbJTqs2xfOVRDGTpYwRHhNVEGa1rFOpYHmv0sAj6+OXbMDn7ul0K/g==", + "dev": true, + "dependencies": { + "@stylistic/eslint-plugin-js": "1.5.4", + "@typescript-eslint/utils": "^6.19.0" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "peerDependencies": { + "eslint": ">=8.40.0" + } + }, + "node_modules/@stylistic/eslint-plugin-ts/node_modules/@typescript-eslint/scope-manager": { + "version": "6.20.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.20.0.tgz", + "integrity": "sha512-p4rvHQRDTI1tGGMDFQm+GtxP1ZHyAh64WANVoyEcNMpaTFn3ox/3CcgtIlELnRfKzSs/DwYlDccJEtr3O6qBvA==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "6.20.0", + "@typescript-eslint/visitor-keys": "6.20.0" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@stylistic/eslint-plugin-ts/node_modules/@typescript-eslint/types": { + "version": "6.20.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.20.0.tgz", + "integrity": "sha512-MM9mfZMAhiN4cOEcUOEx+0HmuaW3WBfukBZPCfwSqFnQy0grXYtngKCqpQN339X3RrwtzspWJrpbrupKYUSBXQ==", + "dev": true, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@stylistic/eslint-plugin-ts/node_modules/@typescript-eslint/typescript-estree": { + "version": "6.20.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.20.0.tgz", + "integrity": "sha512-RnRya9q5m6YYSpBN7IzKu9FmLcYtErkDkc8/dKv81I9QiLLtVBHrjz+Ev/crAqgMNW2FCsoZF4g2QUylMnJz+g==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "6.20.0", + "@typescript-eslint/visitor-keys": "6.20.0", + "debug": "^4.3.4", + "globby": "^11.1.0", + "is-glob": "^4.0.3", + "minimatch": "9.0.3", + "semver": "^7.5.4", + "ts-api-utils": "^1.0.1" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@stylistic/eslint-plugin-ts/node_modules/@typescript-eslint/utils": { + "version": "6.20.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-6.20.0.tgz", + "integrity": "sha512-/EKuw+kRu2vAqCoDwDCBtDRU6CTKbUmwwI7SH7AashZ+W+7o8eiyy6V2cdOqN49KsTcASWsC5QeghYuRDTyOOg==", + "dev": true, + "dependencies": { + "@eslint-community/eslint-utils": "^4.4.0", + "@types/json-schema": "^7.0.12", + "@types/semver": "^7.5.0", + "@typescript-eslint/scope-manager": "6.20.0", + "@typescript-eslint/types": "6.20.0", + "@typescript-eslint/typescript-estree": "6.20.0", + "semver": "^7.5.4" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^7.0.0 || ^8.0.0" + } + }, + "node_modules/@stylistic/eslint-plugin-ts/node_modules/@typescript-eslint/visitor-keys": { + "version": "6.20.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.20.0.tgz", + "integrity": "sha512-E8Cp98kRe4gKHjJD4NExXKz/zOJ1A2hhZc+IMVD6i7w4yjIvh6VyuRI0gRtxAsXtoC35uGMaQ9rjI2zJaXDEAw==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "6.20.0", + "eslint-visitor-keys": "^3.4.1" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@stylistic/eslint-plugin-ts/node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/@stylistic/eslint-plugin-ts/node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/@stylistic/eslint-plugin-ts/node_modules/minimatch": { + "version": "9.0.3", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.3.tgz", + "integrity": "sha512-RHiac9mvaRw0x3AYRgDC1CxAP7HTcNrrECeA8YYJeWnpo+2Q5CegtZjaotWTWxDG3UeGA1coE05iH1mPjT/2mg==", + "dev": true, + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/@stylistic/eslint-plugin-ts/node_modules/semver": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "dev": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/@swc/core": { "version": "1.3.100", "resolved": "https://registry.npmjs.org/@swc/core/-/core-1.3.100.tgz", @@ -6217,9 +6771,9 @@ } }, "node_modules/acorn": { - "version": "8.11.2", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.2.tgz", - "integrity": "sha512-nc0Axzp/0FILLEVsm4fNwLCwMttvhEI263QtVPQcbpfZZ3ts0hLsZGOpE6czNlid7CJ9MlyH8reXkpsf3YUY4w==", + "version": "8.11.3", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.3.tgz", + "integrity": "sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg==", "bin": { "acorn": "bin/acorn" }, diff --git a/package.json b/package.json index 53abdbb6..e385b229 100644 --- a/package.json +++ b/package.json @@ -47,6 +47,8 @@ "@graphql-eslint/eslint-plugin": "^3.20.1", "@graphql-tools/mock": "^9.0.0", "@graphql-tools/schema": "^10.0.0", + "@stylistic/eslint-plugin": "^1.5.4", + "@stylistic/eslint-plugin-migrate": "^1.5.4", "@swc/core": "^1.3.95", "@types/node": "^20.8.10", "@types/supertest": "^2.0.12", diff --git a/src/resolvers.ts b/src/resolvers.ts index 8565afc1..45207d56 100644 --- a/src/resolvers.ts +++ b/src/resolvers.ts @@ -10,21 +10,21 @@ import { logger } from './logger.js' const resolvers = { Query: { facility: async (_parent: gqlType.Facility, args: { id: string; }) - : Promise => { + : Promise => { const queryResults = await facilityService.getFacilityById(args.id) convertErrorsToGqlErrors(queryResults) return queryResults.data }, facilities: async (_parent: unknown, args: { filters: gqlType.FacilitySearchFilters }) - : Promise => { + : Promise => { const queryResults = await facilityService.searchFacilities(args.filters) convertErrorsToGqlErrors(queryResults) return queryResults.data }, healthcareProfessional: async (_parent: unknown, args: { id: string; }) - : Promise => { + : Promise => { const matchingHealthcareProfessionalResult = await healthcareProfessionalService.getHealthcareProfessionalById(args.id) @@ -34,7 +34,7 @@ const resolvers = { healthcareProfessionals: async (_parent: unknown, args: { filters: gqlType.HealthcareProfessionalSearchFilters }) - : Promise => { + : Promise => { const queryResults = await healthcareProfessionalService.searchProfessionals(args.filters) @@ -42,7 +42,7 @@ const resolvers = { return queryResults.data }, submission: async (_parent: unknown, args: { id: string }, context: UserContext) - : Promise => { + : Promise => { const isAdmin = await hasAdminRole(context) if (!isAdmin) { @@ -59,7 +59,7 @@ const resolvers = { return matchingSubmissionResult.data }, submissions: async (_parent: unknown, args: { filters: gqlType.SubmissionSearchFilters }, context: UserContext) - : Promise => { + : Promise => { const isAdmin = await hasAdminRole(context) if (!isAdmin) { diff --git a/src/result.ts b/src/result.ts index 14358c0d..04800e27 100644 --- a/src/result.ts +++ b/src/result.ts @@ -36,5 +36,5 @@ export enum ErrorCode { ORDERBY_OPTION_MAX_LIMIT = 'ORDERBY_OPTION_MAX_LIMIT', ORDERBY_FIELD_SELECTED_TWICE = 'ORDERBY_FIELD_SELECTED_TWICE', INVALID_LANGUAGE_INPUT = 'INVALID_LANGUAGE_INPUT', - INVALID_INPUT = 'INVALID_INPUT', + INVALID_INPUT = 'INVALID_INPUT' } diff --git a/src/services/facilityService.ts b/src/services/facilityService.ts index f54c271b..3bd80c57 100644 --- a/src/services/facilityService.ts +++ b/src/services/facilityService.ts @@ -14,7 +14,7 @@ import { logger } from '../logger.js' * @returns A Facility object. */ export const getFacilityById = async (id: string) - : Promise> => { +: Promise> => { try { const validationResult = validateIdInput(id) @@ -61,7 +61,7 @@ export const getFacilityById = async (id: string) * @returns The matching Facilities. */ export async function searchFacilities(filters: gqlTypes.FacilitySearchFilters = {}): - Promise> { +Promise> { try { const validationResult = validateFacilitiesSearchInput(filters) @@ -95,7 +95,7 @@ export async function searchFacilities(filters: gqlTypes.FacilitySearchFilters = filters.orderBy.forEach(order => { if (order) { searchRef = searchRef.orderBy(order.fieldToOrder as string, - order.orderDirection as gqlTypes.OrderDirection) + order.orderDirection as gqlTypes.OrderDirection) } }) } else { @@ -206,7 +206,7 @@ export async function createFacility(facilityInput: gqlTypes.CreateFacilityInput * @returns The updated Facility. */ export const updateFacility = async (facilityId: string, fieldsToUpdate: Partial) - : Promise> => { +: Promise> => { try { const validationResult = validateUpdateFacilityInput(fieldsToUpdate) diff --git a/src/services/healthcareProfessionalService.ts b/src/services/healthcareProfessionalService.ts index 6cc8075c..24cd77c0 100644 --- a/src/services/healthcareProfessionalService.ts +++ b/src/services/healthcareProfessionalService.ts @@ -61,7 +61,7 @@ export async function getHealthcareProfessionalById(id: string) * @returns The matching Healthcare Professionals. */ export async function searchProfessionals(filters: gqlTypes.HealthcareProfessionalSearchFilters = {}): - Promise> { +Promise> { try { const validationResult = validateProfessionalsSearchInput(filters) @@ -105,7 +105,7 @@ export async function searchProfessionals(filters: gqlTypes.HealthcareProfession filters.orderBy.forEach(order => { if (order) { searchRef = searchRef.orderBy(order.fieldToOrder as string, - order.orderDirection as gqlTypes.OrderDirection) + order.orderDirection as gqlTypes.OrderDirection) } }) } else { diff --git a/src/services/submissionService.ts b/src/services/submissionService.ts index 00b1f3b9..311a2505 100644 --- a/src/services/submissionService.ts +++ b/src/services/submissionService.ts @@ -159,7 +159,7 @@ export async function searchSubmissions(filters: gqlTypes.SubmissionSearchFilter * @returns The submission that was created. */ export const createSubmission = async (submissionInput: gqlTypes.CreateSubmissionInput): - Promise> => { +Promise> => { try { const validationResults = validateCreateSubmissionInputs(submissionInput) @@ -212,7 +212,7 @@ export const createSubmission = async (submissionInput: gqlTypes.CreateSubmissio * @returns The submission that was updated. */ export const updateSubmission = async (submissionId: string, fieldsToUpdate: Partial): - Promise> => { +Promise> => { try { //business logic: a submission can't be updated or unapproved once it's approved. //business logic: you can't approve and update at the same time.