Skip to content

Commit

Permalink
style(eslint): update to eslint-config-opencollective 1.3.0
Browse files Browse the repository at this point in the history
implement feedback from eslint-plugin-import and eslint-plugin-node
  • Loading branch information
znarf committed Jun 20, 2018
1 parent 0430054 commit d8d1d77
Show file tree
Hide file tree
Showing 10 changed files with 115 additions and 104 deletions.
10 changes: 6 additions & 4 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
{
"extends": "opencollective",
"extends": [
"opencollective",
],
"env": {
"jest": true
"jest": true,
},
"rules": {
// we still use console even on frontend
"no-console": 0
"no-console": 1,
"node/no-unsupported-features": 0,
}
}
127 changes: 88 additions & 39 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 7 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,10 @@
"stop:staging": "heroku ps:scale web=0 -a oc-staging-frontend && heroku ps:scale web=0 -a opencollective-staging-website && heroku ps:scale web=0 -a opencollective-staging-api",
"git:clean": "./scripts/git_clean.sh",
"postinstall": "if test \"$NODE_ENV\" = \"\" || test \"$NODE_ENV\" = \"development\" ; then echo \"Skipping postinstall build because NODE_ENV is '${NODE_ENV}'\" ; else npm run build ; fi",
"hint": "npm run lint",
"lint": "eslint '**/*.js' --quiet",
"lint:fix": "eslint '**/*.js' --fix",
"pretest": "npm run lint",
"lint": "eslint \"src/**/*.js\"",
"lint:fix": "npm run lint -- --fix",
"lint:quiet": "npm run lint -- --quiet",
"pretest": "npm run lint:quiet",
"commit": "git-cz",
"semantic-release": "semantic-release",
"cypress": "TZ=UTC cypress run"
Expand All @@ -119,9 +119,11 @@
"cypress": "3.0.1",
"cz-conventional-changelog": "^2.1.0",
"eslint": "^4.19.1",
"eslint-config-opencollective": "^1.2.1",
"eslint-config-opencollective": "^1.3.0",
"eslint-plugin-babel": "^5.1.0",
"eslint-plugin-cypress": "^2.0.1",
"eslint-plugin-import": "^2.12.0",
"eslint-plugin-node": "^6.0.1",
"eslint-plugin-react": "^7.9.1",
"jest": "23.1.0",
"jest-styled-components": "^5.0.1",
Expand Down
1 change: 1 addition & 0 deletions src/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ module.exports = {
new webpack.ContextReplacementPlugin(/moment[/\\]locale$/, /en|fr|es|ja/),
);
if (process.env.WEBPACK_BUNDLE_ANALYZER) {
// eslint-disable-next-line node/no-unpublished-require
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
config.plugins.push(
new BundleAnalyzerPlugin({
Expand Down
2 changes: 1 addition & 1 deletion src/server/controllers/collectives.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ export async function avatar(req, res) {
}
}

const base64data = new Buffer(data).toString('base64');
const base64data = Buffer.from(data).toString('base64');
const svg = `<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="${imageWidth}" height="${imageHeight}">
<image width="${imageWidth}" height="${imageHeight}" xlink:href="data:${contentType};base64,${base64data}"/>
</svg>`;
Expand Down
52 changes: 2 additions & 50 deletions src/server/controllers/transactions.js
Original file line number Diff line number Diff line change
@@ -1,55 +1,7 @@
import pdf from 'html-pdf';
import { logger } from '../logger';
import { fetchTransaction, fetchTransactions, fetchInvoice } from '../lib/graphql';

export async function list(req, res, next) {
// Keeping the resulting info for 10m in the CDN cache
res.setHeader('Cache-Control', `public, max-age=${60*10}`);
let allTransactions, path = '/';
if (req.params.collectiveSlug) {
path += `${req.params.collectiveSlug}/`;
}
try {
allTransactions = await fetchTransactions(req.params.collectiveSlug);
allTransactions = allTransactions.map(t => {
t.url = `https://opencollective.com${path}transactions/${t.id}`;
t.info = `https://opencollective.com${path}transactions/${t.id}.json`;
if (req.params.collectiveSlug) {
delete t.collective;
}
return t;
})
res.send(allTransactions);
} catch (e) {
if (e.message.match(/No collective found/)) {
return res.status(404).send("Not found");
}
logger.debug('>>> transactions.list error', e);
return next(e);
}
}

export async function info(req, res, next) {
// Keeping the resulting info for 10mn in the CDN cache
res.setHeader('Cache-Control', `public, max-age=${60*10}`);
let transaction, path = '';
if (req.params.collectiveSlug) {
path += `/${req.params.collectiveSlug}/`;
}
try {
transaction = await fetchTransaction(req.params.id);
transaction.url = `https://opencollective.com${path}transactions/${transaction.id}`;
transaction.attendees = `https://opencollective.com${path}transactions/${transaction.id}/attendees.json`;
res.send(transaction);
} catch (e) {
if (e.message.match(/No collective found/)) {
return res.status(404).send("Not found");
}
logger.debug('>>> transactions.info error', e);
return next(e);
}

}
import { logger } from '../logger';
import { fetchInvoice } from '../lib/graphql';

export async function invoice(req, res, next) {
// Keeping the resulting info for 10mn in the CDN cache
Expand Down
2 changes: 1 addition & 1 deletion src/server/lib/image-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export function generateSVGBannerForUsers(users, options) {

const contentType = headers['content-type'];
const website = (options.linkToProfile || !user.website) ? `${WEBSITE_URL}/${user.slug}` : user.website;
const base64data = new Buffer(rawData).toString('base64');
const base64data = Buffer.from(rawData).toString('base64');
let avatarWidth = avatarHeight;
try {
// We make sure the image loaded properly
Expand Down
5 changes: 4 additions & 1 deletion src/server/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,7 @@ const loggerMiddleware = {
})
}

module.exports = { logger, loggerMiddleware };
export {
logger,
loggerMiddleware
}
6 changes: 4 additions & 2 deletions src/server/pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ pages
.add('expense', '/:parentCollectiveSlug?/:collectiveType(events)?/:collectiveSlug/expenses/:ExpenseId([0-9]+)')
.add('expenses', '/:parentCollectiveSlug?/:collectiveType(events)?/:collectiveSlug/expenses/:filter(categories|recipients)?/:value?')
.add('collective', '/:slug')
.add('editCollective', '/:slug/edit')
.add('editCollective', '/:slug/edit');

module.exports = pages;
export default pages;

export const { Link, Router } = pages;
2 changes: 1 addition & 1 deletion src/server/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { logger } from './logger';
import { getCloudinaryUrl } from './lib/utils';
import { translateApiUrl } from '../lib/utils';

module.exports = (server, app) => {
export default (server, app) => {

server.get('*', mw.ga, (req, res, next) => {
req.app = app;
Expand Down

0 comments on commit d8d1d77

Please sign in to comment.