Skip to content

Commit 1c326a1

Browse files
claydiffrientdiasbruno
authored andcommitted
Add Linting (#293)
* Add linting * Make specs pass linter * Make lib/helpers pass linter * Make lib/components pass linter This also does some signfiicant refactoring of the code to appease the linter's pro-ES2015+ stance. closes #289 closes #286 * Make travis run the lint task as well as specs closes #284
1 parent d2fbe55 commit 1c326a1

File tree

7 files changed

+679
-92
lines changed

7 files changed

+679
-92
lines changed

Diff for: .eslintrc.js

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
module.exports = {
2+
"env": {
3+
"es6": true,
4+
"browser": true
5+
},
6+
"extends": "airbnb",
7+
"parserOptions": {
8+
"ecmaVersion": 7,
9+
"ecmaFeatures": {
10+
"experimentalObjectRestSpread": true,
11+
"jsx": true
12+
},
13+
"sourceType": "module"
14+
},
15+
"parser": "babel-eslint",
16+
rules: {
17+
"comma-dangle": [2, "only-multiline"],
18+
"max-len": [1, {"code": 140}],
19+
"no-continue": [0],
20+
"no-plusplus": [0],
21+
"space-before-function-paren": [2, "always"],
22+
"import/no-extraneous-dependencies": [2, {"devDependencies": true}],
23+
"react/jsx-filename-extension": ["error", {"extensions": [".js"]}]
24+
},
25+
};

Diff for: Makefile

+4
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ help: info
1717
@echo " make deps - install all dependencies."
1818
@echo " make serve - start the server."
1919
@echo " make tests - run tests."
20+
@echo " make lint - run lint."
2021
@echo " make docs - build and serve the docs."
2122
@echo " make build - build project artifacts."
2223
@echo " make publish - build and publish version on npm."
@@ -48,6 +49,9 @@ tests:
4849
tests-ci:
4950
@npm run test -- --single-run
5051

52+
lint:
53+
@npm run lint
54+
5155
docs: build-docs
5256
gitbook serve
5357

Diff for: eslint.json

-18
This file was deleted.

Diff for: package.json

+9-1
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,28 @@
1414
},
1515
"scripts": {
1616
"start": "./node_modules/.bin/webpack-dev-server --inline --host 127.0.0.1 --content-base examples/",
17-
"test": "cross-env NODE_ENV=test karma start"
17+
"test": "cross-env NODE_ENV=test karma start",
18+
"test:full": "npm-run-all -p 'test -- --single-run' lint",
19+
"lint": "eslint lib/ specs/"
1820
},
1921
"authors": [
2022
"Ryan Florence"
2123
],
2224
"license": "MIT",
2325
"devDependencies": {
2426
"babel-core": "^6.7.4",
27+
"babel-eslint": "^7.1.1",
2528
"babel-loader": "^6.2.4",
2629
"babel-preset-es2015": "^6.6.0",
2730
"babel-preset-react": "^6.5.0",
2831
"babel-preset-stage-2": "^6.24.1",
2932
"cross-env": "^5.0.1",
3033
"envify": "^3.4.1",
34+
"eslint": "^3.9.1",
35+
"eslint-config-airbnb": "latest",
36+
"eslint-plugin-import": "^2.1.0",
37+
"eslint-plugin-jsx-a11y": "^2.2.3",
38+
"eslint-plugin-react": "^6.6.0",
3139
"expect": "^1.20.2",
3240
"gitbook-cli": "^2.3.0",
3341
"karma": "^1.3.0",

Diff for: specs/spec_index.js

+7-8
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
const testsContext = require.context('.', true, /spec$/);
2-
testsContext.keys().forEach(function(path) {
3-
try {
4-
testsContext(path);
5-
} catch(err) {
6-
debugger
7-
console.error(`[ERROR] WITH SPEC FILE: ${path}`);
8-
console.error(err);
9-
}
2+
testsContext.keys().forEach((path) => {
3+
try {
4+
testsContext(path);
5+
} catch (err) {
6+
console.error(`[ERROR] WITH SPEC FILE: ${path}`);
7+
console.error(err);
8+
}
109
});

Diff for: webpack.test.config.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
var commonConfig = require('./webpack.config');
1+
const commonConfig = require('./webpack.config');
22

33
commonConfig.plugins = [];
44
commonConfig.entry = undefined;
55
commonConfig.debug = true;
6+
commonConfig.devtool = 'inline-source-map';
67

78
module.exports = commonConfig;

0 commit comments

Comments
 (0)