Skip to content

Commit

Permalink
feat(package): update eslint-config-ybiquitous to version 4.0.0 (#61)
Browse files Browse the repository at this point in the history
BREAKING CHANGES:

`eslint-config-ybiquitous@4.0.0` uses Prettier, so code style may be changed by auto-fix.
  • Loading branch information
ybiquitous committed Dec 5, 2017
1 parent ef5ec08 commit 49bcd40
Show file tree
Hide file tree
Showing 9 changed files with 87 additions and 50 deletions.
26 changes: 15 additions & 11 deletions commitlint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,20 @@ module.exports = {
extends: ['@commitlint/config-conventional'],

rules: {
'scope-enum': [2, 'always', [
'',
'package',
'readme',
'eslint',
'commitlint',
'coverage',
'release',
'init',
'api',
]],
'scope-enum': [
2,
'always',
[
'',
'package',
'readme',
'eslint',
'commitlint',
'coverage',
'release',
'init',
'api',
],
],
},
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,14 @@
"@commitlint/cli": "^5.2.0",
"@commitlint/config-conventional": "^5.1.3",
"eslint": "^4.12.1",
"eslint-config-ybiquitous": "^3.0.1",
"eslint-config-ybiquitous": "^4.0.0",
"fs-extra": "^4.0.2",
"husky": "^0.14.3",
"lint-staged": "^6.0.0",
"markdownlint-cli": "^0.5.0",
"npm-run-all": "^4.1.2",
"prepend-file-cli": "^1.0.6",
"prettier": "^1.8.2",
"semver": "^5.4.1",
"standard-version": "^4.2.0",
"yargs": "^10.0.3"
Expand Down
5 changes: 2 additions & 3 deletions src/cli.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const yargs = require('yargs')
const init = require('./init')

process.on('unhandledRejection', (reason) => {
process.on('unhandledRejection', reason => {
process.stderr.write(reason.stack)
process.exit(1)
})
Expand All @@ -14,6 +14,5 @@ module.exports = function cli() {
.demandCommand(1)
.strict()
.alias('help', 'h')
.alias('version', 'v')
.argv
.alias('version', 'v').argv
}
18 changes: 12 additions & 6 deletions src/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ class Init {
})
Object.keys(originalPackage.scripts)
.filter(key => !(key === 'test' || key.startsWith('test:')))
.forEach((key) => {
.forEach(key => {
scripts[key] = originalPackage.scripts[key]
})

// update other keys
const keys = ['lint-staged', 'standard-version']
keys.forEach((key) => {
keys.forEach(key => {
if (!(key in packageInfo)) {
packageInfo[key] = {}
}
Expand All @@ -66,16 +66,22 @@ class Init {
}

async writeESLintConfig() {
await this.writeFile('.eslintrc.js', `module.exports = {
await this.writeFile(
'.eslintrc.js',
`module.exports = {
root: true,
extends: ['ybiquitous'],
}`)
}`,
)
}

async writeCommitlintConfig() {
await this.writeFile('commitlint.config.js', `module.exports = {
await this.writeFile(
'commitlint.config.js',
`module.exports = {
extends: ['@commitlint/config-angular'],
}`)
}`,
)
}
}

Expand Down
11 changes: 3 additions & 8 deletions test/help.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@ Options:
`.trim()

suite('help', () => {
[
[],
['unknown'],
['unknown', 'xyz'],
].forEach((args) => {
;[[], ['unknown'], ['unknown', 'xyz']].forEach(args => {
test(`with arguments [${args.join(', ')}]`, async () => {
const error = await assertThrows(() => exec(...args))
const { code, stdout, stderr } = error
Expand All @@ -30,9 +26,8 @@ suite('help', () => {
assert(stdout === '')
assert(stderr.includes(HELP), stderr)
})
});

['--help', '-h'].forEach((option) => {
})
;['--help', '-h'].forEach(option => {
test(`with "${option}" option`, async () => {
const { stdout, stderr } = await exec(option)
assert(stdout.includes(HELP), stdout)
Expand Down
5 changes: 1 addition & 4 deletions test/helpers/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import assertThrows from './assert-throws'
import exec from './exec'

export {
assertThrows,
exec,
}
export { assertThrows, exec }
29 changes: 19 additions & 10 deletions test/init.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,7 @@ suite('init', () => {
})

assert.deepStrictEqual(pkg['lint-staged'], {
'*.{js,jsx}': [
'eslint --fix --no-ignore',
'git add',
],
'*.{js,jsx}': ['eslint --fix --no-ignore', 'git add'],
'*.md': 'markdownlint',
'*.css': 'xyz',
})
Expand All @@ -79,7 +76,10 @@ suite('init', () => {
test('copy ".editorconfig"', async () => {
await exec('init')

const original = await fs.readFile(path.join(originalDir, '.editorconfig'), 'utf8')
const original = await fs.readFile(
path.join(originalDir, '.editorconfig'),
'utf8',
)
const copy = await fs.readFile(path.join(workDir, '.editorconfig'), 'utf8')
assert(original === copy)
})
Expand All @@ -88,21 +88,30 @@ suite('init', () => {
await exec('init')

const wrote = await fs.readFile(path.join(workDir, '.eslintrc.js'), 'utf8')
assert(wrote === `module.exports = {
assert(
wrote ===
`module.exports = {
root: true,
extends: ['ybiquitous'],
}
`)
`,
)
})

test('write "commitlint.config.js"', async () => {
await exec('init')

const wrote = await fs.readFile(path.join(workDir, 'commitlint.config.js'), 'utf8')
assert(wrote === `module.exports = {
const wrote = await fs.readFile(
path.join(workDir, 'commitlint.config.js'),
'utf8',
)
assert(
wrote ===
`module.exports = {
extends: ['@commitlint/config-angular'],
}
`)
`,
)
})

test('throw error', async () => {
Expand Down
5 changes: 2 additions & 3 deletions test/version.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ import assert from 'assert'
import { exec } from './helpers'

suite('version', () => {
const version = process.env.npm_package_version;

['--version', '-v'].forEach((option) => {
const version = process.env.npm_package_version
;['--version', '-v'].forEach(option => {
test(`with "${option}" option`, async () => {
const { stdout, stderr } = await exec(option)
assert(stdout.trim() === version)
Expand Down
35 changes: 31 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1468,15 +1468,23 @@ eslint-config-airbnb@^16.0.0:
dependencies:
eslint-config-airbnb-base "^12.1.0"

eslint-config-ybiquitous@^3.0.1:
version "3.0.1"
resolved "https://registry.yarnpkg.com/eslint-config-ybiquitous/-/eslint-config-ybiquitous-3.0.1.tgz#a326942998bbf1d2fe53d7ddaa6949ff6cbb6970"
eslint-config-prettier@^2.9.0:
version "2.9.0"
resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-2.9.0.tgz#5ecd65174d486c22dff389fe036febf502d468a3"
dependencies:
get-stdin "^5.0.1"

eslint-config-ybiquitous@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/eslint-config-ybiquitous/-/eslint-config-ybiquitous-4.0.0.tgz#d55c93bd91ce87ceaed4b12f1bd30dbe7444f1ab"
dependencies:
eslint-config-airbnb "^16.0.0"
eslint-config-prettier "^2.9.0"
eslint-plugin-compat "^2.0.1"
eslint-plugin-eslint-comments "^2.0.1"
eslint-plugin-import "^2.7.0"
eslint-plugin-jsx-a11y "^6.0.2"
eslint-plugin-prettier "^2.3.1"
eslint-plugin-react "^7.4.0"

eslint-import-resolver-node@^0.3.1:
Expand Down Expand Up @@ -1536,6 +1544,13 @@ eslint-plugin-jsx-a11y@^6.0.2:
emoji-regex "^6.1.0"
jsx-ast-utils "^1.4.0"

eslint-plugin-prettier@^2.3.1:
version "2.3.1"
resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-2.3.1.tgz#e7a746c67e716f335274b88295a9ead9f544e44d"
dependencies:
fast-diff "^1.1.1"
jest-docblock "^21.0.0"

eslint-plugin-react@^7.4.0:
version "7.5.1"
resolved "https://registry.yarnpkg.com/eslint-plugin-react/-/eslint-plugin-react-7.5.1.tgz#52e56e8d80c810de158859ef07b880d2f56ee30b"
Expand Down Expand Up @@ -1712,6 +1727,10 @@ fast-deep-equal@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-1.0.0.tgz#96256a3bc975595eb36d82e9929d060d893439ff"

fast-diff@^1.1.1:
version "1.1.2"
resolved "https://registry.yarnpkg.com/fast-diff/-/fast-diff-1.1.2.tgz#4b62c42b8e03de3f848460b639079920695d0154"

fast-json-stable-stringify@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz#d5142c0caee6b1189f87d3a76111064f86c8bbf2"
Expand Down Expand Up @@ -1922,7 +1941,7 @@ get-pkg-repo@^1.0.0:
parse-github-repo-url "^1.3.0"
through2 "^2.0.0"

get-stdin@5.0.1:
get-stdin@5.0.1, get-stdin@^5.0.1:
version "5.0.1"
resolved "https://registry.yarnpkg.com/get-stdin/-/get-stdin-5.0.1.tgz#122e161591e21ff4c52530305693f20e6393a398"

Expand Down Expand Up @@ -2449,6 +2468,10 @@ istanbul-reports@^1.1.3:
dependencies:
handlebars "^4.0.3"

jest-docblock@^21.0.0:
version "21.2.0"
resolved "https://registry.yarnpkg.com/jest-docblock/-/jest-docblock-21.2.0.tgz#51529c3b30d5fd159da60c27ceedc195faf8d414"

jest-get-type@^21.2.0:
version "21.2.0"
resolved "https://registry.yarnpkg.com/jest-get-type/-/jest-get-type-21.2.0.tgz#f6376ab9db4b60d81e39f30749c6c466f40d4a23"
Expand Down Expand Up @@ -3323,6 +3346,10 @@ preserve@^0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/preserve/-/preserve-0.2.0.tgz#815ed1f6ebc65926f865b310c0713bcb3315ce4b"

prettier@^1.8.2:
version "1.8.2"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.8.2.tgz#bff83e7fd573933c607875e5ba3abbdffb96aeb8"

pretty-format@^21.2.1:
version "21.2.1"
resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-21.2.1.tgz#ae5407f3cf21066cd011aa1ba5fce7b6a2eddb36"
Expand Down

0 comments on commit 49bcd40

Please sign in to comment.