Skip to content

Commit

Permalink
eslint: relax function declaration rules in test/ (#1170)
Browse files Browse the repository at this point in the history
Disable eslint rules:

* func-names
* space-before-function-paren

These rules are violated in numerous places, and it doesn't seem to bother anyone :¬)
  • Loading branch information
alxndrsn authored Oct 2, 2024
1 parent 99174aa commit 66ecf31
Show file tree
Hide file tree
Showing 8 changed files with 5 additions and 28 deletions.
4 changes: 3 additions & 1 deletion test/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ module.exports = {
mocha: true,
},
rules: {
'import/no-dynamic-require': 'off'
'func-names': 'off',
'import/no-dynamic-require': 'off',
'space-before-function-paren': 'off',
}
};
2 changes: 0 additions & 2 deletions test/assertions.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
const should = require('should');
const { DateTime } = require('luxon');

/* eslint-disable space-before-function-paren, func-names */

// debugging things.
// eslint-disable-next-line no-console
global.tap = (x) => { console.log(x); return x; };
Expand Down
1 change: 0 additions & 1 deletion test/integration/other/analytics-queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ const submitToForm = (service, user, projectId, xmlFormId, xml, deviceId = 'abcd
////////////////////////////////////////////////////////////////////////////////
// Tests!
////////////////////////////////////////////////////////////////////////////////
// eslint-disable-next-line func-names
describe('analytics task queries', function () {
// increasing timeouts on this set of tests
this.timeout(8000);
Expand Down
8 changes: 0 additions & 8 deletions test/integration/other/migrations.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ const testMigration = (filename, tests, options = {}) => {
// eslint-disable-next-line no-only-tests/no-only-tests
? describe.only.bind(describe)
: (skip ? describe.skip.bind(describe) : describe);
// eslint-disable-next-line func-names, space-before-function-paren
f(`database migrations: ${filename}`, function() {
this.timeout(20000);

Expand All @@ -60,7 +59,6 @@ testMigration.skip = (filename, tests) =>
// column to projects and forms, it is not possible to migrate part way
// (before the new column) and populate the data when frames expect the
// new column to exist.
// eslint-disable-next-line space-before-function-paren, func-names
describe.skip('database migrations', function() {
this.timeout(8000);

Expand Down Expand Up @@ -220,7 +218,6 @@ describe.skip('database migrations', function() {

});

// eslint-disable-next-line space-before-function-paren, func-names
describe('database migrations: removing default project', function() {
this.timeout(8000);

Expand Down Expand Up @@ -258,7 +255,6 @@ describe('database migrations: removing default project', function() {
}));
});

// eslint-disable-next-line space-before-function-paren, func-names
describe('database migrations: intermediate form schema', function() {
this.timeout(20000);

Expand Down Expand Up @@ -388,7 +384,6 @@ describe('database migrations: intermediate form schema', function() {
}));
});

// eslint-disable-next-line func-names, space-before-function-paren
describe('database migrations: 20230123-01-remove-google-backups', function() {
this.timeout(20000);

Expand Down Expand Up @@ -483,7 +478,6 @@ describe('database migrations: 20230123-01-remove-google-backups', function() {
}));
});

// eslint-disable-next-line func-names
describe.skip('database migrations: 20230324-01-edit-dataset-verbs.js', function () {
this.timeout(20000);

Expand Down Expand Up @@ -520,7 +514,6 @@ describe.skip('database migrations: 20230324-01-edit-dataset-verbs.js', function
}));
});

// eslint-disable-next-line func-names
describe.skip('database migrations from 20230406: altering entities and entity_defs', function () {
this.timeout(20000);

Expand Down Expand Up @@ -615,7 +608,6 @@ describe.skip('database migrations from 20230406: altering entities and entity_d
}));
});

// eslint-disable-next-line func-names
describe('database migrations from 20230512: adding entity_def_sources table', function () {
this.timeout(20000);

Expand Down
4 changes: 0 additions & 4 deletions test/integration/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ const initialize = async () => {
return withDefaults({ db, context, enketo, env, s3 }).transacting(populate);
};

// eslint-disable-next-line func-names, space-before-function-paren
before(function() {
this.timeout(0);
return initialize();
Expand All @@ -99,7 +98,6 @@ beforeEach(() => {
if(mustReinitAfter) throw new Error(`Failed to reinitalize after previous test: '${mustReinitAfter}'. You may need to increase your mocha timeout.`);
s3.resetMock();
});
// eslint-disable-next-line func-names, space-before-function-paren
afterEach(async function() {
this.timeout(0);
if (mustReinitAfter) {
Expand Down Expand Up @@ -156,7 +154,6 @@ const testService = (test) => () => new Promise((resolve, reject) => {
// for some tests we explicitly need to make concurrent requests, in which case
// the transaction butchering we do for testService will not work. for these cases,
// we offer testServiceFullTrx:
// eslint-disable-next-line space-before-function-paren, func-names
const testServiceFullTrx = (test) => function() {
mustReinitAfter = this.test.fullTitle();
return test(augment(request(service(baseContainer))), baseContainer);
Expand All @@ -172,7 +169,6 @@ const testContainer = (test) => () => new Promise((resolve, reject) => {
});

// complete the square of options:
// eslint-disable-next-line space-before-function-paren, func-names
const testContainerFullTrx = (test) => function() {
mustReinitAfter = this.test.fullTitle();
return test(baseContainer);
Expand Down
2 changes: 0 additions & 2 deletions test/unit/external/enketo.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ describe('external/enketo', () => {
it('should send a properly constructed request to Enketo', () => {
enketoNock
.post('/enketoPath/api/v2/survey/all')
// eslint-disable-next-line space-before-function-paren, func-names
.reply(201, function(uri, requestBody) {
const base64Auth = Buffer.from('enketoApiKey:').toString('base64');
const expectedQueryString = querystring.stringify({ server_url: openRosaUrl, form_id: xmlFormId });
Expand Down Expand Up @@ -87,7 +86,6 @@ describe('external/enketo', () => {
let run = false;
enketoNock
.post('/enketoPath/api/v2/instance')
// eslint-disable-next-line space-before-function-paren, func-names
.reply(201, function(uri, requestBody) {
run = true;
const base64Auth = Buffer.from('enketoApiKey:').toString('base64');
Expand Down
10 changes: 1 addition & 9 deletions test/unit/http/endpoint.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,11 @@ const Problem = require(appRoot + '/lib/util/problem');
const createModernResponse = () => {
const result = createResponse({ eventEmitter: EventEmitter });
// node-mocks-http does not have hasHeader yet.
// eslint-disable-next-line space-before-function-paren, func-names
result.hasHeader = function(name) {
return this.getHeader(name) != null;
};

// express adds this.
// eslint-disable-next-line space-before-function-paren, func-names
result.status = function(code) {
this.statusCode = code;
return this;
Expand Down Expand Up @@ -465,7 +463,6 @@ describe('endpoints', () => {
result.should.equal('ateststream');
done();
});
// eslint-disable-next-line space-before-function-paren, func-names
responseTest.hasHeader = function() { return true; };
defaultResultWriter(streamTest.fromChunks([ 'a', 'test', 'stream' ]), requestTest, responseTest);
});
Expand All @@ -477,7 +474,6 @@ describe('endpoints', () => {
result.should.equal('a!test!stream!');
done();
});
// eslint-disable-next-line space-before-function-paren, func-names
responseTest.hasHeader = function() { return true; };

const resourceResult = PartialPipe.of(
Expand All @@ -501,9 +497,7 @@ describe('endpoints', () => {
(result === undefined).should.equal(true); // post node v14.??
done();
});
// eslint-disable-next-line space-before-function-paren, func-names
responseTest.addTrailers = function(t) { trailers = t; };
// eslint-disable-next-line space-before-function-paren, func-names
responseTest.hasHeader = function() { return true; };

const resourceResult = PartialPipe.of(
Expand All @@ -522,9 +516,8 @@ describe('endpoints', () => {
it('should call next on PartialPipe stream error', (done) => {
const requestTest = streamTest.fromChunks();
const responseTest = streamTest.toText(() => {});
// eslint-disable-next-line no-undef, space-before-function-paren, func-names
// eslint-disable-next-line no-undef
responseTest.addTrailers = function(t) { trailers = t; };
// eslint-disable-next-line space-before-function-paren, func-names
responseTest.hasHeader = function() { return true; };

const resourceResult = PartialPipe.of(
Expand All @@ -545,7 +538,6 @@ describe('endpoints', () => {
it('should not crash if the request is aborted but the stream is not endable', () => {
const requestTest = new EventEmitter();
const responseTest = streamTest.toText(() => {});
// eslint-disable-next-line space-before-function-paren, func-names
responseTest.hasHeader = function() { return true; };
const source = streamTest.fromChunks([ 'a', 'test', 'stream' ], 20);
defaultResultWriter(source, requestTest, responseTest);
Expand Down
2 changes: 1 addition & 1 deletion test/unit/util/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ describe('util/http', () => {

describe('format response helpers', () => {
const { contentType, xml, atom, json } = http;
// eslint-disable-next-line semi, space-before-function-paren, object-shorthand, func-names
// eslint-disable-next-line semi, object-shorthand
const mockResponse = () => ({ type: function(value) { this.contentType = value } });
it('should ultimately return the result', () => {
contentType()(42)(null, mockResponse()).should.equal(42);
Expand Down

0 comments on commit 66ecf31

Please sign in to comment.