Skip to content

Commit

Permalink
Merge pull request dherault#687 from dnalborczyk/eslint
Browse files Browse the repository at this point in the history
Eslint adjustments
  • Loading branch information
dherault authored Jun 4, 2019
2 parents 8811c2e + e03baa4 commit 2705280
Show file tree
Hide file tree
Showing 12 changed files with 23 additions and 19 deletions.
4 changes: 4 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
manual_test_nodejs
manual_test_python
manual_test_ruby
manual_test_websocket
18 changes: 9 additions & 9 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
const { env, platform } = process;

const rules = {
semi: ["error", "always"],
"prefer-destructuring": "off",
"key-spacing": "off",
"guard-for-in": "off",
"no-restricted-syntax": "off",
"import/no-dynamic-require": "off",
'guard-for-in': 'off',
'import/no-dynamic-require': 'off',
'key-spacing': 'off',
'no-restricted-syntax': 'off',
'prefer-destructuring': 'off',
semi: ['error', 'always'],
};

// workaround for git + eslint line ending issue on Travis for Windows OS:
// https://travis-ci.community/t/files-in-checkout-have-eol-changed-from-lf-to-crlf/349/2
if (env.TRAVIS && platform === "win32") {
rules["linebreak-style"] = "off";
if (env.TRAVIS && platform === 'win32') {
rules['linebreak-style'] = 'off';
}

module.exports = {
extends: "dherault",
extends: 'dherault',
rules,
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"main": "src/index.js",
"scripts": {
"test": "mocha test",
"lint": "eslint src/**/*.js test/**/*.js"
"lint": "eslint ."
},
"repository": {
"type": "git",
Expand Down
3 changes: 3 additions & 0 deletions test/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@ const rules = {
};

module.exports = {
'env': {
'mocha': true
},
rules,
};
3 changes: 2 additions & 1 deletion test/unit/authCanExecuteResourceTest.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* global describe context it */
const { expect } = require('chai');
const authCanExecuteResource = require('../../src/authCanExecuteResource');

Expand Down Expand Up @@ -137,6 +136,7 @@ describe('authCanExecuteResource', () => {
const canExecute = authCanExecuteResource(policy, resourceTwo);
expect(canExecute).to.eq(false);
});

context('and the Resource is an array', () => {
it('returns false', () => {
const policy = setup(
Expand All @@ -154,6 +154,7 @@ describe('authCanExecuteResource', () => {
expect(canExecute).to.eq(false);
});
});

context('and there is also an Allow statement', () => {
it('returns false', () => {
const policy = setup(
Expand Down
2 changes: 1 addition & 1 deletion test/unit/authFunctionNameExtractorTest.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* global describe context it */
const { expect } = require('chai');
const authFunctionNameExtractor = require('../../src/authFunctionNameExtractor');

Expand Down Expand Up @@ -79,6 +78,7 @@ describe('authFunctionNameExtractor', () => {
context('authorizer is a string', () => {
it('is a string anAuthorizerName', supportedAuthTest('anAuthorizerName', 'anAuthorizerName'));
});

context('authorizer is an object', () => {
it('named anAuthorizerName', supportedAuthTest({ name : 'anAuthorizerName' }, 'anAuthorizerName'));
});
Expand Down
1 change: 0 additions & 1 deletion test/unit/authMatchPolicyResourceTest.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* global describe context it */
const { expect } = require('chai');
const authMatchPolicyResource = require('../../src/authMatchPolicyResource');

Expand Down
2 changes: 0 additions & 2 deletions test/unit/createLambdaProxyContextTest.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* global describe before context it */
/* eslint-disable no-unused-expressions */
const { expect } = require('chai');
const RequestBuilder = require('../support/RequestBuilder');
const createLambdaProxyContext = require('../../src/createLambdaProxyContext');
Expand Down
1 change: 0 additions & 1 deletion test/unit/functionHelperTest.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* global describe before context it */
const { expect } = require('chai');
const path = require('path');
const functionHelper = require('../../src/functionHelper');
Expand Down
4 changes: 3 additions & 1 deletion test/unit/requestBodyValidatorTest.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* global describe before context it */
const { expect } = require('chai');
const requestBodyValidator = require('../../src/requestBodyValidator');

Expand Down Expand Up @@ -64,13 +63,15 @@ describe('requestBodyValidator', () => {
},
},
};

before(() => {
result = requestBodyValidator.getModel(custom, eventHttp, log => logStorage.push(log));
});

it('should return null', () => {
expect(result).to.eq(null);
});

it('should add a warning log', () => {
expect(logStorage.length).to.eq(1);
expect(logStorage[0]).to.eq(`Warning: can't find '${anotherModel}' within ${JSON.stringify(eventHttp.documentation.requestModels)}`);
Expand Down Expand Up @@ -101,6 +102,7 @@ describe('requestBodyValidator', () => {
const body = JSON.stringify({
message: 'foo',
});

it('should throw error', () => {
expect(() => requestBodyValidator.validate(model, body)).to.throw(/Request body validation failed.*/);
});
Expand Down
1 change: 0 additions & 1 deletion test/unit/utilsTest.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* global describe context it */
const { expect } = require('chai');
const {
detectEncoding,
Expand Down
1 change: 0 additions & 1 deletion test/unit/velocityContextTest.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* global describe it */
const { expect } = require('chai');
const createVelocityContext = require('../../src/createVelocityContext');

Expand Down

0 comments on commit 2705280

Please sign in to comment.