Skip to content

Commit

Permalink
style(standard): fix linting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-ciniawsky committed Aug 4, 2018
1 parent 8ef443f commit 8772814
Show file tree
Hide file tree
Showing 10 changed files with 95 additions and 92 deletions.
2 changes: 1 addition & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ module.exports = function loader (css, map, meta) {
}
}

rc.ctx.webpack = this;
rc.ctx.webpack = this

return postcssrc(rc.ctx, rc.path)
}).then((config) => {
Expand Down
8 changes: 4 additions & 4 deletions test/fixtures/config/context/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ const postcss = require('postcss')
// This plugin creates asset file in webpack compilation
module.exports = postcss.plugin('plugin', (ctx) => {
ctx.webpack._compilation.assets['asset.txt'] = {
source() {
return '123';
source () {
return '123'
},
size() {
return 0;
size () {
return 0
}
}
})
18 changes: 11 additions & 7 deletions test/loader.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const webpack = require('./helpers/compiler')
const { loader } = require('./helpers/compilation')
const { copyFile, deleteFile } = require('./helpers/fs');
const { copyFile, deleteFile } = require('./helpers/fs')

describe('Loader', () => {
test('Default', () => {
Expand All @@ -15,11 +15,11 @@ describe('Loader', () => {
}

return webpack('css/index.js', config).then((stats) => {
const src = loader(stats).src
const src = loader(stats).src

expect(src).toEqual("module.exports = \"a { color: black }\\n\"")
expect(src).toMatchSnapshot()
})
expect(src).toEqual('module.exports = "a { color: black }\\n"')
expect(src).toMatchSnapshot()
})
})

describe('Watching', () => {
Expand All @@ -40,7 +40,7 @@ describe('Loader', () => {
options: {
plugins: [
require('postcss-import')
],
]
}
}
}
Expand All @@ -66,7 +66,7 @@ describe('Loader', () => {
const { err, src } = loader(stats)

expect(src).toMatchSnapshot()
expect(src).toEqual("module.exports = \"a { color: black }\\n\"")
expect(src).toEqual('module.exports = "a { color: black }\\n"')
expect(err.length).toEqual(0)

return close()
Expand All @@ -77,6 +77,10 @@ describe('Loader', () => {

const options = {
watch (err, stats, close) {
if (err) {
throw err
}

steps[step](stats, close)

step++
Expand Down
41 changes: 20 additions & 21 deletions test/options/config.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ describe('Options', () => {
}

return webpack('css/index.js', config).then((stats) => {
const src = loader(stats).src
const src = loader(stats).src

expect(src).toEqual("module.exports = \"a { color: rgba(255, 0, 0, 1.0) }\\n\"")
expect(src).toMatchSnapshot()
})
expect(src).toEqual('module.exports = "a { color: rgba(255, 0, 0, 1.0) }\\n"')
expect(src).toMatchSnapshot()
})
})

test('Config - Path - {String}', () => {
Expand All @@ -27,11 +27,11 @@ describe('Options', () => {
}

return webpack('css/index.js', config).then((stats) => {
const src = loader(stats).src
const src = loader(stats).src

expect(src).toEqual("module.exports = \"a { color: black }\\n\"")
expect(src).toMatchSnapshot()
})
expect(src).toEqual('module.exports = "a { color: black }\\n"')
expect(src).toMatchSnapshot()
})
})

test('Config - Context - {Object}', () => {
Expand All @@ -47,14 +47,13 @@ describe('Options', () => {
}

return webpack('css/index.js', config).then((stats) => {
const src = loader(stats).src
const src = loader(stats).src

expect(src).toEqual("module.exports = \"a { color: rgba(255, 0, 0, 1.0) }\\n\"")
expect(src).toMatchSnapshot()
})
expect(src).toEqual('module.exports = "a { color: rgba(255, 0, 0, 1.0) }\\n"')
expect(src).toMatchSnapshot()
})
})


test('Config - Context - {Object} - with ident', () => {
const config = {
loader: {
Expand All @@ -69,11 +68,11 @@ describe('Options', () => {
}

return webpack('css/index.js', config).then((stats) => {
const src = loader(stats).src
const src = loader(stats).src

expect(src).toEqual("module.exports = \"a { color: rgba(255, 0, 0, 1.0) }\\n\"")
expect(src).toMatchSnapshot()
})
expect(src).toEqual('module.exports = "a { color: rgba(255, 0, 0, 1.0) }\\n"')
expect(src).toMatchSnapshot()
})
})

test('Pass loader object to config context', () => {
Expand All @@ -88,11 +87,11 @@ describe('Options', () => {
}

return webpack('css/index.js', config).then((stats) => {
const assets = stats.compilation.assets;
const expectedAssetName = 'asset.txt';
const assets = stats.compilation.assets
const expectedAssetName = 'asset.txt'

expect(expectedAssetName in assets).toBeTruthy();
expect(assets[expectedAssetName].source()).toBe('123');
expect(expectedAssetName in assets).toBeTruthy()
expect(assets[expectedAssetName].source()).toBe('123')
})
})
})
14 changes: 7 additions & 7 deletions test/options/exec.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ describe('Options', () => {
}

return webpack('jss/exec/index.js', config).then((stats) => {
const src = loader(stats).src
const src = loader(stats).src

expect(src).toEqual("module.exports = \"a {\\n color: green\\n}\"")
expect(src).toMatchSnapshot()
})
expect(src).toEqual('module.exports = "a {\\n color: green\\n}"')
expect(src).toMatchSnapshot()
})
})

test('JSS - {String}', () => {
Expand All @@ -32,9 +32,9 @@ describe('Options', () => {
}

return webpack('jss/index.js', config).then((stats) => {
const src = loader(stats).src
const src = loader(stats).src

expect(src).toMatchSnapshot()
})
expect(src).toMatchSnapshot()
})
})
})
16 changes: 8 additions & 8 deletions test/options/parser.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ describe('Options', () => {
}

return webpack('sss/index.js', config).then((stats) => {
const src = loader(stats).src
const src = loader(stats).src

expect(src).toEqual("module.exports = \"a {\\n color: black\\n}\\n\"")
expect(src).toMatchSnapshot()
})
expect(src).toEqual('module.exports = "a {\\n color: black\\n}\\n"')
expect(src).toMatchSnapshot()
})
})

