Skip to content

Commit

Permalink
chore(lint): consistent trailing commas
Browse files Browse the repository at this point in the history
1. ran `yarn eslint . --fix`
2. ran `yarn jest -u` (trailing commas changed snapshots)

see emotion-js#525 (comment)
  • Loading branch information
Haroenv committed Jan 9, 2018
1 parent b1db578 commit bfe24fc
Show file tree
Hide file tree
Showing 109 changed files with 649 additions and 647 deletions.
2 changes: 1 addition & 1 deletion babel-plugin-emotion-test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require('babel-register')
const path = require('path')
require('module-alias').addAliases({
'emotion-utils': path.resolve(__dirname, './packages/emotion-utils/src')
'emotion-utils': path.resolve(__dirname, './packages/emotion-utils/src'),
})

module.exports = require('./packages/babel-plugin-emotion/src')
6 changes: 4 additions & 2 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ const { jest: lernaAliases } = require('lerna-alias')
module.exports = {
transform: {
'\\.css$': '<rootDir>/test/styleTransform.js',
'^.+\\.js?$': 'babel-jest'
'^.+\\.js?$': 'babel-jest',
},
moduleNameMapper: lernaAliases(),
setupTestFrameworkScriptFile: '<rootDir>/test/testSetup.js',
coveragePathIgnorePatterns: ['<rootDir>/packages/emotion-utils/src/stylis.js']
coveragePathIgnorePatterns: [
'<rootDir>/packages/emotion-utils/src/stylis.js',
],
}
2 changes: 1 addition & 1 deletion jest.dist.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ const baseConfig = require('./jest.config.js')
module.exports = Object.assign({}, baseConfig, {
moduleNameMapper: lernaAliases({ sourceDirectory: false }),
transformIgnorePatterns: ['dist', 'node_modules'],
testPathIgnorePatterns: ['babel-plugin-emotion']
testPathIgnorePatterns: ['babel-plugin-emotion'],
})
2 changes: 1 addition & 1 deletion packages/babel-plugin-emotion/src/ast-object.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default class ASTObject {
matches.push({
value: match[0],
p1: parseInt(match[1], 10),
index: match.index
index: match.index,
})
}

Expand Down
8 changes: 4 additions & 4 deletions packages/babel-plugin-emotion/src/babel-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ export function getRuntimeImportPath(path: BabelPath, t: Types) {
type EmotionMacroPluginPass = EmotionBabelPluginPass & {
emotionImports: void | {
[key: string]: {
[key: string]: Identifier
}
}
[key: string]: Identifier,
},
},
}

export function buildMacroRuntimeNode(
Expand Down Expand Up @@ -101,7 +101,7 @@ export function getName(identifierName?: string, prefix: string) {
}

export function createRawStringFromTemplateLiteral(quasi: {
quasis: Array<{ value: { cooked: string } }>
quasis: Array<{ value: { cooked: string } }>,
}) {
let strs = quasi.quasis.map(x => x.value.cooked)
let hash = hashArray([...strs])
Expand Down
8 changes: 4 additions & 4 deletions packages/babel-plugin-emotion/src/css-prop.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ export default function(
[
t.templateElement({
raw: cssPropValue.value,
cooked: cssPropValue.value
})
cooked: cssPropValue.value,
}),
],
[]
)
Expand All @@ -58,7 +58,7 @@ export default function(
const args = state.opts.sourceMap
? [
cssPropValue,
t.stringLiteral(addSourceMaps(cssPath.node.loc.start, state))
t.stringLiteral(addSourceMaps(cssPath.node.loc.start, state)),
]
: [cssPropValue]
cssTemplateExpression = t.callExpression(getCssIdentifer(), args)
Expand All @@ -79,7 +79,7 @@ export default function(
add(
cssTemplateExpression,
add(t.stringLiteral(' '), classNamesValue.expression)
)
),
]

