Skip to content

Commit 852d6f6

Browse files
authored
style: Add linting using eslint (#406)
* Fix error message concatenation * Add linting using eslint * Only run linting on Node.js 4.x and up
1 parent 6d282be commit 852d6f6

34 files changed

+84
-35
lines changed

.eslintrc

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"extends": "standard",
3+
"rules": {
4+
"block-spacing": 0,
5+
"brace-style": 0,
6+
"comma-dangle": 0,
7+
"indent": 0,
8+
"key-spacing": 0,
9+
"keyword-spacing": 0,
10+
"no-duplicate-imports": 0,
11+
"no-multiple-empty-lines": 0,
12+
"no-path-concat": 0,
13+
"no-throw-literal": 0,
14+
"no-trailing-spaces": 0,
15+
"no-unused-vars": 0,
16+
"operator-linebreak": 0,
17+
"padded-blocks": 0,
18+
"quotes": 0,
19+
"semi-spacing": 0,
20+
"semi": 0,
21+
"space-before-blocks": 0,
22+
"space-before-function-paren": 0,
23+
"space-infix-ops": 0
24+
}
25+
}

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ before_script:
2222
- npm prune
2323
- git version
2424
script:
25+
# Only run linting on Node.js 4.x and up
26+
- if [ $(node -pe 'process.version.match(/v(\d+)\./)[1] >= 4') == 'true' ]; then npm run lint; fi
2527
- npm run test
2628
- npm run check-coverage
2729
after_success:

package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"write-coverage": "nyc report --reporter=lcov",
1414
"semantic-release": "semantic-release pre && npm publish && semantic-release post",
1515
"start": "npm run test:watch",
16+
"lint": "eslint --ignore-path .gitignore .",
1617
"test": "nyc --require babel-core/register _mocha -- test/tests/index.js",
1718
"test:watch": "nodemon -q --ignore test/.tmp/ --ignore test/artifacts/ --ignore coverage/ --exec \"npm run test\" --",
1819
"test:windows": "node ./test/tools/trigger-appveyor-tests.js"
@@ -22,7 +23,7 @@
2223
"path": "./node_modules/cz-conventional-changelog"
2324
},
2425
"ghooks": {
25-
"pre-commit": "npm run test && npm run check-coverage"
26+
"pre-commit": "npm run lint && npm run test && npm run check-coverage"
2627
}
2728
},
2829
"homepage": "https://github.com/commitizen/cz-cli",
@@ -54,6 +55,10 @@
5455
"babel-preset-stage-2": "6.17.0",
5556
"chai": "3.5.0",
5657
"codecov.io": "0.1.6",
58+
"eslint": "3.12.2",
59+
"eslint-config-standard": "6.2.1",
60+
"eslint-plugin-promise": "3.4.0",
61+
"eslint-plugin-standard": "2.0.1",
5762
"ghooks": "1.3.0",
5863
"in-publish": "^2.0.0",
5964
"mocha": "3.1.2",

src/cli/git-cz.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ function bootstrap(environment = {}) {
2525
// This tells commitizen that it is not needed, just use git
2626
useGitStrategy(rawGitArgs, environment);
2727
}
28-
}
28+
}

src/cli/parsers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ import * as gitCz from './parsers/git-cz';
44
export {
55
commitizen,
66
gitCz
7-
};
7+
};

src/cli/parsers/commitizen.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ function parse(rawGitArgs) {
1818
});
1919

2020
return args;
21-
}
21+
}

src/cli/parsers/git-cz.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ function parse(rawGitArgs) {
2525
for (let arg in args) {
2626

2727
if (!args.hasOwnProperty(arg)) {
28-
//The current property is not a direct property
28+
// The current property is not a direct property
2929
continue;
3030
}
3131

@@ -67,4 +67,4 @@ function parse(rawGitArgs) {
6767
} else {
6868
return output;
6969
}
70-
}
70+
}

src/cli/strategies.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ import gitCz from './strategies/git-cz';
44
export {
55
git,
66
gitCz
7-
};
7+
};

src/cli/strategies/git.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import child_process from 'child_process';
1+
import childProcess from 'child_process';
22

33
export default git;
44

@@ -10,7 +10,7 @@ function git(rawGitArgs, environment) {
1010
} else {
1111
var vanillaGitArgs = ["commit"].concat(rawGitArgs);
1212

13-
var child = child_process.spawn('git', vanillaGitArgs, {
13+
var child = childProcess.spawn('git', vanillaGitArgs, {
1414
stdio: 'inherit'
1515
});
1616

src/commitizen.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ export {
1212
configLoader,
1313
init,
1414
staging
15-
};
15+
};

0 commit comments

Comments
 (0)