Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ADD: eslint configurations #70

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
32 changes: 32 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"env": {
"browser": true,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why bowser?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is default eslint config :)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is default eslint config :

"commonjs": true,
"es6": true
},
"plugins": [
"security"
],
"extends": ["airbnb-standard","plugin:security/recommended"],
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly"
},
"parserOptions": {
"ecmaVersion": 2018
},
"rules": {
"indent": [2, "tab"],
ahmadawais marked this conversation as resolved.
Show resolved Hide resolved
"no-tabs": 0,
"no-console": 0,
"consistent-return": 0,
"array-callback-return": 0,
"import/order": 0,
"no-undef": 0,
"no-const-assign": 0,
"no-unused-vars": 0,
"no-param-reassign": 0,
"promise/param-names": 0,
"security/detect-object-injection":0
}
}
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,15 @@
"update-notifier": "^4.1.0"
},
"devDependencies": {
"eslint": "^6.8.0",
"eslint-config-airbnb-standard": "^3.1.0",
"eslint-plugin-security": "^1.4.0",
"prettier": "^2.0.2"
},
"scripts": {
"format": "prettier --write \"./**/*.{js,json}\"",
"lint": "eslint ./utils/",
"lint:fix": "eslint ./utils/ --fix",
"test": "node test.js"
}
}
7 changes: 4 additions & 3 deletions utils/cli.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
const meow = require('meow');
const chalk = require('chalk');
const green = chalk.green;
const yellow = chalk.yellow;
const cyan = chalk.cyan;

const { green } = chalk;
const { yellow } = chalk;
const { cyan } = chalk;

module.exports = meow(
`
Expand Down
5 changes: 3 additions & 2 deletions utils/getCountries.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
const axios = require('axios');
const chalk = require('chalk');
const cyan = chalk.cyan;
const dim = chalk.dim;

const { cyan } = chalk;
const { dim } = chalk;
const comma = require('comma-number');
const { sortingKeys } = require('./table.js');
const to = require('await-to-js').default;
Expand Down
3 changes: 2 additions & 1 deletion utils/getCountry.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ const chalk = require('chalk');
const axios = require('axios');
const sym = require('log-symbols');
const comma = require('comma-number');
const red = chalk.red;

const { red } = chalk;
const to = require('await-to-js').default;
const handleError = require('cli-handle-error');

Expand Down
6 changes: 2 additions & 4 deletions utils/getCountryChart.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ module.exports = async (spinner, countryName, { chart, log }) => {
logScale = x => (x === 0 ? undefined : Math.log(x));
}
const shortDate = x => moment(x, 'MM/DD/YY').format('D MMM');
const cumulative = (a, b) => (a = a + b);
const cumulative = (a, b) => (a += b);
const screen = blessed.screen();
const line = contrib.line({
style: {
Expand Down Expand Up @@ -76,9 +76,7 @@ module.exports = async (spinner, countryName, { chart, log }) => {
line.setData([casesSeries, deathsSeries, recoveredSeries]);
screen.render();
await new Promise((resolve, _) => {
screen.key(['escape', 'q', 'C-c', 'enter', 'space'], (ch, key) => {
return process.exit(0);
});
screen.key(['escape', 'q', 'C-c', 'enter', 'space'], (ch, key) => process.exit(0));
});
}
};
5 changes: 3 additions & 2 deletions utils/getStates.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
const axios = require('axios');
const chalk = require('chalk');
const cyan = chalk.cyan;
const dim = chalk.dim;

const { cyan } = chalk;
const { dim } = chalk;
const comma = require('comma-number');
const { sortingStateKeys } = require('./table.js');
const to = require('await-to-js').default;
Expand Down
2 changes: 1 addition & 1 deletion utils/init.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const welcome = require('cli-welcome');
const checkNode = require('cli-check-node');
const pkgJSON = require('./../package.json');
const updateNotifier = require('update-notifier');
const unhandledError = require('cli-handle-unhandled');
const pkgJSON = require('./../package.json');

module.exports = async () => {
unhandledError();
Expand Down
9 changes: 5 additions & 4 deletions utils/table.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
const chalk = require('chalk');
const green = chalk.green;
const red = chalk.red;
const yellow = chalk.yellow;
const dim = chalk.dim;

const { green } = chalk;
const { red } = chalk;
const { yellow } = chalk;
const { dim } = chalk;

module.exports = {
single: [
Expand Down
19 changes: 9 additions & 10 deletions utils/theEnd.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
const sym = require('log-symbols');
const chalk = require('chalk');
const cyan = chalk.cyan;
const dim = chalk.dim;

const infoStates = () =>
console.log(
dim(`
const { cyan } = chalk;
const { dim } = chalk;

const infoStates = () => console.log(
dim(`
\n${sym.info} ${cyan(`KEY:`)}
${dim(`❯ `)}${cyan(`State:`)} Name of the state
${dim(`❯ `)}${cyan(`Cases:`)} Total number of cases in a country
Expand All @@ -15,11 +15,10 @@ ${dim(`❯ `)}${cyan(`Deaths (today):`)} Deaths in 24 hours GMT/UTC
${dim(`❯ `)}${cyan(`Recovered:`)} Total number of recovered people
${dim(`❯ `)}${cyan(`Active:`)} Total number of active patients
`)
);
);

const infoCountries = () =>
console.log(
dim(`
const infoCountries = () => console.log(
dim(`
\n${sym.info} ${cyan(`KEY:`)}
${dim(`❯ `)}${cyan(`Country:`)} Name of the country
${dim(`❯ `)}${cyan(`Cases:`)} Total number of cases in a country
Expand All @@ -31,7 +30,7 @@ ${dim(`❯ `)}${cyan(`Active:`)} Total number of active patients
${dim(`❯ `)}${cyan(`Critical:`)} Total number of critical patients
${dim(`❯ `)}${cyan(`Per Million:`)} Affected patients per million
`)
);
);

module.exports = async (lastUpdated, states, minimal) => {
if (minimal) return console.log();
Expand Down