Skip to content

Commit

Permalink
fix linting
Browse files Browse the repository at this point in the history
  • Loading branch information
ekdeveloper committed Aug 28, 2024
1 parent fa04758 commit 688f10b
Show file tree
Hide file tree
Showing 33 changed files with 2,300 additions and 3,217 deletions.
5 changes: 0 additions & 5 deletions .eslintignore

This file was deleted.

70 changes: 0 additions & 70 deletions .eslintrc

This file was deleted.

2 changes: 1 addition & 1 deletion docs/MIGRATION_2.0.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ module.exports.search = async (args, context) => {
.map((result) => new Observation(result));
let entries = Array.prototype.concat(
patients.map((patient) => new BundleEntry({ resource: patient })),
observations.map((observation) => new BundleEntry({ resource: observation }))
observations.map((observation) => new BundleEntry({ resource: observation })),
);
return new Bundle({ entry: entries });
};
Expand Down
123 changes: 123 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
const globals = require('globals');
const js = require('@eslint/js');
// const babelParser = require('@babel/eslint-parser');
const { FlatCompat } = require('@eslint/eslintrc');

const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all,
});

module.exports = [
...compat.extends('eslint:recommended', 'prettier'),
{
ignores: [
'eslint.config.js',
'coverage/**/*',
'node_modules/**/*',
'/package/**/node_modules/**/*',
'**/dist/**/*',
'**/__tmp__/**/*',
'lerna.json',
'**/resources/**/*',
],
},
{
languageOptions: {
globals: {
...globals.browser,
...globals.jest,
...globals.node,
},
ecmaVersion: 8,
sourceType: 'commonjs',
},

rules: {
'no-mixed-spaces-and-tabs': [0, 'smart-tabs'],
quotes: [2, 'single', 'avoid-escape'],
'no-compare-neg-zero': 0,
'no-console': 0,
'no-debugger': 2,
'no-array-constructor': 2,
'no-caller': 2,
'no-catch-shadow': 2,
'no-eval': 2,
'no-extend-native': 2,
'no-extra-bind': 2,
'no-implied-eval': 2,
'no-iterator': 2,
'no-label-var': 2,
'no-labels': 2,
'no-lone-blocks': 2,
'no-loop-func': 2,
'no-multi-spaces': 2,
'no-multi-str': 2,
'no-native-reassign': 2,
'no-new': 2,
'no-new-func': 2,
'no-new-object': 2,
'no-new-wrappers': 2,
'no-octal-escape': 2,
'no-proto': 2,
'no-return-assign': 2,
'no-script-url': 2,
'no-sequences': 2,
'no-shadow': 2,
'no-shadow-restricted-names': 2,
'no-spaced-func': 2,
'no-undef-init': 2,
'no-unused-expressions': 2,
'no-unused-vars': 'off',

'no-use-before-define': 2,
'no-with': 2,
'comma-spacing': 2,
curly: [2, 'all'],

'dot-notation': [
2,
{
allowKeywords: true,
},
],

'no-extra-parens': [2, 'functions'],
eqeqeq: 2,

'key-spacing': [
2,
{
beforeColon: false,
afterColon: true,
},
],

'new-cap': 2,
'new-parens': 2,
semi: 2,

'semi-spacing': [
2,
{
before: false,
after: true,
},
],

'space-infix-ops': 2,
'keyword-spacing': 2,

'space-unary-ops': [
2,
{
words: true,
nonwords: false,
},
],

yoda: [2, 'never'],
},
},
];
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"prettier-fix": "prettier --write \"**/*.{js,mjs,cjs,jsx,json,ts,tsx,md,mdx,css,html,yml,yaml,scss,less,graphql,graphqls,gql}\"",
"lint": "run-p prettier-check lint-eslint",
"lint-staged": "lint-staged",
"lint-eslint": "eslint . --ext js,jsx,ts,tsx",
"lint-eslint": "eslint . '**/*.{js,jsx,ts,tsx}'",
"snyk": "snyk",
"snyk-test": "snyk test --all-projects"
},
Expand All @@ -46,6 +46,8 @@
},
"devDependencies": {
"eslint": "^9.9",
"eslint-config-prettier": "^9.1.0",
"globals": "^15.9.0",
"jest-cli": "^29.7.0",
"lerna": "^8.1.8",
"npm-run-all": "^4.1.5",
Expand Down
2 changes: 1 addition & 1 deletion packages/fhir-qb-mongo/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ let buildEndsWithQuery = function ({ field, value, caseSensitive = false }) {
let applySearchResultTransformations = function ({ query, searchResultTransformations }) {
Object.keys(searchResultTransformations).forEach((transformation) => {
query.push(
supportedSearchTransformations[transformation](searchResultTransformations[transformation])
supportedSearchTransformations[transformation](searchResultTransformations[transformation]),
);
});
return query;
Expand Down
2 changes: 1 addition & 1 deletion packages/fhir-qb-mongo/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ describe('Mongo Query Builder Tests', () => {
error = err;
}
expect(error.message).toContain(
"Missing required implementation parameter 'archivedParamPath'"
"Missing required implementation parameter 'archivedParamPath'",
);
});
test('Should return input query as is if we are not filtering out archived results', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/fhir-qb-sql/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ const assembleSearchQuery = function ({

if (tokenMatches.length > 0) {
let listOfOrs = tokenMatches
.filter((match) => match && match.length !== 0 && match !== {})
.filter((match) => match && match.length !== 0 && Object.keys(match).length > 0)
.map((match) => buildOrQuery({ queries: match }));
if (listOfOrs.length) {
query.tokens = buildAndQuery(listOfOrs);
Expand Down
12 changes: 6 additions & 6 deletions packages/fhir-qb/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ class QueryBuilder {
} else {
throw new Error(
`Supplied columnIdentifierStrategy value '${columnIdentifierStrategy}' not one of currently supported columnIdentifierStrategy values: ${supportedColumnIdentifierStrategies.join(
', '
)}`
', ',
)}`,
);
}
}
Expand Down Expand Up @@ -480,7 +480,7 @@ class QueryBuilder {
break;
default:
throw new Error(
`Unsupported fhirtype '${fhirtype}' supplied for token parameter '${field}'`
`Unsupported fhirtype '${fhirtype}' supplied for token parameter '${field}'`,
);
}
return tokenQuery;
Expand Down Expand Up @@ -603,13 +603,13 @@ class QueryBuilder {
sanitize.sanitizeNumber({
field: parameter,
value: parameterValue,
}).value
}).value,
);
if (pageNumber < 1 || !Number.isInteger(pageNumber)) {
throw new Error(
`Value for page parameter '${
this.pageParam
}' must be a positive integer. Received ${JSON.stringify(pageNumber)}`
}' must be a positive integer. Received ${JSON.stringify(pageNumber)}`,
);
}
return;
Expand Down Expand Up @@ -652,7 +652,7 @@ class QueryBuilder {
if (parameterValue.startsWith('urn') && modifier) {
// Modifiers cannot be used with URN values. If a modifier was supplied
throw new Error(
`Search modifiers are not supported for parameter '${parameter}' as a URN of type uri.`
`Search modifiers are not supported for parameter '${parameter}' as a URN of type uri.`,
);
}
}
Expand Down
Loading

0 comments on commit 688f10b

Please sign in to comment.