Skip to content

Commit

Permalink
convert to airbnb eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
digitalsadhu committed Jan 9, 2019
1 parent ec2fb29 commit 0ebcfeb
Show file tree
Hide file tree
Showing 10 changed files with 88 additions and 46 deletions.
3 changes: 0 additions & 3 deletions .editorconfig
Expand Up @@ -9,6 +9,3 @@ end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[{*.json,.stylelintrc,.eslintrc,.babelrc}]
indent_size = 2
1 change: 1 addition & 0 deletions .eslintignore
@@ -1 +1,2 @@
coverage/
coverage
30 changes: 15 additions & 15 deletions .eslintrc
@@ -1,17 +1,17 @@
{
"root": true,
"extends": [
"finn",
"finn/node",
"finn-prettier"
],
"parserOptions": {
"ecmaVersion": 2018
},
"overrides": [{
"files": "__tests__/**/*",
"env": {
"jest": true
}
}]
"root": true,
"extends": ["airbnb-base", "prettier"],
"overrides": [
{
"files": "__tests__/**/*",
"env": {
"jest": true
}
}
],
"plugins": ["prettier"],
"rules": {
"strict": [0, "global"],
"class-methods-use-this": [0]
}
}
7 changes: 7 additions & 0 deletions .gitignore
Expand Up @@ -6,3 +6,10 @@ node_modules/
*.log
.vscode
package-lock.json
node_modules
node_modules/**/*
.DS_Store
tmp/**/*
.idea
.idea/**/*
coverage
13 changes: 13 additions & 0 deletions .prettierrc
@@ -0,0 +1,13 @@
{
"singleQuote": true,
"trailingComma": "all",
"tabWidth": 4,
"overrides": [
{
"files": [".prettierrc", "*.json", "*.yml", ".travis.yml", ".eslintrc"],
"options": {
"tabWidth": 2
}
}
]
}
16 changes: 8 additions & 8 deletions __tests__/layout.js
Expand Up @@ -2,10 +2,10 @@

const Podlet = require('@podium/podlet');
const stoppable = require('stoppable');
const Layout = require('../');
const express = require('express');
const request = require('supertest');
const stream = require('readable-stream');
const Layout = require('../');

const destObjectStream = done => {
const arr = [];
Expand Down Expand Up @@ -37,7 +37,7 @@ test('Layout() - instantiate new layout object - should create an object', () =>
test('Layout() - object tag - should be PodiumLayout', () => {
const layout = new Layout({ name: 'foo', pathname: '/' });
expect(Object.prototype.toString.call(layout)).toEqual(
'[object PodiumLayout]'
'[object PodiumLayout]',
);
});

Expand All @@ -46,7 +46,7 @@ test('Layout() - no value given to "name" argument - should throw', () => {
expect(() => {
const layout = new Layout({ pathname: '/' }); // eslint-disable-line no-unused-vars
}).toThrowError(
'The value, "", for the required argument "name" on the Layout constructor is not defined or not valid.'
'The value, "", for the required argument "name" on the Layout constructor is not defined or not valid.',
);
});

Expand All @@ -55,7 +55,7 @@ test('Layout() - invalid value given to "name" argument - should throw', () => {
expect(() => {
const layout = new Layout({ name: 'foo bar', pathname: '/' }); // eslint-disable-line no-unused-vars
}).toThrowError(
'The value, "foo bar", for the required argument "name" on the Layout constructor is not defined or not valid.'
'The value, "foo bar", for the required argument "name" on the Layout constructor is not defined or not valid.',
);
});

Expand All @@ -64,7 +64,7 @@ test('Layout() - no value given to "pathname" argument - should throw', () => {
expect(() => {
const layout = new Layout({ name: 'foo' }); // eslint-disable-line no-unused-vars
}).toThrowError(
'The value, "", for the required argument "pathname" on the Layout constructor is not defined or not valid.'
'The value, "", for the required argument "pathname" on the Layout constructor is not defined or not valid.',
);
});

Expand All @@ -73,7 +73,7 @@ test('Layout() - invalid value given to "name" argument - should throw', () => {
expect(() => {
const layout = new Layout({ name: 'foo', pathname: 'foo bar' }); // eslint-disable-line no-unused-vars
}).toThrowError(
'The value, "foo bar", for the required argument "pathname" on the Layout constructor is not defined or not valid.'
'The value, "foo bar", for the required argument "pathname" on the Layout constructor is not defined or not valid.',
);
});

Expand Down Expand Up @@ -133,14 +133,14 @@ test('Layout() - metrics properly decorated', async done => {
expect(arr[3].meta.proxy).toBe('api');
expect(arr[3].meta.layout).toBe('myLayout');
done();
})
}),
);

