Skip to content
This repository has been archived by the owner on Apr 5, 2024. It is now read-only.

Commit

Permalink
Merge pull request #196 from XhmikosR/xmr-eslint-2
Browse files Browse the repository at this point in the history
Update ESLint rules.
  • Loading branch information
Francois Marier committed Apr 26, 2018
2 parents 92c9ff9 + 5034e4c commit bb0d830
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 33 deletions.
4 changes: 2 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@
"error",
"always"
],
"object-shorthand": "off",
"object-shorthand": "error",
"one-var": [
"error",
"never"
Expand All @@ -263,7 +263,7 @@
"prefer-template": "error",
"quote-props": [
"error",
"consistent"
"as-needed"
],
"quotes": [
"error",
Expand Down
2 changes: 1 addition & 1 deletion build/copyright.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function findCopyright(fileGlobs, opts) {
return !fileStr.match(options.pattern);
});

if (files.length) {
if (files.length > 0) {
console.log('The following files don\'t match the specified pattern:\n> %s\n', options.pattern);

files.forEach((file) => {
Expand Down
12 changes: 6 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,14 @@ server.register(inert, () => {
path: '/',
handler(request, reply) {
const browsers = helpers.shuffleArray([
{ 'name': 'Firefox', 'url': 'https://www.mozilla.org/firefox/' },
{ 'name': 'Safari', 'url': 'https://www.apple.com/safari/' },
{ 'name': 'Chrome', 'url': 'https://www.google.com/chrome/browser/desktop/' }
{ name: 'Firefox', url: 'https://www.mozilla.org/firefox/' },
{ name: 'Safari', url: 'https://www.apple.com/safari/' },
{ name: 'Chrome', url: 'https://www.google.com/chrome/browser/desktop/' }
]);
reply
.view('index', {
'title': 'SRI Hash Generator',
'browsers': browsers
title: 'SRI Hash Generator',
browsers
})
.header('Content-Security-Policy', CSP_HEADER)
.header('Referrer-Policy', REFERRER_HEADER);
Expand Down Expand Up @@ -135,7 +135,7 @@ server.register(inert, () => {
request.payload.algorithms,
(result) => {
reply
.view('hash', { 'hash': result })
.view('hash', { hash: result })
.header('Content-Security-Policy', CSP_HEADER)
.header('Referrer-Policy', REFERRER_HEADER);
}
Expand Down
46 changes: 23 additions & 23 deletions lib/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,18 +99,18 @@ const eligibility = (response) => {
const processResource = (data, response, resourceUrl, cb) => {
if (response.statusCode !== 200) {
return cb({
'success': false,
'status': response.statusCode
success: false,
status: response.statusCode
});
}

return cb({
'success': true,
'status': response.statusCode,
'url': resourceUrl,
'eligibility': eligibility(response),
'data': data,
'ct': response.headers['content-type']
success: true,
status: response.statusCode,
url: resourceUrl,
eligibility: eligibility(response),
data,
ct: response.headers['content-type']
});
};

Expand All @@ -133,7 +133,7 @@ const fetchResource = (resourceUrl, cb) => {
const options = {
hostname: urlObject.hostname,
path: urlObject.path,
headers: { 'Origin': 'https://www.srihash.org/' }
headers: { Origin: 'https://www.srihash.org/' }
};

moduleForProtocol(resourceUrl).get(options, (response) => {
Expand Down Expand Up @@ -217,31 +217,31 @@ const generate = (options, cb) => {
fetchResource(options.url, (resource) => {
if (!resource) {
return cb({
'success': false,
'status': 0
success: false,
status: 0
});
}
if (resource.status !== 200) {
return cb(resource);
}

const sri = sriToolbox.generate({
'algorithms': options.algorithms,
'full': true
algorithms: options.algorithms,
full: true
}, resource.data);

const contentType = getResourceTypeFromContentTypeHeader(resource.ct);

return cb({
'success': true,
'status': resource.status,
'url': resource.url,
'type': guessResourceType({
'url': resource.url,
'ct': contentType
success: true,
status: resource.status,
url: resource.url,
type: guessResourceType({
url: resource.url,
ct: contentType
}),
'integrity': sri.integrity,
'eligibility': resource.eligibility
integrity: sri.integrity,
eligibility: resource.eligibility
});
});
};
Expand All @@ -257,8 +257,8 @@ const generate = (options, cb) => {
*/
const generateElement = (resourceUrl, algorithms, cb) => {
const options = {
'url': resourceUrl,
'algorithms': algorithms
url: resourceUrl,
algorithms
};

generate(options, (resource) => {
Expand Down
2 changes: 1 addition & 1 deletion test/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ describe('eligibility()', () => {

describe('Non-eligible', () => {
it('non-CORS', () => {
const nonCORS = { headers: { 'dnt': '1' } };
const nonCORS = { headers: { dnt: '1' } };
const result = helpers.eligibility(nonCORS);
assert.deepEqual(result, ['non-cors']);
});
Expand Down

0 comments on commit bb0d830

Please sign in to comment.