Skip to content

Commit

Permalink
chore(prettier): re-format all files
Browse files Browse the repository at this point in the history
  • Loading branch information
Viktor Vincze committed Jan 31, 2019
1 parent ab0f9d1 commit 4359c91
Show file tree
Hide file tree
Showing 32 changed files with 109 additions and 327 deletions.
5 changes: 1 addition & 4 deletions src/configs/babel/development/plugins.js
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
export default (defaults = []) => [
...defaults,
require.resolve('react-hot-loader/babel')
]
export default (defaults = []) => [...defaults, require.resolve('react-hot-loader/babel')]
6 changes: 1 addition & 5 deletions src/configs/babel/write.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@ import FileTypes from '@/utils/fileTypes'
import { writeFile } from '@/utils'
import babelConfig from '@/configs/babel/index'

const writeConfig = (
dir = __dirname,
format = FileTypes.JSON_NO_EXT,
overwrite
) => {
const writeConfig = (dir = __dirname, format = FileTypes.JSON_NO_EXT, overwrite) => {
return writeFile(dir, '.babelrc', babelConfig, format, overwrite)
}

Expand Down
14 changes: 2 additions & 12 deletions src/configs/eslint/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,7 @@ const eslintConfig = loadConfig('eslint', {
},
parser: 'babel-eslint',
plugins: ['react', 'jest'],
extends: [
'airbnb',
'prettier',
'prettier/react',
'plugin:jest/recommended'
],
extends: ['airbnb', 'prettier', 'prettier/react', 'plugin:jest/recommended'],
rules: {
'jsx-a11y/media-has-caption': 0,
'jsx-a11y/click-events-have-key-events': 0,
Expand Down Expand Up @@ -144,12 +139,7 @@ const eslintConfig = loadConfig('eslint', {
'no-path-concat': 1,
'no-process-exit': 1,
'no-restricted-modules': 1,
'no-restricted-syntax': [
'error',
'ForInStatement',
'LabeledStatement',
'WithStatement'
],
'no-restricted-syntax': ['error', 'ForInStatement', 'LabeledStatement', 'WithStatement'],
'no-sync': 1,

'brace-style': [1, '1tbs', { allowSingleLine: true }],
Expand Down
6 changes: 1 addition & 5 deletions src/configs/eslint/write.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@ import FileTypes from '@/utils/fileTypes'
import { writeFile } from '@/utils'
import eslintConfig from '@/configs/eslint/index'

const writeConfig = (
dir = process.cwd(),
format = FileTypes.JSON_NO_EXT,
overwrite
) => {
const writeConfig = (dir = process.cwd(), format = FileTypes.JSON_NO_EXT, overwrite) => {
return writeFile(dir, '.eslintrc', eslintConfig, format, overwrite)
}

Expand Down
6 changes: 1 addition & 5 deletions src/configs/gitignore/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import mhyConfig from '@/configs/mhy'
import { loadConfig } from '@/utils'

const gitignore = loadConfig('gitignore', [
'/dist',
'/build',
...mhyConfig.defaultIgnoreList
])
const gitignore = loadConfig('gitignore', ['/dist', '/build', ...mhyConfig.defaultIgnoreList])

export default gitignore
6 changes: 1 addition & 5 deletions src/configs/gitignore/write.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@ import FileTypes from '@/utils/fileTypes'
import { writeFile } from '@/utils'
import gitignore from '@/configs/gitignore/index'

const writeConfig = (
dir = process.cwd(),
format = FileTypes.RAW,
overwrite
) => {
const writeConfig = (dir = process.cwd(), format = FileTypes.RAW, overwrite) => {
return writeFile(dir, '.gitignore', gitignore.join('\n'), format, overwrite)
}

Expand Down
17 changes: 3 additions & 14 deletions src/configs/mhy/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,10 @@ import fs from 'fs'
import { loadConfig } from '@/utils'

const mhyConfig = loadConfig('mhy', {
defaultIndexHtml: path.resolve(
__dirname,
'../..',
'resources',
'index.html'
),
defaultIndexHtml: path.resolve(__dirname, '../..', 'resources', 'index.html'),
get indexHtml() {
const projectIndexHtml = path.resolve(
process.cwd(),
this.srcFolder,
'index.html'
)
return fs.existsSync(projectIndexHtml)
? projectIndexHtml
: this.defaultIndexHtml
const projectIndexHtml = path.resolve(process.cwd(), this.srcFolder, 'index.html')
return fs.existsSync(projectIndexHtml) ? projectIndexHtml : this.defaultIndexHtml
},
srcFolder: 'src',
distFolder: 'dist',
Expand Down
6 changes: 1 addition & 5 deletions src/configs/npmignore/write.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@ import FileTypes from '@/utils/fileTypes'
import { writeFile } from '@/utils'
import npmignore from '@/configs/npmignore'

const writeConfig = (
dir = process.cwd(),
format = FileTypes.RAW,
overwrite
) => {
const writeConfig = (dir = process.cwd(), format = FileTypes.RAW, overwrite) => {
return writeFile(dir, '.npmignore', npmignore.join('\n'), format, overwrite)
}

Expand Down
6 changes: 1 addition & 5 deletions src/configs/prettier/write.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@ import FileTypes from '@/utils/fileTypes'
import { writeFile } from '@/utils'
import prettierConfig from '@/configs/prettier/index'

const writeConfig = (
dir = process.cwd(),
format = FileTypes.JSON_NO_EXT,
overwrite
) => {
const writeConfig = (dir = process.cwd(), format = FileTypes.JSON_NO_EXT, overwrite) => {
let filename
switch (format) {
case FileTypes.JS:
Expand Down
14 changes: 2 additions & 12 deletions src/configs/tslint/index.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,12 @@
import { loadConfig } from '@/utils'

const tslintConfig = loadConfig('tslint', {
extends: [
'tslint:recommended',
'tslint-config-airbnb',
'tslint-react',
'tslint-config-prettier'
],
extends: ['tslint:recommended', 'tslint-config-airbnb', 'tslint-react', 'tslint-config-prettier'],
rules: {
'max-line-length': {
options: [120]
},
'variable-name': [
true,
'ban-keywords',
'check-format',
'allow-pascal-case'
],
'variable-name': [true, 'ban-keywords', 'check-format', 'allow-pascal-case'],
semicolon: [true, 'never'],
'no-arg': true,
'no-bitwise': true,
Expand Down
6 changes: 1 addition & 5 deletions src/configs/tslint/write.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@ import FileTypes from '@/utils/fileTypes'
import { writeFile } from '@/utils'
import tslintConfig from '@/configs/tslint'

const writeConfig = (
dir = process.cwd(),
format = FileTypes.JSON,
overwrite
) => {
const writeConfig = (dir = process.cwd(), format = FileTypes.JSON, overwrite) => {
return writeFile(dir, 'tslint', tslintConfig, format, overwrite)
}

Expand Down
11 changes: 3 additions & 8 deletions src/configs/typescript/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,7 @@ const tsconfig = loadConfig('typescript', {
return acc
},
{
'*': [
path.resolve(process.cwd(), 'node_modules', '*'),
path.resolve(_globalTypes, '../', '*')
]
'*': [path.resolve(process.cwd(), 'node_modules', '*'), path.resolve(_globalTypes, '../', '*')]
}
)
},
Expand All @@ -41,10 +38,8 @@ const tsconfig = loadConfig('typescript', {
})

// Setup @types
const isDirectory = source => dir =>
fs.lstatSync(path.join(source, dir)).isDirectory()
const getDirectories = source =>
fs.readdirSync(source).filter(isDirectory(source))
const isDirectory = source => dir => fs.lstatSync(path.join(source, dir)).isDirectory()
const getDirectories = source => fs.readdirSync(source).filter(isDirectory(source))

// Set fixed types from mhy
getDirectories(_globalTypes).forEach(dir => {
Expand Down
4 changes: 1 addition & 3 deletions src/configs/webpack/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { loadConfig } from '@/utils'

process.env.WEBPACK_DEV_SERVER = process.argv.find(v =>
v.includes('webpack-dev-server')
)
process.env.WEBPACK_DEV_SERVER = process.argv.find(v => v.includes('webpack-dev-server'))

const webpackConfig = loadConfig('webpack', {})

Expand Down
4 changes: 1 addition & 3 deletions src/configs/webpack/production/module/rules/eslint.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
export default rules => {
const rule = rules.find(({ loader = '' }) =>
loader.includes('eslint-loader')
)
const rule = rules.find(({ loader = '' }) => loader.includes('eslint-loader'))
rule.options = {
...rule.options,
failOnWarning: true,
Expand Down
16 changes: 2 additions & 14 deletions src/configs/webpack/root/resolve.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,9 @@ import path from 'path'
import mhyConfig from '@/configs/mhy'

export default () => ({
extensions: [
'.js',
'.mjs',
'.jsx',
'.css',
'.scss',
'.ts',
'.tsx',
'.json'
],
extensions: ['.js', '.mjs', '.jsx', '.css', '.scss', '.ts', '.tsx', '.json'],
modules: Array.from(
new Set([
path.resolve(__dirname, '../../../../node_modules'),
path.resolve(process.cwd(), 'node_modules')
])
new Set([path.resolve(__dirname, '../../../../node_modules'), path.resolve(process.cwd(), 'node_modules')])
),
alias: mhyConfig.defaultAliases
})
7 changes: 1 addition & 6 deletions src/processes/command/babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,5 @@ const commandHandler = argv => {
}

export default () => {
yargs.command(
['babel', 'bb'],
'compile src using Babel',
() => {},
commandHandler
)
yargs.command(['babel', 'bb'], 'compile src using Babel', () => {}, commandHandler)
}
10 changes: 2 additions & 8 deletions src/processes/command/boot.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,13 @@ import yargs from 'yargs'

// mhy boot [technology:react|vue|...] [template:default|...] [-o,--output: output path]
const commandHandler = ({ technology, template, output }) => {
const source = path.resolve(
__dirname,
'../../../',
`templates/${technology}/${template}`
)
const source = path.resolve(__dirname, '../../../', `templates/${technology}/${template}`)
const destination = path.resolve(process.cwd(), output)

fse.copy(source, destination, function(err) {
if (err) {
console.error(`mhy:boot:${technology}:${template}`)
console.error(
`An error occurred while copying the source to the destination: ${destination}`
)
console.error(`An error occurred while copying the source to the destination: ${destination}`)
console.error(err)
return
}
Expand Down
Loading

0 comments on commit 4359c91

Please sign in to comment.