const s2 = stoppable(app.listen(4001), 0);

const result = await request('http://localhost:4001').get('/');
const apiResponse = await request('http://localhost:4001').get(
'/podium-resource/myPodlet/api'
'/podium-resource/myPodlet/api',
);

expect(result.text).toBe('this is podlet content');
Expand Down
9 changes: 6 additions & 3 deletions example/server/server.js
@@ -1,8 +1,11 @@
/* eslint-disable import/no-extraneous-dependencies */
/* eslint-disable no-console */

'use strict';

const express = require('express');
const Layout = require('../../');
const path = require('path');
const Layout = require('../../');

const layout = new Layout({
pathname: '/foo',
Expand Down Expand Up @@ -79,7 +82,7 @@ app.get(
res.locals.css = layout.client.css();
res.locals.js = layout.client.js();
res.status(200).render('layout', res.locals);
}
},
);

app.use(`${layout.pathname()}/assets`, express.static('assets'));
Expand All @@ -88,7 +91,7 @@ app.use(`${layout.pathname()}/assets`, express.static('assets'));
app.use((error, req, res, next) => {
console.error(error);
res.status(500).send(
'<html><body><h1>Internal server error</h1></body></html>'
'<html><body><h1>Internal server error</h1></body></html>',
);
});

Expand Down
22 changes: 12 additions & 10 deletions lib/layout.js
@@ -1,3 +1,5 @@
/* eslint-disable no-underscore-dangle */

'use strict';

const schemas = require('@podium/schemas');
Expand Down Expand Up @@ -28,8 +30,8 @@ const PodiumLayout = class PodiumLayout {
name,
schemas.manifest.name,
new Error(
`The value, "${name}", for the required argument "name" on the Layout constructor is not defined or not valid.`
)
`The value, "${name}", for the required argument "name" on the Layout constructor is not defined or not valid.`,
),
),
});

Expand All @@ -38,8 +40,8 @@ const PodiumLayout = class PodiumLayout {
pathname,
schemas.manifest.uri,
new Error(
`The value, "${pathname}", for the required argument "pathname" on the Layout constructor is not defined or not valid.`
)
`The value, "${pathname}", for the required argument "pathname" on the Layout constructor is not defined or not valid.`,
),
),
});

Expand All @@ -53,8 +55,8 @@ const PodiumLayout = class PodiumLayout {
{
logger: this.log,
},
client
)
client,
),
),
enumerable: true,
});
Expand All @@ -72,8 +74,8 @@ const PodiumLayout = class PodiumLayout {
},
logger: this.log,
},
context
)
context,
),
),
enumerable: true,
});
Expand All @@ -85,8 +87,8 @@ const PodiumLayout = class PodiumLayout {
pathname: this[_pathname],
logger: this.log,
},
proxy
)
proxy,
),
),
});

Expand Down
2 changes: 2 additions & 0 deletions lib/utils.js
@@ -1,3 +1,5 @@
/* eslint-disable no-param-reassign */

'use strict';

const { Transform } = require('readable-stream');
Expand Down
31 changes: 24 additions & 7 deletions package.json
Expand Up @@ -13,9 +13,11 @@
"scripts": {
"lint": "eslint .",
"lint:fix": "eslint --fix .",
"test": "jest",
"test": "jest .",
"test:verbose": "jest --verbose",
"test:coverage": "jest --coverage"
"test:coverage": "jest --coverage",
"lint:format": "eslint --fix .",
"precommit": "lint-staged"
},
"dependencies": {
"@metrics/client": "^2.2.0",
Expand All @@ -30,13 +32,17 @@
"readable-stream": "^3.1.1"
},
"devDependencies": {
"eslint": "^5.11.1",
"eslint-config-finn": "^3.0.1",
"eslint-config-finn-prettier": "^3.0.2",
"eslint": "^5.12.0",
"eslint-config-airbnb-base": "^13.1.0",
"eslint-config-prettier": "^3.3.0",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-prettier": "^3.0.1",
"express": "^4.16.4",
"hbs": "^4.0.1",
"husky": "^1.3.1",
"jest": "^23.6.0",
"prettier": "^1.14.2",
"lint-staged": "^8.1.0",
"prettier": "^1.15.3",
"stoppable": "^1.1.0",
"supertest": "^3.3.0"
},
Expand All @@ -52,6 +58,17 @@
"statements": 100
}
},
"testEnvironment": "node"
"testEnvironment": "node",
"clearMocks": true
},
"lint-staged": {
"*.js": [
"eslint --fix --config ./.eslintrc",
"git add"
],
"{*.json,*.md,.eslintrc,.prettierrc}": [
"prettier --write",
"git add"
]
}
}

0 comments on commit 0ebcfeb

Please sign in to comment.