Skip to content

Commit 38a9c59

Browse files
committed
Added prettier
1 parent c86f531 commit 38a9c59

39 files changed

+419
-378
lines changed

.eslintrc.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
module.exports = {
22
parser: 'babel-eslint',
3-
extends: ['jss'],
3+
extends: ['jss', 'prettier'],
44
globals: {
55
benchmark: true
66
},
77
env: {
88
mocha: true,
99
browser: true
10-
},
10+
}
1111
}

.prettierignore

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
node_modules/
2+
dist/
3+
lib/
4+
*.html
5+
# npm install does it's own formatting, which can conflict with prettier
6+
package.json
7+
!packages/**/package.json

.prettierrc

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"semi": false,
3+
"singleQuote": true,
4+
"trailingComma": "none",
5+
"bracketSpacing": false,
6+
"printWidth": 100
7+
}

babel.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module.exports = (api) => {
1+
module.exports = api => {
22
api.cache(true)
33
const presets = [['@babel/env', {loose: true}]]
44
const plugins = [

benchmark/tests/supported-value.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ import {supportedValue} from '../../src'
33
suite('Supported value', () => {
44
benchmark('background-color', () => supportedValue('background-color', 'white') === 'white')
55

6-
benchmark('transform with double array value', () => (
7-
supportedValue('transition', 'all 100ms ease, transform 200ms linear') ===
8-
'all 100ms ease, transform 200ms linear'
9-
))
6+
benchmark(
7+
'transform with double array value',
8+
() =>
9+
supportedValue('transition', 'all 100ms ease, transform 200ms linear') ===
10+
'all 100ms ease, transform 200ms linear'
11+
)
1012
})

changelog.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@
2222

2323
- Added support for various properties for old browsers, undetectable with feature tests:
2424
- appearance
25-
- break-*
25+
- break-\*
2626
- clip-path
2727
- filter
2828
- flex
2929
- (border|margin|padding)-inline
30-
- mask-*
30+
- mask-\*
3131
- scroll-snap
3232
- transform
3333
- transition

karma.conf.js

+8-6
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,27 @@ const travisBuildId = process.env.TRAVIS_BUILD_ID
1010
const travisJobNumber = process.env.TRAVIS_JOB_NUMBER
1111
const isBench = process.env.NODE_ENV === 'benchmark'
1212

13-
module.exports = (config) => {
13+
module.exports = config => {
1414
config.set({
1515
customLaunchers: browsers,
1616
browsers: ['Chrome'],
1717
frameworks: ['mocha'],
1818
files: [
1919
'node_modules/es5-shim/es5-shim.js',
2020
'node_modules/es5-shim/es5-sham.js',
21-
'tests.webpack.js',
21+
'tests.webpack.js'
2222
],
2323
preprocessors: {
24-
'tests.webpack.js': ['webpack', 'sourcemap'],
24+
'tests.webpack.js': ['webpack', 'sourcemap']
2525
},
2626
webpack: Object.assign(webpackConfig, {
2727
devtool: 'inline-source-map',
2828
module: {
29-
rules: [Object.assign(webpackConfig.module.rules[0], {
30-
exclude: /node_modules(?!(\/|\\)camelcase-css)/
31-
})]
29+
rules: [
30+
Object.assign(webpackConfig.module.rules[0], {
31+
exclude: /node_modules(?!(\/|\\)camelcase-css)/
32+
})
33+
]
3234
}
3335
}),
3436
webpackServer: {

package.json

+4
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"clean": "rimraf {dist,tmp}/*",
3333
"lint": "eslint ./src ./tests --fix",
3434
"lint:staged": "lint-staged",
35+
"format": "prettier \"*.{js,md}\" \"{tests,src,benchmark}/**/*.js\" --write",
3536
"test": "cross-env NODE_ENV=test karma start --single-run ",
3637
"test:watch": "cross-env NODE_ENV=test karma start",
3738
"bench": "cross-env NODE_ENV=benchmark karma start --single-run",
@@ -55,6 +56,7 @@
5556
"es5-shim": "^4.5.10",
5657
"eslint": "^5.13.0",
5758
"eslint-config-jss": "^5.0.1",
59+
"eslint-config-prettier": "^4.0.0",
5860
"expect.js": "^0.3.1",
5961
"karma": "^3.1.4",
6062
"karma-benchmark": "^1.0.0",
@@ -72,6 +74,7 @@
7274
"mocha": "^5.2.0",
7375
"postcss-js": "^2.0.0",
7476
"pre-commit": "^1.1.3",
77+
"prettier": "1.16.4",
7578
"rimraf": "^2.6.2",
7679
"rollup": "^1.1.2",
7780
"rollup-plugin-babel": "^4.3.2",
@@ -89,6 +92,7 @@
8992
"lint-staged": {
9093
"**/*.js": [
9194
"eslint --fix",
95+
"prettier --write",
9296
"git add"
9397
]
9498
},

rollup.config.js

+4-12
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ const external = id => !id.startsWith('.') && !id.startsWith('/')
1414
const getBabelOptions = ({useESModules}) => ({
1515
exclude: /node_modules/,
1616
runtimeHelpers: true,
17-
plugins: [
18-
['@babel/transform-runtime', {useESModules}]
19-
]
17+
plugins: [['@babel/transform-runtime', {useESModules}]]
2018
})
2119

2220
export default [
@@ -47,19 +45,13 @@ export default [
4745
input,
4846
output: {file: pkg.main, format: 'cjs'},
4947
external,
50-
plugins: [
51-
babel(getBabelOptions({useESModules: false})),
52-
sizeSnapshot()
53-
]
48+
plugins: [babel(getBabelOptions({useESModules: false})), sizeSnapshot()]
5449
},
5550

5651
{
5752
input,
5853
output: {file: pkg.module, format: 'esm'},
5954
external,
60-
plugins: [
61-
babel(getBabelOptions({useESModules: true})),
62-
sizeSnapshot()
63-
]
64-
},
55+
plugins: [babel(getBabelOptions({useESModules: true})), sizeSnapshot()]
56+
}
6557
]

src/index.js

+5-10
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,9 @@
66
* @license MIT
77
*/
88

9-
import prefix from './prefix';
10-
import supportedKeyframes from './supported-keyframes';
11-
import supportedProperty from './supported-property';
12-
import supportedValue from './supported-value';
9+
import prefix from './prefix'
10+
import supportedKeyframes from './supported-keyframes'
11+
import supportedProperty from './supported-property'
12+
import supportedValue from './supported-value'
1313

14-
export {
15-
prefix,
16-
supportedKeyframes,
17-
supportedProperty,
18-
supportedValue,
19-
};
14+
export {prefix, supportedKeyframes, supportedProperty, supportedValue}

src/index.test.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { currentBrowser } from 'caniuse-support';
1+
import {currentBrowser} from 'caniuse-support'
22

3-
const msg = `Detected browser: ${currentBrowser.id} ${currentBrowser.version}`;
4-
console.log(msg); // eslint-disable-line no-console
3+
const msg = `Detected browser: ${currentBrowser.id} ${currentBrowser.version}`
4+
console.log(msg) // eslint-disable-line no-console

src/plugins/appearence.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import prefix from '../prefix';
1+
import prefix from '../prefix'
22

33
// Support old appearance props syntax.
44
// https://caniuse.com/#search=appearance
55
export default {
66
noPrefill: ['appearance'],
7-
supportedProperty: (prop) => {
8-
if (prop !== 'appearance') return false;
9-
if (prefix.js === 'ms') return `-webkit-${prop}`;
10-
return prefix.css + prop;
11-
},
12-
};
7+
supportedProperty: prop => {
8+
if (prop !== 'appearance') return false
9+
if (prefix.js === 'ms') return `-webkit-${prop}`
10+
return prefix.css + prop
11+
}
12+
}

src/plugins/break-props-old.js

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
import prefix from '../prefix';
2-
import pascalize from '../utils/pascalize';
1+
import prefix from '../prefix'
2+
import pascalize from '../utils/pascalize'
33

44
// Support old break-* props syntax.
55
// https://caniuse.com/#search=multicolumn
66
// https://github.com/postcss/autoprefixer/issues/491
77
// https://github.com/postcss/autoprefixer/issues/177
88
export default {
99
supportedProperty: (prop, style) => {
10-
if (!/^break-/.test(prop)) return false;
10+
if (!/^break-/.test(prop)) return false
1111
if (prefix.js === 'Webkit') {
12-
const jsProp = `WebkitColumn${pascalize(prop)}`;
13-
return jsProp in style ? `${prefix.css}column-${prop}` : false;
12+
const jsProp = `WebkitColumn${pascalize(prop)}`
13+
return jsProp in style ? `${prefix.css}column-${prop}` : false
1414
}
1515
if (prefix.js === 'Moz') {
16-
const jsProp = `page${pascalize(prop)}`;
17-
return jsProp in style ? `page-${prop}` : false;
16+
const jsProp = `page${pascalize(prop)}`
17+
return jsProp in style ? `page-${prop}` : false
1818
}
19-
return false;
20-
},
21-
};
19+
return false
20+
}
21+
}

src/plugins/color-adjust.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import prefix from '../prefix';
1+
import prefix from '../prefix'
22

33
// Support old color-adjust prop syntax.
44
// https://caniuse.com/#search=color-adjust
55
export default {
66
noPrefill: ['color-adjust'],
7-
supportedProperty: (prop) => {
8-
if (prop !== 'color-adjust') return false;
9-
if (prefix.js === 'Webkit') return `${prefix.css}print-${prop}`;
10-
return prop;
11-
},
12-
};
7+
supportedProperty: prop => {
8+
if (prop !== 'color-adjust') return false
9+
if (prefix.js === 'Webkit') return `${prefix.css}print-${prop}`
10+
return prop
11+
}
12+
}

src/plugins/flex-2009.js

+15-15
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import prefix from '../prefix';
2-
import pascalize from '../utils/pascalize';
1+
import prefix from '../prefix'
2+
import pascalize from '../utils/pascalize'
33

44
const propMap = {
55
flex: 'box-flex',
@@ -8,29 +8,29 @@ const propMap = {
88
order: 'box-ordinal-group',
99
'align-items': 'box-align',
1010
'flex-flow': ['box-orient', 'box-direction'],
11-
'justify-content': 'box-pack',
12-
};
11+
'justify-content': 'box-pack'
12+
}
1313

14-
const propKeys = Object.keys(propMap);
14+
const propKeys = Object.keys(propMap)
1515

16-
const prefixCss = p => prefix.css + p;
16+
const prefixCss = p => prefix.css + p
1717

1818
// Support old flex spec from 2009.
1919
export default {
20-
supportedProperty: (prop, style, { multiple }) => {
20+
supportedProperty: (prop, style, {multiple}) => {
2121
if (propKeys.indexOf(prop) > -1) {
22-
const newProp = propMap[prop];
22+
const newProp = propMap[prop]
2323
if (!Array.isArray(newProp)) {
24-
return prefix.js + pascalize(newProp) in style ? prefix.css + newProp : false;
24+
return prefix.js + pascalize(newProp) in style ? prefix.css + newProp : false
2525
}
26-
if (!multiple) return false;
26+
if (!multiple) return false
2727
for (let i = 0; i < newProp.length; i++) {
2828
if (!(prefix.js + pascalize(newProp[0]) in style)) {
29-
return false;
29+
return false
3030
}
3131
}
32-
return newProp.map(prefixCss);
32+
return newProp.map(prefixCss)
3333
}
34-
return false;
35-
},
36-
};
34+
return false
35+
}
36+
}

src/plugins/flex-2012.js

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import prefix from '../prefix';
2-
import pascalize from '../utils/pascalize';
1+
import prefix from '../prefix'
2+
import pascalize from '../utils/pascalize'
33

44
const propMap = {
55
'flex-grow': 'flex-positive',
@@ -8,15 +8,15 @@ const propMap = {
88
'justify-content': 'flex-pack',
99
order: 'flex-order',
1010
'align-items': 'flex-align',
11-
'align-content': 'flex-line-pack',
11+
'align-content': 'flex-line-pack'
1212
// 'align-self' is handled by 'align-self' plugin.
13-
};
13+
}
1414

1515
// Support old flex spec from 2012.
1616
export default {
1717
supportedProperty: (prop, style) => {
18-
const newProp = propMap[prop];
19-
if (!newProp) return false;
20-
return prefix.js + pascalize(newProp) in style ? prefix.css + newProp : false;
21-
},
22-
};
18+
const newProp = propMap[prop]
19+
if (!newProp) return false
20+
return prefix.js + pascalize(newProp) in style ? prefix.css + newProp : false
21+
}
22+
}

0 commit comments

Comments
 (0)