test('Parser - {Object}', () => {
Expand All @@ -32,10 +32,10 @@ describe('Options', () => {
}

return webpack('sss/index.js', config).then((stats) => {
const src = loader(stats).src
const src = loader(stats).src

expect(src).toEqual("module.exports = \"a {\\n color: black\\n}\\n\"")
expect(src).toMatchSnapshot()
})
expect(src).toEqual('module.exports = "a {\\n color: black\\n}\\n"')
expect(src).toMatchSnapshot()
})
})
})
32 changes: 16 additions & 16 deletions test/options/plugins.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ describe('Options', () => {
}

return webpack('css/index.js', config).then((stats) => {
const src = loader(stats).src
const src = loader(stats).src

expect(src).toEqual("module.exports = \"a { color: rgba(255, 0, 0, 1.0) }\\n\"")
expect(src).toMatchSnapshot()
})
expect(src).toEqual('module.exports = "a { color: rgba(255, 0, 0, 1.0) }\\n"')
expect(src).toMatchSnapshot()
})
})

test('Plugins - {Object}', () => {
Expand All @@ -33,11 +33,11 @@ describe('Options', () => {
}

return webpack('css/index.js', config).then((stats) => {
const src = loader(stats).src
const src = loader(stats).src

expect(src).toEqual("module.exports = \"a { color: rgba(255, 0, 0, 1.0) }\\n\"")
expect(src).toMatchSnapshot()
})
expect(src).toEqual('module.exports = "a { color: rgba(255, 0, 0, 1.0) }\\n"')
expect(src).toMatchSnapshot()
})
})

test('Plugins - {Function} - {Array}', () => {
Expand All @@ -51,11 +51,11 @@ describe('Options', () => {
}

return webpack('css/index.js', config).then((stats) => {
const src = loader(stats).src
const src = loader(stats).src

expect(src).toEqual("module.exports = \"a { color: rgba(255, 0, 0, 1.0) }\\n\"")
expect(src).toMatchSnapshot()
})
expect(src).toEqual('module.exports = "a { color: rgba(255, 0, 0, 1.0) }\\n"')
expect(src).toMatchSnapshot()
})
})

