Skip to content

Commit

Permalink
simplify eslint config
Browse files Browse the repository at this point in the history
  • Loading branch information
UziTech committed May 4, 2019
1 parent c458abd commit bc835ae
Show file tree
Hide file tree
Showing 11 changed files with 154 additions and 157 deletions.
21 changes: 15 additions & 6 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,23 @@
"parserOptions": { "ecmaVersion": 5 },
"rules": {
"semi": ["error", "always"],
"indent": ["warn", 2, {
"VariableDeclarator": { "var": 2 },
"indent": ["error", 2, {
"SwitchCase": 1,
"outerIIFEBody": 0
"VariableDeclarator": { "var": 2 },
"outerIIFEBody": 0,
"MemberExpression": 1,
"FunctionDeclaration": { "parameters": 1, "body": 1 },
"FunctionExpression": { "parameters": 1, "body": 1 },
"CallExpression": { "arguments": 1 },
"ArrayExpression": 1,
"ObjectExpression": 1,
"ImportDeclaration": 1,
"flatTernaryExpressions": false,
"ignoreComments": false
}],
"space-before-function-paren": "off",
"object-curly-spacing": "off",
"operator-linebreak": ["error", "before", { "overrides": { "=": "after" } }],
"no-cond-assign": "off",
"no-useless-escape": "off",
"no-return-assign": "off",
"one-var": "off",
"no-control-regex": "off",

Expand Down Expand Up @@ -100,6 +106,7 @@
"no-proto": "error",
"no-redeclare": "error",
"no-regex-spaces": "error",
"no-return-assign": ["error", "except-parens"],
"no-return-await": "error",
"no-self-assign": "error",
"no-self-compare": "error",
Expand Down Expand Up @@ -129,13 +136,15 @@
"no-useless-return": "error",
"no-whitespace-before-property": "error",
"no-with": "error",
"object-curly-spacing": ["error", "always"],
"object-property-newline": ["error", { "allowMultiplePropertiesPerLine": true }],
"padded-blocks": ["error", { "blocks": "never", "switches": "never", "classes": "never" }],
"prefer-promise-reject-errors": "error",
"quotes": ["error", "single", { "avoidEscape": true, "allowTemplateLiterals": true }],
"rest-spread-spacing": ["error", "never"],
"semi-spacing": ["error", { "before": false, "after": true }],
"space-before-blocks": ["error", "always"],
"space-before-function-paren": ["error", "always"],
"space-in-parens": ["error", "never"],
"space-infix-ops": "error",
"space-unary-ops": ["error", { "words": true, "nonwords": false }],
Expand Down
34 changes: 17 additions & 17 deletions bin/marked
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ var fs = require('fs'),
* Man Page
*/

function help() {
function help () {
var spawn = require('child_process').spawn;

var options = {
Expand All @@ -24,15 +24,15 @@ function help() {
};

spawn('man', [path.resolve(__dirname, '/../man/marked.1')], options)
.on('error', function() {
fs.readFile(path.resolve(__dirname, '/../man/marked.1.txt'), 'utf8', function(err, data) {
.on('error', function () {
fs.readFile(path.resolve(__dirname, '/../man/marked.1.txt'), 'utf8', function (err, data) {
if (err) throw err;
console.log(data);
});
});
}

function version() {
function version () {
var pkg = require('../package.json');
console.log(pkg.version);
}
Expand All @@ -41,7 +41,7 @@ function version() {
* Main
*/

function main(argv, callback) {
function main (argv, callback) {
var files = [],
options = {},
input,
Expand All @@ -51,7 +51,7 @@ function main(argv, callback) {
tokens,
opt;

function getarg() {
function getarg () {
var arg = argv.shift();

if (arg.indexOf('--') === 0) {
Expand All @@ -65,7 +65,7 @@ function main(argv, callback) {
} else if (arg[0] === '-') {
if (arg.length > 2) {
// e.g. -abc
argv = arg.substring(1).split('').map(function(ch) {
argv = arg.substring(1).split('').map(function (ch) {
return '-' + ch;
}).concat(argv);
arg = argv.shift();
Expand Down Expand Up @@ -128,7 +128,7 @@ function main(argv, callback) {
}
}

function getData(callback) {
function getData (callback) {
if (!input) {
if (files.length <= 2) {
if (string) {
Expand All @@ -141,7 +141,7 @@ function main(argv, callback) {
return fs.readFile(input, 'utf8', callback);
}

return getData(function(err, data) {
return getData(function (err, data) {
if (err) return callback(err);

data = tokens
Expand All @@ -161,21 +161,21 @@ function main(argv, callback) {
* Helpers
*/

function getStdin(callback) {
function getStdin (callback) {
var stdin = process.stdin,
buff = '';

stdin.setEncoding('utf8');

stdin.on('data', function(data) {
stdin.on('data', function (data) {
buff += data;
});

stdin.on('error', function(err) {
stdin.on('error', function (err) {
return callback(err);
});

stdin.on('end', function() {
stdin.on('end', function () {
return callback(null, buff);
});

Expand All @@ -186,13 +186,13 @@ function getStdin(callback) {
}
}

function camelize(text) {
return text.replace(/(\w)-(\w)/g, function(_, a, b) {
function camelize (text) {
return text.replace(/(\w)-(\w)/g, function (_, a, b) {
return a + b.toUpperCase();
});
}

function handleError(err) {
function handleError (err) {
if (err.code === 'ENOENT') {
console.error('marked: output to ' + err.path + ': No such directory');
return process.exit(1);
Expand All @@ -206,7 +206,7 @@ function handleError(err) {

if (!module.parent) {
process.title = 'marked';
main(process.argv.slice(), function(err, code) {
main(process.argv.slice(), function (err, code) {
if (err) return handleError(err);
return process.exit(code || 0);
});
Expand Down
Loading

0 comments on commit bc835ae

Please sign in to comment.