Skip to content
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) Configure prettier #103

Merged
merged 1 commit into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": ["ts-react-important-stuff", "plugin:prettier/recommended"],
"extends": [],
"parser": "@typescript-eslint/parser",
"plugins": ["unused-imports"],
"ignorePatterns": ["**/*.test.tsx"],
Expand Down
10 changes: 5 additions & 5 deletions __mocks__/react-i18next.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
const React = require('react');
const reactI18next = require('react-i18next');

const hasChildren = node => node && (node.children || (node.props && node.props.children));
const hasChildren = (node) => node && (node.children || (node.props && node.props.children));

const getChildren = node => (node && node.children ? node.children : node.props && node.props.children);
const getChildren = (node) => (node && node.children ? node.children : node.props && node.props.children);

const renderNodes = reactNodes => {
const renderNodes = (reactNodes) => {
if (typeof reactNodes === 'string') {
return reactNodes;
}
Expand All @@ -31,14 +31,14 @@ const renderNodes = reactNodes => {
});
};

const useMock = [k => k, {}];
const useMock = [(k) => k, {}];
useMock.t = (k, o) => (o && o.defaultValue) || (typeof o === 'string' ? o : k);
useMock.i18n = {};

module.exports = {
// this mock makes sure any components using the translate HoC receive the t function as a prop
Trans: ({ children }) => renderNodes(children),
Translation: ({ children }) => children(k => k, { i18n: {} }),
Translation: ({ children }) => children((k) => k, { i18n: {} }),
useTranslation: () => useMock,

// mock if needed
Expand Down
18 changes: 9 additions & 9 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
module.exports = {
transform: {
"^.+\\.tsx?$": "@swc/jest",
'^.+\\.tsx?$': '@swc/jest',
},
transformIgnorePatterns: ["/node_modules/(?!@openmrs)"],
transformIgnorePatterns: ['/node_modules/(?!@openmrs)'],
moduleNameMapper: {
"@openmrs/esm-framework": "@openmrs/esm-framework/mock",
"\\.(s?css)$": "identity-obj-proxy",
"^lodash-es/(.*)$": "lodash/$1",
"^uuid$": "<rootDir>/node_modules/uuid/dist/index.js",
dexie: require.resolve("dexie"),
'@openmrs/esm-framework': '@openmrs/esm-framework/mock',
'\\.(s?css)$': 'identity-obj-proxy',
'^lodash-es/(.*)$': 'lodash/$1',
'^uuid$': '<rootDir>/node_modules/uuid/dist/index.js',
dexie: require.resolve('dexie'),
},
setupFilesAfterEnv: ["<rootDir>/src/setup-tests.ts"],
testEnvironment: "jsdom",
setupFilesAfterEnv: ['<rootDir>/src/setup-tests.ts'],
testEnvironment: 'jsdom',
};
6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"serve": "webpack serve --mode=development",
"build": "webpack --mode production",
"analyze": "webpack --mode=production --env.analyze=true",
"prettier": "prettier --write \"src/**/*.{ts,tsx}\"",
"prettier": "prettier --write \"src/**/*.{ts,tsx}\" --list-different --ignore-unknown",
"lint": "eslint src --ext js,jsx,ts,tsx",
"test": "jest --config jest.config.js",
"typescript": "tsc",
Expand Down Expand Up @@ -67,13 +67,11 @@
"@types/react-router": "^5.1.14",
"@types/react-router-dom": "^5.1.7",
"@types/webpack-env": "^1.16.0",
"@typescript-eslint/parser": "^4.26.0",
"@typescript-eslint/parser": "^7.5.0",
"concurrently": "^6.2.0",
"dayjs": "1.x",
"eslint": "^7.27.0",
"eslint-config-prettier": "^8.3.0",
"eslint-config-ts-react-important-stuff": "^3.0.0",
"eslint-plugin-prettier": "^3.4.0",
"eslint-plugin-unused-imports": "^2.0.0",
"husky": "^6.0.0",
"identity-obj-proxy": "^3.0.0",
Expand Down
8 changes: 8 additions & 0 deletions prettier.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
printWidth: 120,
singleQuote: true,
trailingComma: 'all',
bracketSpacing: true,
semi: true,
bracketSameLine: true,
};
Loading
Loading