test('Plugins - {Function} - {Object}', () => {
Expand All @@ -69,10 +69,10 @@ describe('Options', () => {
}

return webpack('css/index.js', config).then((stats) => {
const src = loader(stats).src
const src = loader(stats).src

expect(src).toEqual("module.exports = \"a { color: rgba(255, 0, 0, 1.0) }\\n\"")
expect(src).toMatchSnapshot()
})
expect(src).toEqual('module.exports = "a { color: rgba(255, 0, 0, 1.0) }\\n"')
expect(src).toMatchSnapshot()
})
})
})
24 changes: 12 additions & 12 deletions test/options/sourceMap.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@ describe('Options', () => {
}

return webpack('css/index.js', config).then((stats) => {
const src = loader(stats).src
const src = loader(stats).src

expect(src).toEqual("module.exports = \"a { color: rgba(255, 0, 0, 1.0) }\\n\"")
expect(src).toMatchSnapshot()
expect(src).toEqual('module.exports = "a { color: rgba(255, 0, 0, 1.0) }\\n"')
expect(src).toMatchSnapshot()

const map = loader(stats).map
const map = loader(stats).map

map.file = path.relative(__dirname, map.file)
map.sources = map.sources.map((src) => path.relative(__dirname, src))
map.file = path.relative(__dirname, map.file)
map.sources = map.sources.map((src) => path.relative(__dirname, src))

expect(map).toMatchSnapshot()
})
expect(map).toMatchSnapshot()
})
})

test('Sourcemap - {String}', () => {
Expand All @@ -39,10 +39,10 @@ describe('Options', () => {
}

return webpack('css/index.js', config).then((stats) => {
const src = loader(stats).src
const src = loader(stats).src

expect(src).toEqual("module.exports = \"a { color: rgba(255, 0, 0, 1.0) }\\n\\n/*# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInRlc3QvZml4dHVyZXMvY3NzL3N0eWxlLmNzcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxJQUFJLDJCQUFZLEVBQUUiLCJmaWxlIjoidGVzdC9maXh0dXJlcy9jc3Mvc3R5bGUuY3NzIiwic291cmNlc0NvbnRlbnQiOlsiYSB7IGNvbG9yOiBibGFjayB9XG4iXX0= */\"")
expect(src).toMatchSnapshot()
})
expect(src).toEqual('module.exports = "a { color: rgba(255, 0, 0, 1.0) }\\n\\n/*# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInRlc3QvZml4dHVyZXMvY3NzL3N0eWxlLmNzcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxJQUFJLDJCQUFZLEVBQUUiLCJmaWxlIjoidGVzdC9maXh0dXJlcy9jc3Mvc3R5bGUuY3NzIiwic291cmNlc0NvbnRlbnQiOlsiYSB7IGNvbG9yOiBibGFjayB9XG4iXX0= */"')
expect(src).toMatchSnapshot()
})
})
})
16 changes: 8 additions & 8 deletions test/options/stringifier.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ describe('Options', () => {
}

return webpack('css/index.js', config).then((stats) => {
const src = loader(stats).src
const src = loader(stats).src

expect(src).toEqual("module.exports = \"a color: black\\n\"")
expect(src).toMatchSnapshot()
})
expect(src).toEqual('module.exports = "a color: black\\n"')
expect(src).toMatchSnapshot()
})
})

test('Stringifier - {Object}', () => {
Expand All @@ -32,10 +32,10 @@ describe('Options', () => {
}

return webpack('css/index.js', config).then((stats) => {
const src = loader(stats).src
const src = loader(stats).src

expect(src).toEqual("module.exports = \"a color: black\\n\"")
expect(src).toMatchSnapshot()
})
expect(src).toEqual('module.exports = "a color: black\\n"')
expect(src).toMatchSnapshot()
})
})
})
16 changes: 8 additions & 8 deletions test/options/syntax.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ describe('Options', () => {
}

return webpack('sss/index.js', config).then((stats) => {
const src = loader(stats).src
const src = loader(stats).src

expect(src).toEqual("module.exports = \"a\\n color: black\\n\"")
expect(src).toMatchSnapshot()
})
expect(src).toEqual('module.exports = "a\\n color: black\\n"')
expect(src).toMatchSnapshot()
})
})

test('Syntax - {Object}', () => {
Expand All @@ -32,10 +32,10 @@ describe('Options', () => {
}

return webpack('sss/index.js', config).then((stats) => {
const src = loader(stats).src
const src = loader(stats).src

expect(src).toEqual("module.exports = \"a\\n color: black\\n\"")
expect(src).toMatchSnapshot()
})
expect(src).toEqual('module.exports = "a\\n color: black\\n"')
expect(src).toMatchSnapshot()
})
})
})

0 comments on commit 8772814

Please sign in to comment.