diff --git a/src/plugin.js b/src/plugin.js index 1b71e57..c3596d9 100644 --- a/src/plugin.js +++ b/src/plugin.js @@ -91,9 +91,9 @@ export default function transformPostCSS({ types: t }: any): any { if (tokens !== undefined) { const expression = path.findParent((test) => ( - test.isVariableDeclaration() || + test.isVariableDeclaration() || test.isExpressionStatement() - )); + )); expression.addComment( 'trailing', ` @related-file ${stylesheetPath}`, true @@ -120,16 +120,16 @@ export default function transformPostCSS({ types: t }: any): any { if (tokens) { const styles = t.objectExpression( Object.keys(tokens).map( - (token) => t.objectProperty( - t.stringLiteral(token), - t.stringLiteral(tokens[token]) - ) + (token) => t.objectProperty( + t.stringLiteral(token), + t.stringLiteral(tokens[token]) + ) ) ); /* eslint-disable new-cap */ const variableDeclaration = t.VariableDeclaration('var', - [t.VariableDeclarator(path.node.specifiers[0].local, styles)]); + [t.VariableDeclarator(path.node.specifiers[0].local, styles)]); /* eslint-enable new-cap */ path.addComment('trailing', ` @related-file ${stylesheetPath}`, true); diff --git a/src/postcss-client.js b/src/postcss-client.js index 9e5af49..9c3d4d9 100644 --- a/src/postcss-client.js +++ b/src/postcss-client.js @@ -44,7 +44,7 @@ const main = async function main(...args: string[]): Promise { /* istanbul ignore if */ if ((require: any).main === module) { - (async (): Promise => { + (async(): Promise => { try { await main(...process.argv.slice(2)); } catch (err) { process.stderr.write(`${err.stack}\n`); process.exit(1); } })(); diff --git a/src/postcss-server.js b/src/postcss-server.js index 4cc8e6e..bca6db9 100644 --- a/src/postcss-server.js +++ b/src/postcss-server.js @@ -46,7 +46,7 @@ const main = async function main( data += chunk.toString('utf8'); }); - connection.on('end', async (): Promise => { + connection.on('end', async(): Promise => { try { let tokens, cache; const { cssFile } = JSON.parse(data); @@ -139,7 +139,7 @@ const main = async function main( /* istanbul ignore if */ if ((require: any).main === module) { - (async (): Promise => { + (async(): Promise => { try { await main(...process.argv.slice(2)); } catch (err) { process.stderr.write(`${err.stack}\n`); process.exit(1); } })(); diff --git a/test/helpers.js b/test/helpers.js index 608f6b2..d532971 100644 --- a/test/helpers.js +++ b/test/helpers.js @@ -10,9 +10,10 @@ export const babelNoModules = { presets: [ ['env', { modules: false, targets: { node: 'current' } }] ], }; -export const transform = (filename: string, - babelOptionOverrides: ?{ [string]: mixed } - ): Promise => { +export const transform = ( + filename: string, + babelOptionOverrides: ?{ [string]: mixed }, +): Promise => { const file = path.join(fixtures, filename); const options = Object.assign({ diff --git a/test/plugin.js b/test/plugin.js index a43b0fb..2f8a89a 100644 --- a/test/plugin.js +++ b/test/plugin.js @@ -93,11 +93,11 @@ describe('babel-plugin-transform-postcss', () => { describe('when transforming require.js', () => { let result; - beforeEach(async () => { result = await transform('require.js'); }); + beforeEach(async() => { result = await transform('require.js'); }); it('launches the server', testServerLaunched); it('launches a client', () => testClientLaunched('simple.css')); - it('compiles correctly', async () => { + it('compiles correctly', async() => { expect(result).to.eql((await read('require.expected.js')).trim()); }); @@ -107,11 +107,11 @@ describe('babel-plugin-transform-postcss', () => { describe('when transforming import.js', () => { let result; - beforeEach(async () => { result = await transform('import.js'); }); + beforeEach(async() => { result = await transform('import.js'); }); it('launches the server', testServerLaunched); it('launches a client', () => testClientLaunched('simple.css')); - it('compiles correctly', async () => { + it('compiles correctly', async() => { expect(result).to.eql((await read('import.expected.js')).trim()); }); @@ -157,15 +157,15 @@ describe('babel-plugin-transform-postcss', () => { describe('when transforming import.js without modules', () => { let result; - beforeEach(async () => { + beforeEach(async() => { result = await transform('import.js', babelNoModules); }); it('launches the server', testServerLaunched); it('launches a client', () => testClientLaunched('simple.css')); - it('compiles correctly', async () => { + it('compiles correctly', async() => { expect(result).to.eql( - (await read('import.no.modules.expected.js')).trim() + (await read('import.no.modules.expected.js')).trim() ); }); @@ -181,9 +181,9 @@ describe('babel-plugin-transform-postcss', () => { let result; beforeEach(() => childProcess.execFileSync.returns(new Buffer(''))); - beforeEach(async () => { result = await transform('require.js'); }); + beforeEach(async() => { result = await transform('require.js'); }); - it('compiles correctly', async () => { + it('compiles correctly', async() => { expect(result).to.eql((await read('require.expected.empty.js')).trim()); }); }); diff --git a/test/postcss-client.js b/test/postcss-client.js index fdaa32a..4ea61eb 100644 --- a/test/postcss-client.js +++ b/test/postcss-client.js @@ -73,7 +73,7 @@ describe('postcss-client', () => { }); }); - afterEach(async () => { + afterEach(async() => { await new Promise((resolve: () => void, reject: (Error) => void) => { fs.unlinkSync(testSocket); server.close((err: ?Error) => { @@ -84,7 +84,7 @@ describe('postcss-client', () => { }); describe('main(...testArgs)', () => { - beforeEach(async () => { + beforeEach(async() => { const write = new Promise((resolve: () => void) => { streams.stdout.on('finish', () => resolve()); }); @@ -107,7 +107,7 @@ describe('postcss-client', () => { }); describe('main(...testArgs)', () => { - beforeEach(async () => { await main(testSocket, 'client message'); }); + beforeEach(async() => { await main(testSocket, 'client message'); }); it('attempts to re-connect', () => { expect(net.connect).to.have.been.calledTwice; diff --git a/test/postcss-server.js b/test/postcss-server.js index 6aafa0b..6572051 100644 --- a/test/postcss-server.js +++ b/test/postcss-server.js @@ -31,7 +31,7 @@ const testTmp = join(__dirname, 'tmp'); describe('postcss-server', () => { let server, originalStderr; - const invokeMain = async () => { server = await main(testSocket, testTmp); }; + const invokeMain = async() => { server = await main(testSocket, testTmp); }; const closeServer = async() => { await new Promise((resolve: () => void, reject: (Error) => void) => { server.close((err: ?Error) => { @@ -40,7 +40,7 @@ describe('postcss-server', () => { }); }); }; - const closeStderr = async () => { + const closeStderr = async() => { const write = new Promise((resolve: () => void) => { streams.stderr.on('finish', () => resolve()); }); @@ -88,7 +88,7 @@ describe('postcss-server', () => { }); const simpleCSSFile = join(__dirname, 'fixtures', 'simple.css'); - const sendMessage = async ( + const sendMessage = async( json: { cssFile: string, } @@ -113,7 +113,7 @@ describe('postcss-server', () => { return response; }; - it('accepts JSON details and extracts PostCSS modules', async () => { + it('accepts JSON details and extracts PostCSS modules', async() => { const response = await sendMessage({ cssFile: simpleCSSFile, }); @@ -121,7 +121,7 @@ describe('postcss-server', () => { expect(JSON.parse(response)).to.eql({ simple: '_simple_jvai8_1' }); }); - it('fails gracefully for invalid CSS', async () => { + it('fails gracefully for invalid CSS', async() => { const response = await sendMessage({ cssFile: join(__dirname, 'fixtures', 'invalid.css'), }); @@ -139,7 +139,7 @@ describe('postcss-server', () => { })); }); - it('accepts JSON details and extracts PostCSS modules', async () => { + it('accepts JSON details and extracts PostCSS modules', async() => { const response = await sendMessage({ cssFile: simpleCSSFile, }); @@ -156,7 +156,7 @@ describe('postcss-server', () => { fs.writeFileSync(path.join(testTmp, `${name}.cache`), 'not-json'); }); - beforeEach(async () => { + beforeEach(async() => { response = await sendMessage({ cssFile: simpleCSSFile, }); @@ -176,7 +176,7 @@ describe('postcss-server', () => { describe('with a missing CSS file', () => { let response; - beforeEach(async () => { + beforeEach(async() => { response = await sendMessage({ cssFile: join(__dirname, 'fixtures', 'nofile'), }); @@ -199,7 +199,7 @@ describe('postcss-server', () => { beforeEach(() => stub(path, 'dirname').callsFake(() => process.cwd())); afterEach(() => path.dirname.restore()); - beforeEach(async () => { + beforeEach(async() => { response = await sendMessage({ cssFile: join(__dirname, 'fixtures', 'simple.css'), configFile: join(__dirname, 'fixtures', 'nofile'), @@ -226,7 +226,7 @@ describe('postcss-server', () => { }); afterEach(() => { Server.prototype.listen.restore(); }); - it('fails to complete main(...testArgs)', async () => { + it('fails to complete main(...testArgs)', async() => { let error; try { await invokeMain(); } @@ -276,7 +276,7 @@ describe('postcss-server', () => { beforeEach(() => { stub(fs, 'mkdirSync').throws('Error with no code'); }); afterEach(() => { fs.mkdirSync.restore(); }); - it('errors when invoking main', async () => { + it('errors when invoking main', async() => { let error; try { await invokeMain(); }