提交 6b54e9ed 编写于 作者: J Joe Haddad 提交者: Tim Neutkens

Fix Prettier Commit Hook (#9245)

* Apply format to webpack config

* hit all files
上级 636be246
...@@ -31,6 +31,16 @@ collections: ...@@ -31,6 +31,16 @@ collections:
slug: '{{year}}-{{month}}-{{day}}_{{slug}}' slug: '{{year}}-{{month}}-{{day}}_{{slug}}'
fields: fields:
- { label: 'Title', name: 'title', widget: 'string', required: true } - { label: 'Title', name: 'title', widget: 'string', required: true }
- { label: 'Publish Date', name: 'date', widget: 'datetime', required: true } - {
- { label: 'Featured Image', name: 'thumbnail', widget: 'image', required: true } label: 'Publish Date',
name: 'date',
widget: 'datetime',
required: true,
}
- {
label: 'Featured Image',
name: 'thumbnail',
widget: 'image',
required: true,
}
- { label: 'Body', name: 'body', widget: 'markdown', required: true } - { label: 'Body', name: 'body', widget: 'markdown', required: true }
export default () => <div>Next-Offline Example, try to install app via chrome</div> export default () => (
<div>Next-Offline Example, try to install app via chrome</div>
)
...@@ -13,4 +13,4 @@ ...@@ -13,4 +13,4 @@
"background_color": "#ffffff", "background_color": "#ffffff",
"start_url": "/", "start_url": "/",
"display": "standalone" "display": "standalone"
} }
\ No newline at end of file
// next.config.js // next.config.js
const withCSS = require('@zeit/next-css') const withCSS = require('@zeit/next-css')
module.exports = withCSS({/* my next config */}) module.exports = withCSS({
/* my next config */
})
...@@ -42,11 +42,14 @@ now ...@@ -42,11 +42,14 @@ now
## The idea behind the example ## The idea behind the example
This setup is a basic starting point for using [Tailwind CSS](https://tailwindcss.com) with Next.js. This example also includes the following [PostCSS](https://github.com/postcss/postcss) plugins: This setup is a basic starting point for using [Tailwind CSS](https://tailwindcss.com) with Next.js. This example also includes the following [PostCSS](https://github.com/postcss/postcss) plugins:
- [autoprefixer](https://github.com/postcss/autoprefixer) - Adds vendor prefixes to CSS rules in your stylesheet using values from [Can I Use](https://caniuse.com/) - [autoprefixer](https://github.com/postcss/autoprefixer) - Adds vendor prefixes to CSS rules in your stylesheet using values from [Can I Use](https://caniuse.com/)
- [purgecss](https://github.com/FullHuman/purgecss) - Removes unused CSS - [purgecss](https://github.com/FullHuman/purgecss) - Removes unused CSS
- [cssnano](https://cssnano.co/) - Minifies CSS - [cssnano](https://cssnano.co/) - Minifies CSS
- [postcss-easy-import](https://github.com/TrySound/postcss-easy-import) - Allows importing one stylesheet into another - [postcss-easy-import](https://github.com/TrySound/postcss-easy-import) - Allows importing one stylesheet into another
## Limitations ## Limitations
### Dynamically generated class strings will be purged ### Dynamically generated class strings will be purged
Purgecss takes a very straightforward approach to removing unused CSS. It simply searches an entire file for a string that matches a regular expression. As a result, class strings that are dynamically created in a template using string concatenation will be considered unused and removed from your stylesheet. Tailwind CSS addresses this problem in more detail in [their documentation](https://tailwindcss.com/docs/controlling-file-size#writing-purgeable-html). Purgecss takes a very straightforward approach to removing unused CSS. It simply searches an entire file for a string that matches a regular expression. As a result, class strings that are dynamically created in a template using string concatenation will be considered unused and removed from your stylesheet. Tailwind CSS addresses this problem in more detail in [their documentation](https://tailwindcss.com/docs/controlling-file-size#writing-purgeable-html).
...@@ -3,7 +3,7 @@ import { sampleUserData } from '../../../utils/sample-data' ...@@ -3,7 +3,7 @@ import { sampleUserData } from '../../../utils/sample-data'
export default (req: NextApiRequest, res: NextApiResponse) => { export default (req: NextApiRequest, res: NextApiResponse) => {
try { try {
const { id } = req.query; const { id } = req.query
const selected = sampleUserData.find(data => data.id === Number(id)) const selected = sampleUserData.find(data => data.id === Number(id))
if (!selected) { if (!selected) {
...@@ -15,4 +15,3 @@ export default (req: NextApiRequest, res: NextApiResponse) => { ...@@ -15,4 +15,3 @@ export default (req: NextApiRequest, res: NextApiResponse) => {
res.status(404).json({ statusCode: 404, message: err.message }) res.status(404).json({ statusCode: 404, message: err.message })
} }
} }
...@@ -15,7 +15,9 @@ class InitialPropsDetail extends React.Component<Props> { ...@@ -15,7 +15,9 @@ class InitialPropsDetail extends React.Component<Props> {
static getInitialProps = async ({ query }: NextPageContext) => { static getInitialProps = async ({ query }: NextPageContext) => {
try { try {
const { id } = query const { id } = query
const item = await sampleFetchWrapper(`http://localhost:3000/api/users/${Array.isArray(id) ? id[0] : id}`) const item = await sampleFetchWrapper(
`http://localhost:3000/api/users/${Array.isArray(id) ? id[0] : id}`
)
return { item } return { item }
} catch (err) { } catch (err) {
return { errors: err.message } return { errors: err.message }
...@@ -37,7 +39,9 @@ class InitialPropsDetail extends React.Component<Props> { ...@@ -37,7 +39,9 @@ class InitialPropsDetail extends React.Component<Props> {
return ( return (
<Layout <Layout
title={`${item ? item.name : 'User Detail'} | Next.js + TypeScript Example`} title={`${
item ? item.name : 'User Detail'
} | Next.js + TypeScript Example`}
> >
{item && <ListDetail item={item} />} {item && <ListDetail item={item} />}
</Layout> </Layout>
......
{ {
"browser": "./browser.js", "browser": "./browser.js",
"main": "./server.js" "main": "./server.js"
} }
\ No newline at end of file
{ {
"npmClient": "yarn", "npmClient": "yarn",
"useWorkspaces": true, "useWorkspaces": true,
"packages": [ "packages": ["packages/*"],
"packages/*"
],
"command": { "command": {
"version": { "version": {
"exact": true "exact": true
}, },
"publish": { "publish": {
"npmClient": "npm", "npmClient": "npm",
"allowBranch": [ "allowBranch": ["master", "canary"],
"master",
"canary"
],
"registry": "https://registry.npmjs.org/" "registry": "https://registry.npmjs.org/"
} }
}, },
......
const escape = require('shell-quote').quote
module.exports = {
'**/*.{js,jsx}': filenames => {
const escapedFileNames = filenames
.map(filename => `"${escape([filename])}"`)
.join(' ')
return [
`prettier --write ${escapedFileNames}`,
`standard --fix ${escapedFileNames}`,
`git add ${escapedFileNames}`
]
},
'**/*.{json,ts,tsx,md,mdx,css,html,yml,yaml,scss,sass}': filenames => {
const escapedFileNames = filenames
.map(filename => `"${escape([filename])}"`)
.join(' ')
return [
`prettier --write ${escapedFileNames}`,
`git add ${escapedFileNames}`
]
}
}
...@@ -28,25 +28,6 @@ ...@@ -28,25 +28,6 @@
"next": "./packages/next/dist/bin/next" "next": "./packages/next/dist/bin/next"
}, },
"pre-commit": "lint-staged", "pre-commit": "lint-staged",
"lint-staged": {
"*.js": [
"prettier --write",
"standard --fix",
"git add"
],
"*.tsx": [
"prettier --write",
"git add"
],
"*.ts": [
"prettier --write",
"git add"
],
"*.md": [
"prettier --write",
"git add"
]
},
"standard": { "standard": {
"parser": "babel-eslint", "parser": "babel-eslint",
"ignore": [ "ignore": [
...@@ -97,7 +78,7 @@ ...@@ -97,7 +78,7 @@
"jest-cli": "24.8.0", "jest-cli": "24.8.0",
"jest-junit": "6.4.0", "jest-junit": "6.4.0",
"lerna": "3.14.1", "lerna": "3.14.1",
"lint-staged": "8.1.7", "lint-staged": "9.4.2",
"mkdirp": "0.5.1", "mkdirp": "0.5.1",
"moment": "^2.24.0", "moment": "^2.24.0",
"node-fetch": "2.6.0", "node-fetch": "2.6.0",
...@@ -111,6 +92,7 @@ ...@@ -111,6 +92,7 @@
"release": "6.0.1", "release": "6.0.1",
"request-promise-core": "1.1.2", "request-promise-core": "1.1.2",
"rimraf": "2.6.3", "rimraf": "2.6.3",
"shell-quote": "1.7.2",
"standard": "12.0.1", "standard": "12.0.1",
"taskr": "1.1.0", "taskr": "1.1.0",
"tree-kill": "1.2.1", "tree-kill": "1.2.1",
......
...@@ -338,9 +338,9 @@ export default async function getBaseWebpackConfig( ...@@ -338,9 +338,9 @@ export default async function getBaseWebpackConfig(
// are relative to requests we've already resolved here. // are relative to requests we've already resolved here.
// Absolute requires (require('/foo')) are extremely uncommon, but // Absolute requires (require('/foo')) are extremely uncommon, but
// also have no need for customization as they're already resolved. // also have no need for customization as they're already resolved.
const start = request.charAt(0); const start = request.charAt(0)
if (start === '.' || start === '/') { if (start === '.' || start === '/') {
return callback(); return callback()
} }
// Resolve the import with the webpack provided context, this // Resolve the import with the webpack provided context, this
......
...@@ -3,10 +3,7 @@ import Link from 'next/link' ...@@ -3,10 +3,7 @@ import Link from 'next/link'
// eslint-disable-next-line camelcase // eslint-disable-next-line camelcase
export async function unstable_getStaticParams () { export async function unstable_getStaticParams () {
return [ return ['/blog/post-1/comment-1', { post: 'post-2', comment: 'comment-2' }]
'/blog/post-1/comment-1',
{ post: 'post-2', comment: 'comment-2' }
]
} }
// eslint-disable-next-line camelcase // eslint-disable-next-line camelcase
......
...@@ -3,11 +3,7 @@ import Link from 'next/link' ...@@ -3,11 +3,7 @@ import Link from 'next/link'
// eslint-disable-next-line camelcase // eslint-disable-next-line camelcase
export async function unstable_getStaticParams () { export async function unstable_getStaticParams () {
return [ return ['/blog/post-1', { post: 'post-2' }, '/blog/[post3]']
'/blog/post-1',
{ post: 'post-2' },
'/blog/[post3]'
]
} }
// eslint-disable-next-line camelcase // eslint-disable-next-line camelcase
......
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册