Skip to content

Commit 6ee1437

Browse files
committed
[eslint] add eslint
1 parent dc1cc12 commit 6ee1437

File tree

14 files changed

+103
-25
lines changed

14 files changed

+103
-25
lines changed

.eslintrc

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{
2+
"root": true,
3+
4+
"extends": "@ljharb",
5+
6+
"rules": {
7+
"array-bracket-newline": 0,
8+
"array-bracket-spacing": 1,
9+
"array-callback-return": 1,
10+
"brace-style": 1,
11+
"comma-spacing": 1,
12+
"complexity": 0,
13+
"consistent-return": 1,
14+
"curly": 1,
15+
"eqeqeq": 1,
16+
"func-style": 1,
17+
"indent": [1, 4],
18+
"max-depth": 0,
19+
"max-lines-per-function": 1,
20+
"max-statements": 0,
21+
"multiline-comment-style": 0,
22+
"no-else-return": 1,
23+
"no-lonely-if": 1,
24+
"no-negated-condition": 1,
25+
"no-param-reassign": 1,
26+
"no-shadow": 1,
27+
"no-template-curly-in-string": 0,
28+
"no-trailing-spaces": 1,
29+
"no-use-before-define": 1,
30+
"no-useless-escape": 1,
31+
"nonblock-statement-body-position": 1,
32+
"object-curly-spacing": 1,
33+
"prefer-regex-literals": 1,
34+
"quotes": 1,
35+
"space-before-blocks": 1,
36+
"space-before-function-paren": 1,
37+
"space-infix-ops": 1,
38+
"spaced-comment": 1,
39+
"wrap-regex": 1,
40+
},
41+
42+
"overrides": [
43+
{
44+
"files": "example/**",
45+
"rules": {
46+
"no-console": 0,
47+
},
48+
},
49+
],
50+
}

example/env.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict';
2+
13
var parse = require('../').parse;
24
var xs = parse('beep --boop="$PWD"', { PWD: '/home/robot' });
35
console.dir(xs);

example/op.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict';
2+
13
var parse = require('../').parse;
24
var xs = parse('beep || boop > /byte');
35
console.dir(xs);

example/parse.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict';
2+
13
var parse = require('../').parse;
24
var xs = parse('a "b c" \\$def \'it\\\'s great\'');
35
console.dir(xs);

example/quote.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict';
2+
13
var quote = require('../').quote;
24
var s = quote([ 'a', 'b c d', '$f', '"g"' ]);
35
console.log(s);

index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict';
2+
13
exports.quote = function (xs) {
24
return xs.map(function (s) {
35
if (s && typeof s === 'object') {

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
},
1010
"bugs": "https://github.com/substack/node-shell-quote/issues",
1111
"devDependencies": {
12+
"@ljharb/eslint-config": "^21.0.0",
1213
"aud": "^2.0.1",
14+
"eslint": "=8.8.0",
1315
"tape": "^5.6.1"
1416
},
1517
"homepage": "https://github.com/substack/node-shell-quote",
@@ -26,6 +28,8 @@
2628
"url": "http://github.com/substack/node-shell-quote.git"
2729
},
2830
"scripts": {
31+
"lint": "eslint --ext=js,mjs .",
32+
"pretest": "npm run lint",
2933
"tests-only": "tape 'test/**/*.js'",
3034
"test": "npm run tests-only",
3135
"posttest": "aud --production"

test/comment.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict';
2+
13
var test = require('tape');
24
var parse = require('../').parse;
35

test/env.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict';
2+
13
var test = require('tape');
24
var parse = require('../').parse;
35

@@ -17,22 +19,22 @@ test('expand environment variables', function (t) {
1719
t.same(parse("ab${x}def", { x: 'c' }), [ 'abcdef' ]);
1820
t.same(parse("ab\\${x}def", { x: 'c' }), [ 'ab${x}def' ]);
1921
t.same(parse('"ab\\${x}def"', { x: 'c' }), [ 'ab${x}def' ]);
20-
22+
2123
t.end();
2224
});
2325

2426
test('environment variables with metacharacters', function (t) {
2527
t.same(parse('a $XYZ c', { XYZ: '"b"' }), [ 'a', '"b"', 'c' ]);
2628
t.same(parse('a $XYZ c', { XYZ: '$X', X: 5 }), [ 'a', '$X', 'c' ]);
2729
t.same(parse('a"$XYZ"c', { XYZ: "'xyz'" }), [ "a'xyz'c" ]);
28-
30+
2931
t.end();
3032
});
3133

3234
test('special shell parameters', function (t) {
3335
var chars = '*@#?-$!0_'.split('');
3436
t.plan(chars.length);
35-
37+
3638
chars.forEach(function (c) {
3739
var env = {};
3840
env[c] = 'xxx';

test/env_fn.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
1+
'use strict';
2+
13
var test = require('tape');
24
var parse = require('../').parse;
35

46
test('functional env expansion', function (t) {
57
t.plan(4);
6-
8+
79
t.same(parse('a $XYZ c', getEnv), [ 'a', 'xxx', 'c' ]);
810
t.same(parse('a $XYZ c', getEnvObj), [ 'a', { op: '@@' }, 'c' ]);
911
t.same(parse('a${XYZ}c', getEnvObj), [ 'a', { op: '@@' }, 'c' ]);
1012
t.same(parse('"a $XYZ c"', getEnvObj), [ 'a ', { op: '@@' }, ' c' ]);
11-
12-
function getEnv (key) {
13+
14+
function getEnv() {
1315
return 'xxx';
1416
}
15-
16-
function getEnvObj (key) {
17+
18+
function getEnvObj() {
1719
return { op: '@@' };
1820
}
1921
});

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy