Skip to content

Commit 3abec8e

Browse files
authored
Reduce prettier overrides (#30)
## Ticket #24 ## Changes This PR removed some non-default settings for prettier and then also made the formatting changes associated with that setting change. The setting change and the format change are in separate commits, in case that makes it easier to review. ## Context for reviewers All changes should be non-functional, so just visual confirmation that this looks right is probably all that's needed. Rationale for the change is provided in the issue (#24). ## Testing Non-functional changes, so little testing was needed, but I still ran storybook and the next.js app to make sure those still work, and they did.
1 parent 6816ffe commit 3abec8e

21 files changed

+159
-161
lines changed

app/.prettierrc.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
{
22
"importOrder": ["^components/(.*)$", "^[./]"],
33
"importOrderSeparation": true,
4-
"importOrderSortSpecifiers": true,
5-
"semi": false,
6-
"singleQuote": true
4+
"importOrderSortSpecifiers": true
75
}

app/.storybook/i18next.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
11
// Configure i18next for storybook addon storybook-react-i18next
22
// See https://storybook.js.org/addons/storybook-react-i18next
3-
import i18n from 'i18next'
4-
import LanguageDetector from 'i18next-browser-languagedetector'
5-
import Backend from 'i18next-http-backend'
6-
import { initReactI18next } from 'react-i18next'
3+
import i18n from "i18next";
4+
import LanguageDetector from "i18next-browser-languagedetector";
5+
import Backend from "i18next-http-backend";
6+
import { initReactI18next } from "react-i18next";
77

8-
const ns = ['common']
9-
const supportedLngs = ['en', 'es']
8+
const ns = ["common"];
9+
const supportedLngs = ["en", "es"];
1010
const resources = ns.reduce((acc, n) => {
1111
supportedLngs.forEach((lng) => {
12-
if (!acc[lng]) acc[lng] = {}
12+
if (!acc[lng]) acc[lng] = {};
1313
acc[lng] = {
1414
...acc[lng],
1515
[n]: require(`../public/locales/${lng}/${n}.json`),
16-
}
17-
})
18-
return acc
19-
}, {})
16+
};
17+
});
18+
return acc;
19+
}, {});
2020

2121
i18n.use(initReactI18next).use(LanguageDetector).use(Backend).init({
22-
lng: 'en',
23-
fallbackLng: 'en',
24-
defaultNS: 'common',
22+
lng: "en",
23+
fallbackLng: "en",
24+
defaultNS: "common",
2525
ns,
2626
supportedLngs,
2727
resources,
28-
})
28+
});
2929

30-
export default i18n
30+
export default i18n;

app/.storybook/main.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,56 +4,56 @@
44
* @see https://storybook.js.org/docs/configurations/default-config/
55
*/
66

7-
const nextConfig = require('../next.config')
7+
const nextConfig = require("../next.config");
88

99
module.exports = {
10-
stories: ['../stories/**/*.stories.@(mdx|js|jsx|ts|tsx)'],
11-
addons: ['@storybook/addon-essentials', 'storybook-react-i18next'],
12-
framework: '@storybook/react',
10+
stories: ["../stories/**/*.stories.@(mdx|js|jsx|ts|tsx)"],
11+
addons: ["@storybook/addon-essentials", "storybook-react-i18next"],
12+
framework: "@storybook/react",
1313
core: {
1414
// Use webpack5 instead of webpack4.
15-
builder: 'webpack5',
15+
builder: "webpack5",
1616
disableTelemetry: true,
1717
},
1818
// Tell storybook where to find USWDS static assets
19-
staticDirs: ['../public'],
19+
staticDirs: ["../public"],
2020

2121
// Configure Storybook's final Webpack configuration in order to re-use the Next.js config/dependencies.
2222
webpackFinal: (config) => {
2323
config.module?.rules?.push({
2424
test: /\.scss$/,
2525
use: [
26-
'style-loader',
27-
{ loader: 'css-loader', options: { url: false } }, // this mirrors next.js behavior
26+
"style-loader",
27+
{ loader: "css-loader", options: { url: false } }, // this mirrors next.js behavior
2828
{
2929
/**
3030
* Next.js sets this automatically for us, but we need to manually set it here for Storybook.
3131
* The main thing this enables is autoprefixer, so any experimental CSS properties work.
3232
*/
33-
loader: 'postcss-loader',
33+
loader: "postcss-loader",
3434
options: {
3535
postcssOptions: {
36-
plugins: ['postcss-preset-env'],
36+
plugins: ["postcss-preset-env"],
3737
},
3838
},
3939
},
4040
{
41-
loader: 'sass-loader',
41+
loader: "sass-loader",
4242
options: {
4343
sassOptions: nextConfig.sassOptions,
4444
},
4545
},
4646
],
4747
exclude: /node_modules/,
48-
})
48+
});
4949

5050
// Required for i18next.
5151
config.resolve.fallback = {
5252
fs: false,
5353
path: false,
5454
os: false,
55-
}
55+
};
5656

57-
return config
57+
return config;
5858
},
59-
}
59+
};

app/.storybook/preview.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// Apply global styling to our stories
2-
import '../styles/styles.scss'
2+
import "../styles/styles.scss";
33
// Import i18next config.
4-
import i18n from './i18next.js'
4+
import i18n from "./i18next.js";
55

