Skip to content

Commit a361673

Browse files
committed
chore: move 'prettier' settings to 'package.json' for format-on-save compatibility
'comma-dangle' has been modified in '.eslintrc.js' to get perfect compatibility with 'prettier''s 'trailingComma: all' setting we use in 'package.json'. Fixes #83.
1 parent 0944102 commit a361673

File tree

3 files changed

+27
-23
lines changed

3 files changed

+27
-23
lines changed

.eslintrc.js

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
module.exports = { // eslint-disable-line import/unambiguous
1+
// eslint-disable-next-line import/unambiguous
2+
module.exports = {
23
parser: 'babel-eslint',
34
plugins: [
45
'ava', // SEE: https://github.com/avajs/eslint-plugin-ava
@@ -25,12 +26,11 @@ module.exports = { // eslint-disable-line import/unambiguous
2526
'plugin:import/warnings', // https://git.io/vyRv9
2627

2728
// SEE: https://github.com/prettier/eslint-config-prettier
28-
"prettier",
29-
"prettier/flowtype",
30-
"prettier/react",
29+
'prettier',
30+
'prettier/flowtype',
31+
'prettier/react',
3132
],
32-
rules:
33-
{
33+
rules: {
3434
// Disable this for now, it doesn't seem to work correctly with polymorphic
3535
// Flow types (e.g <T>(...)).
3636
'arrow-parens': 0,
@@ -51,5 +51,16 @@ module.exports = { // eslint-disable-line import/unambiguous
5151

5252
// No semicolons. Overrides the recommended 'airbnb' setting.
5353
semi: 0,
54+
55+
'comma-dangle': [
56+
'error',
57+
{
58+
arrays: 'always-multiline',
59+
objects: 'always-multiline',
60+
imports: 'always-multiline',
61+
exports: 'always-multiline',
62+
functions: 'always-multiline',
63+
},
64+
],
5465
},
5566
}

package.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,14 @@
7777
"engines": {
7878
"node": ">=6"
7979
},
80+
"prettier": {
81+
"bracketSpacing": true,
82+
"singleQuote": true,
83+
"jsxBracketSameLine": true,
84+
"trailingComma": "all",
85+
"printWidth": 80,
86+
"semi": false
87+
},
8088
"scripts": {
8189
"build": "cross-env BABEL_ENV=build babel src --out-dir ./lib",
8290
"build:module": "cross-env BABEL_ENV=module babel src --out-dir ./module ",

scripts/tasks/prettier.js

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,31 +16,18 @@ const prettierCmd = path.resolve(
1616
__dirname,
1717
`../../node_modules/.bin/${prettier}`,
1818
)
19-
const defaultOptions = {
20-
'bracket-spacing': 'true',
21-
'single-quote': 'true',
22-
'jsx-bracket-same-line': 'true',
23-
'trailing-comma': 'all',
24-
'print-width': 80,
25-
semi: 'false',
26-
parser: 'flow',
27-
}
2819

2920
// We assign the 'Object' type to specify that 'config' is not sealed.
3021
// eslint-disable-next-line flowtype/no-weak-types
3122
let config: Object = {
3223
default: {
33-
patterns: ['src/**/*.js'],
24+
patterns: ['src/**/*.js', '.eslintrc.js'],
3425
ignore: ['**/node_modules/**'],
3526
},
3627
scripts: {
3728
patterns: ['scripts/**/*.js'],
3829
ignore: [],
3930
},
40-
static: {
41-
patterns: ['static/**/*.js'],
42-
ignore: [],
43-
},
4431
}
4532

4633
if (process.argv[3]) {
@@ -67,9 +54,7 @@ Object.keys(config).forEach(key => {
6754
patterns.length > 1 ? `{${patterns.join(',')}}` : `${patterns.join(',')}`
6855
const files = glob.sync(globPattern, { ignore })
6956

70-
const args = Object.keys(defaultOptions).map(
71-
k => `--${k}=${(options && options[k]) || defaultOptions[k]}`,
72-
)
57+
const args = []
7358
args.push(`--${shouldWrite ? 'write' : 'l'}`)
7459

7560
try {

0 commit comments

Comments
 (0)