Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lint test configs on commit #2402

Merged
merged 3 commits into from
Aug 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,11 @@
"tslint --project test/typescript --fix",
"prettier --write",
"git add"
],
"{test/test,test/*/index,test/utils,test/**/_config}.js": [
"eslint --fix",
"prettier --write",
"git add"
]
}
}
63 changes: 30 additions & 33 deletions test/hooks/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,20 +274,19 @@ describe('hooks', () => {
`var input = new URL('../assets/test-19916f7d.ext', import.meta.url).href;\n\nexport default input;\n`
);

return rollup
.rollup({
cache,
input: 'input',
experimentalCodeSplitting: true,
plugins: [
loader({ input: '' }),
{
transform () {
assert.fail('Should cache transform');
}
return rollup.rollup({
cache,
input: 'input',
experimentalCodeSplitting: true,
plugins: [
loader({ input: '' }),
{
transform() {
assert.fail('Should cache transform');
}
]
});
}
]
});
})
.then(bundle => {
return bundle.generate({ format: 'es' });
Expand Down Expand Up @@ -332,22 +331,21 @@ describe('hooks', () => {
`var input = new URL('../assets/test-19916f7d.ext', import.meta.url).href;\n\nexport default input;\n`
);

return rollup
.rollup({
cache,
input: 'input',
experimentalCodeSplitting: true,
plugins: [
loader({ input: '' }),
{
name: 'x',
transform () {
runs++;
return `alert('hello world')`;
}
return rollup.rollup({
cache,
input: 'input',
experimentalCodeSplitting: true,
plugins: [
loader({ input: '' }),
{
name: 'x',
transform() {
runs++;
return `alert('hello world')`;
}
]
});
}
]
});
})
.then(bundle => {
return bundle.generate({ format: 'es' });
Expand Down Expand Up @@ -823,7 +821,7 @@ module.exports = input;
loader({ input: `alert('hello')` }),
{
name: 'x',
buildStart () {
buildStart() {
this.cache.set('first', 'first');
this.cache.set('second', 'second');
}
Expand All @@ -842,9 +840,8 @@ module.exports = input;
loader({ input: `alert('hello')` }),
{
name: 'x',
buildStart () {
if (i === 4)
assert.equal(this.cache.has('second'), true);
buildStart() {
if (i === 4) assert.equal(this.cache.has('second'), true);
}
}
]
Expand All @@ -862,7 +859,7 @@ module.exports = input;
loader({ input: `alert('hello')` }),
{
name: 'x',
buildStart () {
buildStart() {
assert.equal(this.cache.has('first'), false);
assert.equal(this.cache.get('first'), undefined);
assert.equal(this.cache.get('second'), 'second');
Expand Down
31 changes: 17 additions & 14 deletions test/watch/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const assert = require('assert');
const path = require('path');
const sander = require('sander');
const rollup = require('../../dist/rollup');
const path = require('path');

const cwd = process.cwd();

Expand Down Expand Up @@ -38,8 +38,7 @@ describe('rollup.watch', () => {
console.error(event.error);
}
watcher.close();
if (event.code === 'ERROR')
console.log(event.error);
if (event.code === 'ERROR') console.log(event.error);
reject(new Error(`Expected ${next} event, got ${event.code}`));
} else {
go(event);
Expand Down Expand Up @@ -107,7 +106,8 @@ describe('rollup.watch', () => {
});

it('passes file events to the watchChange plugin hook', () => {
let watchChangeId, watchChangeCnt = 0;
let watchChangeId;
let watchChangeCnt = 0;
return sander
.copydir('test/watch/samples/basic')
.to('test/_tmp/input')
Expand All @@ -118,12 +118,14 @@ describe('rollup.watch', () => {
file: 'test/_tmp/output/bundle.js',
format: 'cjs'
},
plugins: [{
watchChange (id) {
watchChangeId = id;
watchChangeCnt++;
plugins: [
{
watchChange(id) {
watchChangeId = id;
watchChangeCnt++;
}
}
}],
],
watch: { chokidar }
});

Expand All @@ -143,10 +145,8 @@ describe('rollup.watch', () => {
() => {
assert.equal(run('../_tmp/output/bundle.js'), 43);
assert.equal(watchChangeId, path.resolve('test/_tmp/input/main.js'));
if (chokidar)
assert.equal(watchChangeCnt, 1);
else
assert.ok(watchChangeCnt >= 1);
if (chokidar) assert.equal(watchChangeCnt, 1);
else assert.ok(watchChangeCnt >= 1);
}
]);
});
Expand Down Expand Up @@ -650,7 +650,10 @@ describe('rollup.watch', () => {
if (err.code !== 'ENOENT') throw err;
this.emitAsset('test', 'test');
}
return { code: `export default ${v++}`, dependencies: v === 2 ? [path.resolve(file)] : [] };
return {
code: `export default ${v++}`,
dependencies: v === 2 ? [path.resolve(file)] : []
};
}
}
],
Expand Down