66
export const parameters = {
7-
actions: { argTypesRegex: '^on[A-Z].*' },
7+
actions: { argTypesRegex: "^on[A-Z].*" },
88
controls: {
99
matchers: {
1010
color: /(background|color)$/i,
@@ -13,9 +13,9 @@ export const parameters = {
1313
},
1414
// Configure i18next and locale/dropdown options.
1515
i18n,
16-
locale: 'en',
16+
locale: "en",
1717
locales: {
18-
en: 'English',
19-
es: 'Español',
18+
en: "English",
19+
es: "Español",
2020
},
21-
}
21+
};

app/__mocks__/styleMock.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
module.exports = {}
1+
module.exports = {};

app/jest.config.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
22

33
module.exports = {
4-
preset: 'ts-jest',
5-
testEnvironment: 'jsdom',
4+
preset: "ts-jest",
5+
testEnvironment: "jsdom",
66
moduleNameMapper: {
7-
'\\.(css|scss)$': '<rootDir>/__mocks__/styleMock.js', // sets up routing to mocks style sheet
8-
'^@pages(.*)$': '<rootDir>/pages$1', //allows module imports of page components
7+
"\\.(css|scss)$": "<rootDir>/__mocks__/styleMock.js", // sets up routing to mocks style sheet
8+
"^@pages(.*)$": "<rootDir>/pages$1", //allows module imports of page components
99
},
1010
setupFilesAfterEnv: [
11-
'<rootDir>/tests/jest.setup.js',
12-
'<rootDir>/tests/jest-i18n.ts',
11+
"<rootDir>/tests/jest.setup.js",
12+
"<rootDir>/tests/jest-i18n.ts",
1313
],
1414
transform: {
15-
'^.+\\.tsx?$': 'ts-jest',
15+
"^.+\\.tsx?$": "ts-jest",
1616
}, //transfrom typescript files to common js for jest compiler
1717
transformIgnorePatterns: [
18-
'/.next/',
19-
'/node_modules/',
20-
'^.+\\.module\\.(css|sass|scss)$',
18+
"/.next/",
19+
"/node_modules/",
20+
"^.+\\.module\\.(css|sass|scss)$",
2121
],
22-
testPathIgnorePatterns: ['<rootDir>/node_modules/'],
23-
testRegex: '(/tests/.*(test|spec))\\.[jt]sx?$',
22+
testPathIgnorePatterns: ["<rootDir>/node_modules/"],
23+
testRegex: "(/tests/.*(test|spec))\\.[jt]sx?$",
2424
globals: {
25-
'ts-jest': {
26-
tsconfig: 'tsconfig.ts-jest.json',
25+
"ts-jest": {
26+
tsconfig: "tsconfig.ts-jest.json",
2727
},
2828
},
29-
}
29+
};

app/next-i18next.config.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
module.exports = {
22
i18n: {
3-
defaultLocale: 'en',
4-
locales: ['en', 'es'],
3+
defaultLocale: "en",
4+
locales: ["en", "es"],
55
react: {
66
// Add support for <em>.
77
// See https://react.i18next.com/latest/trans-component#using-for-less-than-br-greater-than-and-other-simple-html-elements-in-translations-v-10-4-0
8-
transKeepBasicHtmlNodesFor: ['br', 'strong', 'i', 'p', 'em'],
8+
transKeepBasicHtmlNodesFor: ["br", "strong", "i", "p", "em"],
99
},
1010
},
11-
}
11+
};

app/next.config.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
/** @type {import('next').NextConfig} */
22

3-
const { i18n } = require('./next-i18next.config')
3+
const { i18n } = require("./next-i18next.config");
44

55
const nextConfig = {
66
i18n,
77
reactStrictMode: true,
88
sassOptions: {
99
includePaths: [
10-
'./node_modules/@uswds',
11-
'./node_modules/@uswds/uswds/packages',
10+
"./node_modules/@uswds",
11+
"./node_modules/@uswds/uswds/packages",
1212
],
1313
},
14-
}
14+
};
1515

16-
module.exports = nextConfig
16+
module.exports = nextConfig;

app/src/api/hello.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction
2-
import type { NextApiRequest, NextApiResponse } from 'next'
2+
import type { NextApiRequest, NextApiResponse } from "next";
33

44
type Data = {
5-
name: string
6-
}
5+
name: string;
6+
};
77

88
export default function handler(
99
req: NextApiRequest,
1010
res: NextApiResponse<Data>
1111
) {
12-
res.status(200).json({ name: 'John Doe' })
12+
res.status(200).json({ name: "John Doe" });
1313
}

app/src/components/Layout.tsx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
1-
import { useTranslation } from 'next-i18next'
2-
import { ReactElement } from 'react'
1+
import { useTranslation } from "next-i18next";
2+
import { ReactElement } from "react";
33

44
type Props = {
5-
children: ReactElement
6-
}
5+
children: ReactElement;
6+
};
77

88
const Layout = ({ children }: Props): ReactElement => {
9-
const { t } = useTranslation('common')
9+
const { t } = useTranslation("common");
1010

1111
return (
1212
<div className="container">
1313
<header className="header">
14-
<em>{t('Layout.header')}</em>
14+
<em>{t("Layout.header")}</em>
1515
</header>
1616
<main className="main">{children}</main>
1717
<footer className="footer">
18-
<em>{t('Layout.footer')}</em>
18+
<em>{t("Layout.footer")}</em>
1919
</footer>
2020
</div>
21-
)
22-
}
21+
);
22+
};
2323

24-
export default Layout
24+
export default Layout;

0 commit comments

Comments
 (0)