mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-31 10:51:44 +02:00
Add Prettier with ESLint integration (#1589)
* Add Prettier, with basic config and ESLint integration * Apply Prettier to all files using `yarn lint --fix` * Tell Prettier to ignore an empty text in a test output. * Run Prettier on JS files not handled by ESLint, and lint them too
This commit is contained in:
committed by
Ian Storm Taylor
parent
f28c59a26e
commit
3339d088e1
@@ -27,8 +27,8 @@ baseline.forEach((suite, i) => {
|
||||
const b = base.iterations / base.elapsed * 1000
|
||||
const c = comp.iterations / comp.elapsed * 1000
|
||||
const threshold = b * THRESHOLD
|
||||
const slower = (b - c) > threshold
|
||||
const faster = (b - c) < (0 - threshold)
|
||||
const slower = b - c > threshold
|
||||
const faster = b - c < 0 - threshold
|
||||
const percent = Math.round(Math.abs(b - c) / b * 100)
|
||||
|
||||
let output = `${b.toFixed(2)} → ${c.toFixed(2)} ops/sec`
|
||||
|
@@ -1,7 +1,6 @@
|
||||
|
||||
const { stdout } = process
|
||||
|
||||
module.exports = function (runner, utils) {
|
||||
module.exports = function(runner, utils) {
|
||||
let hasSuite = false
|
||||
let hasBench = false
|
||||
|
||||
@@ -13,18 +12,18 @@ module.exports = function (runner, utils) {
|
||||
stdout.write(']')
|
||||
})
|
||||
|
||||
runner.on('suite start', (suite) => {
|
||||
runner.on('suite start', suite => {
|
||||
if (hasSuite) stdout.write(',')
|
||||
stdout.write(`{"name":"${suite.title}","benchmarks":[`)
|
||||
hasSuite = true
|
||||
})
|
||||
|
||||
runner.on('suite end', (suite) => {
|
||||
runner.on('suite end', suite => {
|
||||
hasBench = false
|
||||
stdout.write(']}')
|
||||
})
|
||||
|
||||
runner.on('bench end', (bench) => {
|
||||
runner.on('bench end', bench => {
|
||||
if (hasBench) stdout.write(',')
|
||||
stdout.write(JSON.stringify(bench))
|
||||
hasBench = true
|
||||
|
@@ -34,7 +34,10 @@ const umdConfig = {
|
||||
// variant of `react-dom/server` relies on Node.js's Stream.
|
||||
alias({
|
||||
debug: path.resolve(__dirname, 'node_modules/debug/src/browser'),
|
||||
'react-dom/server': path.resolve(__dirname, 'node_modules/react-dom/cjs/react-dom-server.browser.production.min'),
|
||||
'react-dom/server': path.resolve(
|
||||
__dirname,
|
||||
'node_modules/react-dom/cjs/react-dom-server.browser.production.min'
|
||||
),
|
||||
}),
|
||||
|
||||
// Allow rollup to resolve modules that are npm dependencies
|
||||
@@ -51,8 +54,16 @@ const umdConfig = {
|
||||
// hint that e.g. `import { List } from 'immutable'` is a reference
|
||||
// to a valid named export.
|
||||
namedExports: {
|
||||
'esrever': ['reverse'],
|
||||
'immutable': ['List', 'Map', 'Record', 'OrderedSet', 'Set', 'Stack', 'is'],
|
||||
esrever: ['reverse'],
|
||||
immutable: [
|
||||
'List',
|
||||
'Map',
|
||||
'Record',
|
||||
'OrderedSet',
|
||||
'Set',
|
||||
'Stack',
|
||||
'is',
|
||||
],
|
||||
'react-dom': ['findDOMNode'],
|
||||
'react-dom/server': ['renderToStaticMarkup'],
|
||||
},
|
||||
@@ -65,23 +76,20 @@ const umdConfig = {
|
||||
// some modules like React to use their production variant (and
|
||||
// one place within Slate itself).
|
||||
replace({
|
||||
'process.env.NODE_ENV': JSON.stringify(environment)
|
||||
'process.env.NODE_ENV': JSON.stringify(environment),
|
||||
}),
|
||||
|
||||
// Use babel to transpile the result -- limit to package src
|
||||
// to prevent babel from trying to transpile npm dependencies.
|
||||
babel({
|
||||
include: ['examples/**']
|
||||
include: ['examples/**'],
|
||||
}),
|
||||
],
|
||||
// Limit rollup's file watching to example src files and the
|
||||
// built output of packages -- helps keep it from watching
|
||||
// too much and choking.
|
||||
watch: {
|
||||
include: [
|
||||
'examples/**',
|
||||
'packages/*/lib/*.es.js',
|
||||
],
|
||||
include: ['examples/**', 'packages/*/lib/*.es.js'],
|
||||
},
|
||||
}
|
||||
|
||||
|
@@ -9,7 +9,7 @@ import uglify from 'rollup-plugin-uglify'
|
||||
|
||||
const environment = process.env.NODE_ENV || 'development'
|
||||
|
||||
export default (pkg) => {
|
||||
export default pkg => {
|
||||
const pkgName = pkg.name
|
||||
const output = {
|
||||
cjs: pkg.main,
|
||||
@@ -33,7 +33,8 @@ export default (pkg) => {
|
||||
// 2. It is part of a package.json dependency (e.g. `lodash/omit`)
|
||||
// External dependencies are expected to be present at runtime (rather than being bundled into
|
||||
// our built dist).
|
||||
const isExternalDependency = id => !!dependencies.find(dep => dep === id || id.startsWith(`${dep}/`))
|
||||
const isExternalDependency = id =>
|
||||
!!dependencies.find(dep => dep === id || id.startsWith(`${dep}/`))
|
||||
|
||||
// UMD build for browsers
|
||||
const umdConfig = {
|
||||
@@ -79,8 +80,16 @@ export default (pkg) => {
|
||||
// hint that e.g. `import { List } from 'immutable'` is a reference
|
||||
// to a valid named export.
|
||||
namedExports: {
|
||||
'esrever': ['reverse'],
|
||||
'immutable': ['List', 'Map', 'Record', 'OrderedSet', 'Set', 'Stack', 'is'],
|
||||
esrever: ['reverse'],
|
||||
immutable: [
|
||||
'List',
|
||||
'Map',
|
||||
'Record',
|
||||
'OrderedSet',
|
||||
'Set',
|
||||
'Stack',
|
||||
'is',
|
||||
],
|
||||
'react-dom': ['findDOMNode'],
|
||||
'react-dom/server': ['renderToStaticMarkup'],
|
||||
},
|
||||
@@ -90,15 +99,15 @@ export default (pkg) => {
|
||||
// some modules like React to use their production variant (and
|
||||
// one place within Slate itself).
|
||||
replace({
|
||||
'process.env.NODE_ENV': JSON.stringify('production')
|
||||
'process.env.NODE_ENV': JSON.stringify('production'),
|
||||
}),
|
||||
|
||||
// Use babel to transpile the result -- limit to package src
|
||||
// to prevent babel from trying to transpile npm dependencies.
|
||||
babel({
|
||||
include: [`packages/${pkgName}/src/**`]
|
||||
include: [`packages/${pkgName}/src/**`],
|
||||
}),
|
||||
]
|
||||
],
|
||||
}
|
||||
|
||||
// Additional UMD minified build based off of the unminified config
|
||||
@@ -137,15 +146,15 @@ export default (pkg) => {
|
||||
// some modules like React to use their production variant (and
|
||||
// one place within Slate itself).
|
||||
replace({
|
||||
'process.env.NODE_ENV': JSON.stringify(environment)
|
||||
'process.env.NODE_ENV': JSON.stringify(environment),
|
||||
}),
|
||||
|
||||
// Use babel to transpile the result -- limit to package src
|
||||
// to prevent babel from trying to transpile npm dependencies.
|
||||
babel({
|
||||
include: [`packages/${pkgName}/src/**`]
|
||||
include: [`packages/${pkgName}/src/**`],
|
||||
}),
|
||||
]
|
||||
],
|
||||
}
|
||||
|
||||
const configurations = [moduleConfig]
|
||||
|
Reference in New Issue
Block a user