if (state.opts.sourceMap) {
Expand Down
46 changes: 23 additions & 23 deletions packages/babel-plugin-emotion/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ import {
getIdentifierName,
getName,
createRawStringFromTemplateLiteral,
minify
minify,
} from './babel-utils'
import type {
BabelPath as _BabelPath,
Identifier,
BabelPluginPass,
Types,
StringLiteral,
Babel
Babel,
} from 'babel-flow-types'
import { hashString, Stylis, memoize } from 'emotion-utils'
import { addSourceMaps } from './source-map'
Expand All @@ -25,7 +25,7 @@ import cssProps from './css-prop'
import ASTObject from './ast-object'

export type BabelPath = _BabelPath & {
node: *
node: *,
}

export function hashArray(arr: Array<string>) {
Expand All @@ -51,7 +51,7 @@ type ImportedNames = {
keyframes: string,
injectGlobal: string,
styled: string,
merge: string
merge: string,
}

export type EmotionBabelPluginPass = BabelPluginPass & {
Expand All @@ -62,7 +62,7 @@ export type EmotionBabelPluginPass = BabelPluginPass & {
cssPropIdentifiers: Array<Identifier>,
importedNames: ImportedNames,
count: number,
opts: any
opts: any,
}

export function replaceCssWithCallExpression(
Expand Down Expand Up @@ -198,8 +198,8 @@ export function buildStyledCallExpression(
tag,
t.objectExpression([
t.objectProperty(t.identifier('e'), t.stringLiteral(staticClassName)),
targetProperty
])
targetProperty,
]),
]),
[]
)
Expand All @@ -225,7 +225,7 @@ export function buildStyledCallExpression(
return t.callExpression(
t.callExpression(identifier, [
tag,
t.objectExpression([labelProperty, targetProperty].filter(Boolean))
t.objectExpression([labelProperty, targetProperty].filter(Boolean)),
]),
new ASTObject(minify(src), path.node.quasi.expressions, t).toExpressions()
)
Expand Down Expand Up @@ -274,7 +274,7 @@ const defaultImportedNames: ImportedNames = {
css: 'css',
keyframes: 'keyframes',
injectGlobal: 'injectGlobal',
merge: 'merge'
merge: 'merge',
}

const importedNameKeys = Object.keys(defaultImportedNames).map(
Expand Down Expand Up @@ -338,7 +338,7 @@ export default function(babel: Babel) {

state.importedNames = {
...defaultImportedNames,
...state.opts.importedNames
...state.opts.importedNames,
}

const imports = []
Expand All @@ -364,7 +364,7 @@ export default function(babel: Babel) {
imports.push({
source: node.source.value,
imported,
specifiers
specifiers,
})

for (const specifier of path.get('specifiers')) {
Expand All @@ -375,7 +375,7 @@ export default function(babel: Babel) {
specifiers.push({
kind: 'named',
imported: 'default',
local
local,
})
}

Expand All @@ -385,12 +385,12 @@ export default function(babel: Babel) {
specifiers.push({
kind: 'named',
imported: importedName,
local
local,
})
}
}
}
}
},
},
})
}
const emotionPaths = defaultEmotionPaths.concat(
Expand All @@ -412,13 +412,13 @@ export default function(babel: Babel) {
.reduce(
(acc, { imported, local }) => ({
...acc,
[imported === 'default' ? 'styled' : imported]: local
[imported === 'default' ? 'styled' : imported]: local,
}),
defaultImportedNames
)
state.importedNames = {
...importedNames,
...state.opts.importedNames
...state.opts.importedNames,
}
}
})
Expand Down Expand Up @@ -451,7 +451,7 @@ export default function(babel: Babel) {
fs.writeFileSync(cssFilename, toWrite)
}
}
}
},
},
JSXOpeningElement(path: BabelPath, state: EmotionBabelPluginPass) {
cssProps(path, state, t)
Expand All @@ -465,7 +465,7 @@ export default function(babel: Babel) {
) {
hoistPureArgs(callExprPath)
}
}
},
})
}
},
Expand Down Expand Up @@ -537,15 +537,15 @@ export default function(babel: Babel) {
if (path.node.arguments.length === 1) {
path.node.arguments.push(
t.objectExpression([
buildTargetObjectProperty(path, state, t)
buildTargetObjectProperty(path, state, t),
])
)
}
}
} catch (e) {
throw path.buildCodeFrameError(e)
}
}
},
},
TaggedTemplateExpression(path: BabelPath, state: EmotionBabelPluginPass) {
// $FlowFixMe
Expand Down Expand Up @@ -610,7 +610,7 @@ export default function(babel: Babel) {
)
}
}
}
}
},
},
}
}
6 changes: 3 additions & 3 deletions packages/babel-plugin-emotion/src/source-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export function makeSourceMapGenerator(file: BabelFile) {
const filename = generatorOpts.sourceFileName
const generator = new SourceMapGenerator({
file: filename,
sourceRoot: generatorOpts.sourceRoot
sourceRoot: generatorOpts.sourceRoot,
})

generator.setSourceContent(filename, file.code)
Expand All @@ -29,10 +29,10 @@ export function addSourceMaps(
generator.addMapping({
generated: {
line: 1,
column: 0
column: 0,
},
source: generatorOpts.sourceFileName,
original: offset
original: offset,
})
return '\n' + convert.fromObject(generator).toComment({ multiline: true })
}
Loading

0 comments on commit bfe24fc

Please sign in to comment.