Skip to content

Commit

Permalink
lint: resolve keyword-spacing issues (#1328)
Browse files Browse the repository at this point in the history
  • Loading branch information
alxndrsn authored Dec 5, 2024
1 parent 924e9ee commit a91f444
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 62 deletions.
3 changes: 1 addition & 2 deletions test/integration/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,7 @@ after(async () => {

let mustReinitAfter;
beforeEach(() => {
// eslint-disable-next-line keyword-spacing
if(mustReinitAfter) throw new Error(`Failed to reinitalize after previous test: '${mustReinitAfter}'. You may need to increase your mocha timeout.`);
if (mustReinitAfter) throw new Error(`Failed to reinitalize after previous test: '${mustReinitAfter}'. You may need to increase your mocha timeout.`);
s3.resetMock();
});
afterEach(async function() {
Expand Down
12 changes: 4 additions & 8 deletions test/unit/data/attachments.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ describe('.zip attachments streaming', () => {
{ row: { instanceId: 'subtwo', name: 'thirdfile.ext', content: 'this is my third file' } }
]));
zipStreamToFiles(zipStreamFromParts(streamAttachments(inStream)), (err, result) => {
// eslint-disable-next-line keyword-spacing
if(err) return done(err);
if (err) return done(err);

result.filenames.should.eql([
'media/firstfile.ext',
Expand All @@ -37,8 +36,7 @@ describe('.zip attachments streaming', () => {
{ row: { instanceId: 'subone', name: './.secondfile.ext', content: 'this is my duplicate second file' } },
]));
zipStreamToFiles(zipStreamFromParts(streamAttachments(inStream)), (err, result) => {
// eslint-disable-next-line keyword-spacing
if(err) return done(err);
if (err) return done(err);

result.filenames.should.eql([
'media/firstfile.ext',
Expand All @@ -55,8 +53,7 @@ describe('.zip attachments streaming', () => {
{ row: { instanceId: 'subone', name: 'firstfile.ext.enc', content: 'this is my first file' } }
]));
zipStreamToFiles(zipStreamFromParts(streamAttachments(inStream)), (err, result) => {
// eslint-disable-next-line keyword-spacing
if(err) return done(err);
if (err) return done(err);

result.filenames.should.eql([ 'media/firstfile.ext.enc' ]);
done();
Expand All @@ -68,8 +65,7 @@ describe('.zip attachments streaming', () => {
{ row: { instanceId: 'subone', name: 'firstfile.ext.enc', content: 'this is my first file' } }
]));
zipStreamToFiles(zipStreamFromParts(streamAttachments(inStream, () => {})), (err, result) => {
// eslint-disable-next-line keyword-spacing
if(err) return done(err);
if (err) return done(err);

result.filenames.should.eql([ 'media/firstfile.ext' ]);
done();
Expand Down
60 changes: 20 additions & 40 deletions test/unit/data/briefcase.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ describe('.csv.zip briefcase output @slow', () => {
]);

callAndParse(inStream, formXml, 'mytestform', (err, result) => {
// eslint-disable-next-line keyword-spacing
if(err) return done(err);
if (err) return done(err);

result.filenames.should.eql([ 'mytestform.csv' ]);
result['mytestform.csv'].should.equal(
Expand Down Expand Up @@ -113,8 +112,7 @@ describe('.csv.zip briefcase output @slow', () => {
]);

callAndParse(inStream, formXml, 'mytestform', (err, result) => {
// eslint-disable-next-line keyword-spacing
if(err) return done(err);
if (err) return done(err);

result.filenames.should.eql([ 'mytestform.csv' ]);
result['mytestform.csv'].should.equal(
Expand Down Expand Up @@ -154,8 +152,7 @@ describe('.csv.zip briefcase output @slow', () => {
]);

callAndParse(inStream, formXml, 'mytestform', (err, result) => {
// eslint-disable-next-line keyword-spacing
if(err) return done(err);
if (err) return done(err);

result.filenames.should.eql([ 'mytestform.csv' ]);
result['mytestform.csv'].should.equal(
Expand Down Expand Up @@ -194,8 +191,7 @@ describe('.csv.zip briefcase output @slow', () => {
]);

callAndParse(inStream, formXml, 'mytestform', (err, result) => {
// eslint-disable-next-line keyword-spacing
if(err) return done(err);
if (err) return done(err);

result.filenames.should.eql([ 'mytestform.csv' ]);
result['mytestform.csv'].should.equal(
Expand Down Expand Up @@ -232,8 +228,7 @@ describe('.csv.zip briefcase output @slow', () => {
]);

callAndParse(inStream, formXml, 'mytestform', (err, result) => {
// eslint-disable-next-line keyword-spacing
if(err) return done(err);
if (err) return done(err);

result.filenames.should.eql([ 'mytestform.csv' ]);
result['mytestform.csv'].should.equal(
Expand Down Expand Up @@ -269,8 +264,7 @@ describe('.csv.zip briefcase output @slow', () => {
const inStream = streamTest.fromObjects([ data ]);

callAndParse(inStream, formXml, 'mytestform', (err, result) => {
// eslint-disable-next-line keyword-spacing
if(err) return done(err);
if (err) return done(err);

result.filenames.should.eql([ 'mytestform.csv' ]);
result['mytestform.csv'].should.equal(
Expand Down Expand Up @@ -308,8 +302,7 @@ describe('.csv.zip briefcase output @slow', () => {
const inStream = streamTest.fromObjects([ one, two ]);

callAndParse(inStream, formXml, 'mytestform', (err, result) => {
// eslint-disable-next-line keyword-spacing
if(err) return done(err);
if (err) return done(err);

result.filenames.should.eql([ 'mytestform.csv' ]);
result['mytestform.csv'].should.equal(
Expand Down Expand Up @@ -346,8 +339,7 @@ describe('.csv.zip briefcase output @slow', () => {
]);

callAndParse(inStream, formXml, 'mytestform', (err, result) => {
// eslint-disable-next-line keyword-spacing
if(err) return done(err);
if (err) return done(err);

result.filenames.should.eql([ 'mytestform.csv' ]);
result['mytestform.csv'].should.equal(
Expand Down Expand Up @@ -385,8 +377,7 @@ describe('.csv.zip briefcase output @slow', () => {
]);

callAndParse(inStream, formXml, 'mytestform', (err, result) => {
// eslint-disable-next-line keyword-spacing
if(err) return done(err);
if (err) return done(err);

result.filenames.should.eql([ 'mytestform.csv' ]);
result['mytestform.csv'].should.equal(
Expand All @@ -407,8 +398,7 @@ describe('.csv.zip briefcase output @slow', () => {

fieldsFor(testData.forms.selectMultiple).then((fields) => {
zipStreamToFiles(zipStreamFromParts(streamBriefcaseCsvs(inStream, fields, 'selectMultiple', { '/q1': [ 'x', 'y', 'z' ], '/g1/q2': [ 'm', 'n' ] })), (err, result) => {
// eslint-disable-next-line keyword-spacing
if(err) return done(err);
if (err) return done(err);

result.filenames.should.eql([ 'selectMultiple.csv' ]);
result['selectMultiple.csv'].should.equal(
Expand Down Expand Up @@ -458,8 +448,7 @@ describe('.csv.zip briefcase output @slow', () => {
]);

callAndParse(inStream, formXml, 'structuredform', (err, result) => {
// eslint-disable-next-line keyword-spacing
if(err) return done(err);
if (err) return done(err);

result.filenames.should.eql([ 'structuredform.csv' ]);
result['structuredform.csv'].should.equal(
Expand Down Expand Up @@ -510,8 +499,7 @@ describe('.csv.zip briefcase output @slow', () => {

fieldsFor(formXml).then((fields) => {
zipStreamToFiles(zipStreamFromParts(streamBriefcaseCsvs(inStream, fields, 'structuredform', undefined, undefined, false, { groupPaths: false })), (err, result) => {
// eslint-disable-next-line keyword-spacing
if(err) return done(err);
if (err) return done(err);

result.filenames.should.eql([ 'structuredform.csv' ]);
result['structuredform.csv'].should.equal(
Expand All @@ -533,8 +521,7 @@ describe('.csv.zip briefcase output @slow', () => {

fieldsFor(testData.forms.selectMultiple).then((fields) => {
zipStreamToFiles(zipStreamFromParts(streamBriefcaseCsvs(inStream, fields, 'selectMultiple', { '/q1': [ 'x', 'y', 'z' ], '/g1/q2': [ 'm', 'n' ] }, undefined, false, { groupPaths: false })), (err, result) => {
// eslint-disable-next-line keyword-spacing
if(err) return done(err);
if (err) return done(err);

result.filenames.should.eql([ 'selectMultiple.csv' ]);
result['selectMultiple.csv'].should.equal(
Expand Down Expand Up @@ -603,8 +590,7 @@ describe('.csv.zip briefcase output @slow', () => {
]);

callAndParse(inStream, formXml, 'singlerepeat', (err, result) => {
// eslint-disable-next-line keyword-spacing
if(err) return done(err);
if (err) return done(err);

result.filenames.should.containDeep([ 'singlerepeat.csv', 'singlerepeat-child.csv' ]);
result['singlerepeat.csv'].should.equal(
Expand Down Expand Up @@ -668,8 +654,7 @@ Candace,2,three,three/children/child[1]
(new Array(127)).fill(null).map(() => instance(uuid(), `<orx:meta><orx:instanceID>${uuid()}</orx:instanceID></orx:meta><name>${uuid()}</name><children><child><name>${uuid()}</name></child></children>`))); // eslint-disable-line function-paren-newline

callAndParse(inStream, formXml, 'singlerepeat', (err, result) => {
// eslint-disable-next-line keyword-spacing
if(err) return done(err);
if (err) return done(err);

result.filenames.should.containDeep([ 'singlerepeat.csv', 'singlerepeat-child.csv' ]);
result['singlerepeat.csv'].split('\n').length.should.equal(129);
Expand Down Expand Up @@ -746,8 +731,7 @@ Candace,2,three,three/children/child[1]
]);

callAndParse(inStream, formXml, 'multirepeat', (err, result) => {
// eslint-disable-next-line keyword-spacing
if(err) return done(err);
if (err) return done(err);

result.filenames.should.containDeep([ 'multirepeat.csv', 'multirepeat-child.csv', 'multirepeat-toy.csv' ]);
result['multirepeat.csv'].should.equal(
Expand Down Expand Up @@ -809,8 +793,7 @@ Pod racer,three/children/child[1],three/children/child[1]/toy[3]
]);

callAndParse(inStream, formXml, 'pathprefix', (err, result) => {
// eslint-disable-next-line keyword-spacing
if(err) return done(err);
if (err) return done(err);

result.filenames.should.containDeep([ 'pathprefix.csv', 'pathprefix-children.csv' ]);
result['pathprefix.csv'].should.equal(
Expand Down Expand Up @@ -901,8 +884,7 @@ Chelsea,one,one/children[2]
}]);

callAndParse(inStream, formXml, 'all-data-types', (err, result) => {
// eslint-disable-next-line keyword-spacing
if(err) return done(err);
if (err) return done(err);

result.filenames.should.containDeep([ 'all-data-types.csv' ]);
result['all-data-types.csv'].should.equal(
Expand Down Expand Up @@ -1031,8 +1013,7 @@ Chelsea,one,one/children[2]
}]);

callAndParse(inStream, formXml, 'nested-repeats', (err, result) => {
// eslint-disable-next-line keyword-spacing
if(err) return done(err);
if (err) return done(err);

result.filenames.should.containDeep([ 'nested-repeats.csv', 'nested-repeats-g1.csv', 'nested-repeats-g2.csv', 'nested-repeats-g3.csv' ]);
result['nested-repeats.csv'].should.equal(
Expand Down Expand Up @@ -1120,8 +1101,7 @@ some text 3.1.4,uuid:0a1b861f-a5fd-4f49-846a-78dcf06cfc1b/g1[3]/g2[1],uuid:0a1b8
]);

callAndParse(inStream, formXml, 'ambiguous', (err, result) => {
// eslint-disable-next-line keyword-spacing
if(err) return done(err);
if (err) return done(err);

result.filenames.should.containDeep([ 'ambiguous.csv', 'ambiguous-entry~1.csv', 'ambiguous-entry~2.csv' ]);
result['ambiguous.csv'].should.equal(
Expand Down
9 changes: 3 additions & 6 deletions test/unit/util/zip.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ describe('zipPart streamer', () => {

let closed = false;
zipStreamToFiles(zipStreamFromParts(part), (err) => {
// eslint-disable-next-line keyword-spacing
if(err) return done(err);
if (err) return done(err);

closed = true;
done();
Expand Down Expand Up @@ -96,8 +95,7 @@ describe('zipPart streamer', () => {
const part2 = zipPart();

zipStreamToFiles(zipStreamFromParts(part1, part2), (err, result) => {
// eslint-disable-next-line keyword-spacing
if(err) return done(err);
if (err) return done(err);

result.filenames.should.containDeep([
'x/test1.file',
Expand Down Expand Up @@ -128,8 +126,7 @@ describe('zipPart streamer', () => {
const part2 = zipPart();

zipStreamToFiles(zipStreamFromParts(part1, part2), (err, result) => {
// eslint-disable-next-line keyword-spacing
if(err) return done(err);
if (err) return done(err);

result.filenames.should.containDeep([ 'test1.file', 'test2.file' ]);
result['test1.file'].should.equal('test static');
Expand Down
9 changes: 3 additions & 6 deletions test/util/zip.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,11 @@ const processZipFile = (zipfile, callback) => {
result.filenames.push(entry.fileName);
// eslint-disable-next-line no-shadow
zipfile.openReadStream(entry, (err, resultStream) => {
// eslint-disable-next-line keyword-spacing
if(err) return callback(err);
if (err) return callback(err);

// eslint-disable-next-line no-shadow
resultStream.pipe(streamTest.toText((err, contents) => {
// eslint-disable-next-line keyword-spacing
if(err) return callback(err);
if (err) return callback(err);

result[entry.fileName] = contents;
completed += 1;
Expand All @@ -51,8 +49,7 @@ const processZipFile = (zipfile, callback) => {

const zipStreamToFiles = (zipStream, callback) => {
tmp.file((err, tmpfile) => {
// eslint-disable-next-line keyword-spacing
if(err) return callback(err);
if (err) return callback(err);

const writeStream = createWriteStream(tmpfile);
zipStream.pipe(writeStream);
Expand Down

0 comments on commit a91f444

Please sign in to comment.