Skip to content

Commit

Permalink
chore: set up prettier through eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
kantord committed Feb 20, 2022
1 parent 5ca85b5 commit 9cd6660
Show file tree
Hide file tree
Showing 9 changed files with 210 additions and 193 deletions.
63 changes: 25 additions & 38 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,41 +1,28 @@
module.exports = {
'ignorePatterns': ['public'],
'env': {
'browser': true,
'es2021': true,
'node': true,
ignorePatterns: ['public'],
env: {
browser: true,
es2021: true,
node: true,
},
extends: [
'eslint:recommended',
'plugin:react/recommended',
'plugin:prettier/recommended',
],
parserOptions: {
ecmaFeatures: {
jsx: true,
},
'extends': [
'eslint:recommended',
'plugin:react/recommended'
],
'parserOptions': {
'ecmaFeatures': {
'jsx': true
},
'ecmaVersion': 'latest',
'sourceType': 'module'
},
'plugins': [
'react'
],
'rules': {
'indent': [
'error',
4
],
'linebreak-style': [
'error',
'unix'
],
'quotes': [
'error',
'single'
],
'semi': [
'error',
'never'
],
'react/prop-types': 'off',
}
ecmaVersion: 'latest',
sourceType: 'module',
},
plugins: ['react', 'prettier'],
rules: {
'linebreak-style': ['error', 'unix'],
quotes: ['error', 'single'],
semi: ['error', 'never'],
'react/prop-types': 'off',
'prettier/prettier': ['error', { singleQuote: true, semi: false }],
},
}
92 changes: 46 additions & 46 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ const fs = require('fs-extra')
const pkg = require('./package.json')

const log = (...args) => {
console.log(chalk.green('[mdx-deck]'), ...args)
console.log(chalk.green('[mdx-deck]'), ...args)
}
log.error = (...args) => {
console.log(chalk.red('[err]'), ...args)
console.log(chalk.red('[err]'), ...args)
}

const cli = meow(
`
`
${chalk.gray('Usage')}
$ ${chalk.green('mdx-deck deck.mdx')}
Expand All @@ -29,26 +29,26 @@ const cli = meow(
--no-open Prevent from opening in default browser
`,
{
description: chalk.green('@mdx-deck/lite ') + chalk.gray(pkg.description),
flags: {
port: {
type: 'string',
alias: 'p',
default: '8000',
},
host: {
type: 'string',
alias: 'h',
default: 'localhost',
},
open: {
type: 'boolean',
alias: 'o',
default: true,
},
},
}
{
description: chalk.green('@mdx-deck/lite ') + chalk.gray(pkg.description),
flags: {
port: {
type: 'string',
alias: 'p',
default: '8000',
},
host: {
type: 'string',
alias: 'h',
default: 'localhost',
},
open: {
type: 'boolean',
alias: 'o',
default: true,
},
},
}
)

const [cmd, file] = cli.input
Expand All @@ -61,36 +61,36 @@ process.env.__SRC__ = path.resolve(filename)
const opts = Object.assign({}, cli.flags)

const gatsby = async (...args) => {
await execa('gatsby', ['clean'], {
cwd: __dirname,
stdio: 'inherit',
preferLocal: true,
})
return execa('gatsby', args.filter(Boolean), {
cwd: __dirname,
stdio: 'inherit',
preferLocal: true,
})
await execa('gatsby', ['clean'], {
cwd: __dirname,
stdio: 'inherit',
preferLocal: true,
})
return execa('gatsby', args.filter(Boolean), {
cwd: __dirname,
stdio: 'inherit',
preferLocal: true,
})
}

switch (cmd) {
case 'build':
case 'build':
gatsby('build').then(() => {
const public_ = path.join(__dirname, 'public')
const dist = path.join(process.cwd(), 'public')
if (public_ === dist) return
fs.copySync(public_, dist)
const public_ = path.join(__dirname, 'public')
const dist = path.join(process.cwd(), 'public')
if (public_ === dist) return
fs.copySync(public_, dist)
})
break
case 'dev':
default:
case 'dev':
default:
gatsby(
'develop',
'--host',
opts.host,
'--port',
opts.port,
opts.open && '--open'
'develop',
'--host',
opts.host,
'--port',
opts.port,
opts.open && '--open'
)
break
}
2 changes: 1 addition & 1 deletion commitlint.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = {
extends: ['@commitlint/config-conventional']
extends: ['@commitlint/config-conventional'],
}
10 changes: 5 additions & 5 deletions gatsby-config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = {
plugins: [
{
resolve: 'gatsby-theme-mdx-deck',
},
],
plugins: [
{
resolve: 'gatsby-theme-mdx-deck',
},
],
}
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@
"@semantic-release/changelog": "^6.0.1",
"@semantic-release/git": "^10.0.1",
"eslint": "^8.9.0",
"eslint-config-prettier": "^8.4.0",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-react": "^7.28.0",
"husky": "^7.0.4",
"prettier": "^2.5.1",
"semantic-release": "^19.0.2"
},
"scripts": {
Expand Down
41 changes: 21 additions & 20 deletions release.config.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
module.exports = {
branches: ['main'],
plugins: [
'@semantic-release/commit-analyzer',
'@semantic-release/release-notes-generator',
[
'@semantic-release/changelog',
{
changelogFile: 'CHANGELOG.md'
}
],
'@semantic-release/npm',
'@semantic-release/github',
[
'@semantic-release/git',
{
assets: ['CHANGELOG.md', 'dist/**'],
message: 'chore(release): set `package.json` to ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}'
}
]
]
branches: ['main'],
plugins: [
'@semantic-release/commit-analyzer',
'@semantic-release/release-notes-generator',
[
'@semantic-release/changelog',
{
changelogFile: 'CHANGELOG.md',
},
],
'@semantic-release/npm',
'@semantic-release/github',
[
'@semantic-release/git',
{
assets: ['CHANGELOG.md', 'dist/**'],
message:
'chore(release): set `package.json` to ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}',
},
],
],
}
98 changes: 50 additions & 48 deletions src/gatsby-theme-mdx-deck/components/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,63 +6,65 @@ import Context from 'gatsby-theme-mdx-deck/src/context'
import { modes } from 'gatsby-theme-mdx-deck/src/constants'

const WebcamAsBackground = () => {
const videoConstraints = {
width: { min: 640, ideal: 1920, max: 1920 },
height: { min: 400, ideal: 1080, max: 1080 },
facingMode: 'user'
}
const videoConstraints = {
width: { min: 640, ideal: 1920, max: 1920 },
height: { min: 400, ideal: 1080, max: 1080 },
facingMode: 'user',
}

return (
<Webcam
videoConstraints={videoConstraints}
style={{
width: '100%',
height: '100%',
position: 'fixed',
objectFit: 'cover',
top: 0,
left: 0,
right: 0,
bottom: 0,
zIndex: -1000,
}}
/>
)
return (
<Webcam
videoConstraints={videoConstraints}
style={{
width: '100%',
height: '100%',
position: 'fixed',
objectFit: 'cover',
top: 0,
left: 0,
right: 0,
bottom: 0,
zIndex: -1000,
}}
/>
)
}

const reducer = (state, next) =>
typeof next === 'function'
? merge({}, state, next(state))
: merge({}, state, next)
typeof next === 'function'
? merge({}, state, next(state))
: merge({}, state, next)

const App = props => {
const [state, setState] = useReducer(reducer, {
mode: modes.normal,
step: 0,
metadata: {},
})
const App = (props) => {
const [state, setState] = useReducer(reducer, {
mode: modes.normal,
step: 0,
metadata: {},
})

const register = (index, key, value) => {
if (state.metadata[index] && state.metadata[index][key]) return
setState({
metadata: {
[index]: {
[key]: value,
},
},
})
}
const register = (index, key, value) => {
if (state.metadata[index] && state.metadata[index][key]) return
setState({
metadata: {
[index]: {
[key]: value,
},
},
})
}

const context = {
...state,
setState,
register,
}
const context = {
...state,
setState,
register,
}

return <>
<WebcamAsBackground />
<Context.Provider value={context}>{props.children}</Context.Provider>
return (
<>
<WebcamAsBackground />
<Context.Provider value={context}>{props.children}</Context.Provider>
</>
)
}

export default App
Loading

0 comments on commit 9cd6660

Please sign in to comment.