-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(chore) Various tooling updates and tweaks #73
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
src/**/*.test.tsx | ||
**/*.d.ts |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,39 @@ | ||
{ | ||
"env": { | ||
"node": true, | ||
"browser": true | ||
"node": true | ||
}, | ||
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended", "prettier"], | ||
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't we add There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could. Only reason I didn't is because I want to keep the diff small |
||
"parser": "@typescript-eslint/parser", | ||
"plugins": ["@typescript-eslint"], | ||
"ignorePatterns": ["**/*.test.tsx"], | ||
"parserOptions": { | ||
"project": true, | ||
"tsconfigRootDir": "__dirname" | ||
}, | ||
"plugins": ["@typescript-eslint", "import", "react-hooks"], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't know if its a standard or if we should do it but we have There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shall we add the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's already in there |
||
"root": true, | ||
"rules": { | ||
// The following rules need `noImplicitAny` to be set to `true` in our tsconfig. They are too restrictive for now, but should be reconsidered in future | ||
"@typescript-eslint/ban-types": "off", | ||
"@typescript-eslint/ban-ts-comment": "off", | ||
"@typescript-eslint/no-explicit-any": "off", | ||
"@typescript-eslint/no-floating-promises": "off", | ||
"@typescript-eslint/no-unsafe-argument": "off", | ||
"@typescript-eslint/no-unsafe-assignment": "off", | ||
"@typescript-eslint/no-unsafe-call": "off", | ||
"@typescript-eslint/no-unsafe-member-access": "off", | ||
"@typescript-eslint/no-unsafe-return": "off", | ||
"@typescript-eslint/no-unused-vars": "off", | ||
"@typescript-eslint/unbound-method": "off", | ||
"@typescript-eslint/consistent-type-definitions": "off", | ||
"@typescript-eslint/consistent-type-exports": "error", | ||
// Use `import type` instead of `import` for type imports | ||
"@typescript-eslint/consistent-type-imports": [ | ||
"error", | ||
{ | ||
"fixStyle": "inline-type-imports" | ||
} | ||
], | ||
"import/no-duplicates": "error", | ||
"no-console": ["error", { "allow": ["warn", "error"] }], | ||
"no-explicit-any": "off", | ||
"no-extra-boolean-cast": "off", | ||
"no-prototype-builtins": "off", | ||
"no-restricted-imports": [ | ||
"error", | ||
{ | ||
|
@@ -26,6 +48,7 @@ | |
"importNames": ["default"], | ||
"message": "Import specific methods from `lodash-es`. e.g. `import { map } from 'lodash-es'`" | ||
}, | ||
// These two rules ensure that we're importing Carbon components and icons from the correct packages (after v10). May be removed in the future. | ||
{ | ||
"name": "carbon-components-react", | ||
"message": "Import from `@carbon/react` directly. e.g. `import { Toggle } from '@carbon/react'`" | ||
|
@@ -37,21 +60,7 @@ | |
] | ||
} | ||
], | ||
"no-unsafe-optional-chaining": "off", | ||
"no-useless-escape": "off", | ||
"prefer-const": "off", | ||
"@typescript-eslint/ban-ts-comment": "off", | ||
"@typescript-eslint/ban-types": "off", | ||
// Use `import type` instead of `import` for type imports https://typescript-eslint.io/blog/consistent-type-imports-and-exports-why-and-how | ||
"@typescript-eslint/consistent-type-imports": [ | ||
"error", | ||
{ | ||
"fixStyle": "inline-type-imports" | ||
} | ||
], | ||
"@typescript-eslint/no-explicit-any": "off", | ||
"@typescript-eslint/no-unused-vars": "off", | ||
"@typescript-eslint/no-var-requires": "off", | ||
"@typescript-eslint/triple-slash-reference": "off" | ||
"react-hooks/exhaustive-deps": "warn", | ||
"react-hooks/rules-of-hooks": "error" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,5 +3,5 @@ | |
|
||
set -e # die on error | ||
|
||
yarn pretty-quick --staged | ||
npx lint-staged | ||
yarn turbo run extract-translations |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"$schema": "https://turbo.build/schema.json", | ||
"pipeline": { | ||
"tasks": { | ||
"build": { | ||
"outputs": ["dist/**"] | ||
}, | ||
|
This file was deleted.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
module.exports = { | ||
contextSeparator: "_", | ||
contextSeparator: '_', | ||
// Key separator used in your translation keys | ||
|
||
createOldCatalogs: false, | ||
// Save the \_old files | ||
|
||
defaultNamespace: "translations", | ||
defaultNamespace: 'translations', | ||
// Default namespace used in your i18next config | ||
|
||
defaultValue: "", | ||
defaultValue: '', | ||
// Default value to give to empty keys | ||
// You may also specify a function accepting the locale, namespace, and key as arguments | ||
|
||
|
@@ -18,43 +18,43 @@ module.exports = { | |
keepRemoved: false, | ||
// Keep keys from the catalog that are no longer in code | ||
|
||
keySeparator: ".", | ||
keySeparator: '.', | ||
// Key separator used in your translation keys | ||
// If you want to use plain english keys, separators such as `.` and `:` will conflict. You might want to set `keySeparator: false` and `namespaceSeparator: false`. That way, `t('Status: Loading...')` will not think that there are a namespace and three separator dots for instance. | ||
|
||
// see below for more details | ||
lexers: { | ||
hbs: ["HandlebarsLexer"], | ||
handlebars: ["HandlebarsLexer"], | ||
hbs: ['HandlebarsLexer'], | ||
handlebars: ['HandlebarsLexer'], | ||
|
||
htm: ["HTMLLexer"], | ||
html: ["HTMLLexer"], | ||
htm: ['HTMLLexer'], | ||
html: ['HTMLLexer'], | ||
|
||
mjs: ["JavascriptLexer"], | ||
js: ["JavascriptLexer"], // if you're writing jsx inside .js files, change this to JsxLexer | ||
ts: ["JavascriptLexer"], | ||
jsx: ["JsxLexer"], | ||
tsx: ["JsxLexer"], | ||
mjs: ['JavascriptLexer'], | ||
js: ['JavascriptLexer'], // if you're writing jsx inside .js files, change this to JsxLexer | ||
ts: ['JavascriptLexer'], | ||
jsx: ['JsxLexer'], | ||
tsx: ['JsxLexer'], | ||
|
||
default: ["JavascriptLexer"], | ||
default: ['JavascriptLexer'], | ||
}, | ||
|
||
lineEnding: "auto", | ||
lineEnding: 'auto', | ||
// Control the line ending. See options at https://github.com/ryanve/eol | ||
|
||
locales: ["en", "am", "es", "fr", "km", "he"], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We only want to extract |
||
locales: ['en'], | ||
// An array of the locales in your applications | ||
|
||
namespaceSeparator: ":", | ||
namespaceSeparator: ':', | ||
// Namespace separator used in your translation keys | ||
// If you want to use plain english keys, separators such as `.` and `:` will conflict. You might want to set `keySeparator: false` and `namespaceSeparator: false`. That way, `t('Status: Loading...')` will not think that there are a namespace and three separator dots for instance. | ||
|
||
output: "$NAMESPACE/$LOCALE.json", | ||
output: '$NAMESPACE/$LOCALE.json', | ||
// Supports $LOCALE and $NAMESPACE injection | ||
// Supports JSON (.json) and YAML (.yml) file formats | ||
// Where to write the locale files relative to process.cwd() | ||
|
||
pluralSeparator: "_", | ||
pluralSeparator: '_', | ||
// Plural separator used in your translation keys | ||
// If you want to use plain english keys, separators such as `_` might conflict. You might want to set `pluralSeparator` to a different string that does not occur in your keys. | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
const path = require('path'); | ||
|
||
module.exports = { | ||
clearMocks: true, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So mocks gets automatically cleared between test runs. |
||
collectCoverageFrom: [ | ||
'**/src/**/*.component.tsx', | ||
'!**/node_modules/**', | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,21 +1,28 @@ | ||||||
import React, { useEffect, useMemo, useState } from 'react'; | ||||||
import { Button, ModalBody, ModalFooter, ModalHeader, Form, InlineLoading } from '@carbon/react'; | ||||||
import { | ||||||
Button, | ||||||
Column, | ||||||
Form, | ||||||
InlineLoading, | ||||||
InlineNotification, | ||||||
ModalBody, | ||||||
ModalFooter, | ||||||
ModalHeader, | ||||||
NumberInput, | ||||||
TextInput, | ||||||
} from '@carbon/react'; | ||||||
import { useTranslation } from 'react-i18next'; | ||||||
import { showSnackbar } from '@openmrs/esm-framework'; | ||||||
import { Controller, type FieldErrors, useForm } from 'react-hook-form'; | ||||||
import { mutate } from 'swr'; | ||||||
import { z } from 'zod'; | ||||||
import { zodResolver } from '@hookform/resolvers/zod'; | ||||||
import { type LineItem, type MappedBill } from '../types'; | ||||||
import styles from './bill-item-actions.scss'; | ||||||
import { updateBillItems } from '../billing.resource'; | ||||||
import { mutate } from 'swr'; | ||||||
import { showSnackbar } from '@openmrs/esm-framework'; | ||||||
import { apiBasePath } from '../constants'; | ||||||
import { Column } from '@carbon/react'; | ||||||
import { InlineNotification } from '@carbon/react'; | ||||||
import { getBillableServiceUuid } from '../invoice/payments/utils'; | ||||||
import { type LineItem, type MappedBill } from '../types'; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
import { updateBillItems } from '../billing.resource'; | ||||||
import { useBillableServices } from '../billable-services/billable-service.resource'; | ||||||
import { NumberInput } from '@carbon/react'; | ||||||
import { TextInput } from '@carbon/react'; | ||||||
import styles from './bill-item-actions.scss'; | ||||||
|
||||||
interface BillLineItemProps { | ||||||
bill: MappedBill; | ||||||
|
@@ -25,17 +32,17 @@ interface BillLineItemProps { | |||||
|
||||||
const ChangeStatus: React.FC<BillLineItemProps> = ({ bill, item, closeModal }) => { | ||||||
const { t } = useTranslation(); | ||||||
const { billableServices } = useBillableServices(); | ||||||
const [showErrorNotification, setShowErrorNotification] = useState(false); | ||||||
const [total, setTotal] = useState(0); | ||||||
const { billableServices } = useBillableServices(); | ||||||
|
||||||
const schema = useMemo( | ||||||
() => | ||||||
z.object({ | ||||||
quantity: z.string({ required_error: t('quantityRequired', 'Quantity is required') }), | ||||||
price: z.string({ required_error: t('priceIsRequired', 'Price is required') }), | ||||||
}), | ||||||
[], | ||||||
[t], | ||||||
); | ||||||
|
||||||
type BillLineItemForm = z.infer<typeof schema>; | ||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,9 +1,9 @@ | ||||||
import React from 'react'; | ||||||
import { render, screen, fireEvent, waitFor } from '@testing-library/react'; | ||||||
import ChangeStatus from './edit-bill-item.component'; | ||||||
import { updateBillItems } from '../billing.resource'; | ||||||
import { showSnackbar } from '@openmrs/esm-framework'; | ||||||
import { type LineItem, type MappedBill } from '../types'; | ||||||
import { type MappedBill } from '../types'; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
import { updateBillItems } from '../billing.resource'; | ||||||
import ChangeStatus from './edit-bill-item.component'; | ||||||
|
||||||
// Mock external dependencies | ||||||
jest.mock('../billing.resource', () => ({ | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't this disable global browser-specific variables like
console
,window
etc.?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't think so, no. We don't have that elsewhere AFAICT.