Skip to content

Commit

Permalink
Add Linting (reactjs#293)
Browse files Browse the repository at this point in the history
* 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 reactjs#289
closes reactjs#286

* Make travis run the lint task as well as specs

closes reactjs#284
  • Loading branch information
claydiffrient authored and diasbruno committed Jun 15, 2017
1 parent d2fbe55 commit 1c326a1
Show file tree
Hide file tree
Showing 7 changed files with 679 additions and 92 deletions.
25 changes: 25 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
module.exports = {
"env": {
"es6": true,
"browser": true
},
"extends": "airbnb",
"parserOptions": {
"ecmaVersion": 7,
"ecmaFeatures": {
"experimentalObjectRestSpread": true,
"jsx": true
},
"sourceType": "module"
},
"parser": "babel-eslint",
rules: {
"comma-dangle": [2, "only-multiline"],
"max-len": [1, {"code": 140}],
"no-continue": [0],
"no-plusplus": [0],
"space-before-function-paren": [2, "always"],
"import/no-extraneous-dependencies": [2, {"devDependencies": true}],
"react/jsx-filename-extension": ["error", {"extensions": [".js"]}]
},
};
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ help: info
@echo " make deps - install all dependencies."
@echo " make serve - start the server."
@echo " make tests - run tests."
@echo " make lint - run lint."
@echo " make docs - build and serve the docs."
@echo " make build - build project artifacts."
@echo " make publish - build and publish version on npm."
Expand Down Expand Up @@ -48,6 +49,9 @@ tests:
tests-ci:
@npm run test -- --single-run

lint:
@npm run lint

docs: build-docs
gitbook serve

Expand Down
18 changes: 0 additions & 18 deletions eslint.json

This file was deleted.

10 changes: 9 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,28 @@
},
"scripts": {
"start": "./node_modules/.bin/webpack-dev-server --inline --host 127.0.0.1 --content-base examples/",
"test": "cross-env NODE_ENV=test karma start"
"test": "cross-env NODE_ENV=test karma start",
"test:full": "npm-run-all -p 'test -- --single-run' lint",
"lint": "eslint lib/ specs/"
},
"authors": [
"Ryan Florence"
],
"license": "MIT",
"devDependencies": {
"babel-core": "^6.7.4",
"babel-eslint": "^7.1.1",
"babel-loader": "^6.2.4",
"babel-preset-es2015": "^6.6.0",
"babel-preset-react": "^6.5.0",
"babel-preset-stage-2": "^6.24.1",
"cross-env": "^5.0.1",
"envify": "^3.4.1",
"eslint": "^3.9.1",
"eslint-config-airbnb": "latest",
"eslint-plugin-import": "^2.1.0",
"eslint-plugin-jsx-a11y": "^2.2.3",
"eslint-plugin-react": "^6.6.0",
"expect": "^1.20.2",
"gitbook-cli": "^2.3.0",
"karma": "^1.3.0",
Expand Down
15 changes: 7 additions & 8 deletions specs/spec_index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
const testsContext = require.context('.', true, /spec$/);
testsContext.keys().forEach(function(path) {
try {
testsContext(path);
} catch(err) {
debugger
console.error(`[ERROR] WITH SPEC FILE: ${path}`);
console.error(err);
}
testsContext.keys().forEach((path) => {
try {
testsContext(path);
} catch (err) {
console.error(`[ERROR] WITH SPEC FILE: ${path}`);
console.error(err);
}
});
3 changes: 2 additions & 1 deletion webpack.test.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
var commonConfig = require('./webpack.config');
const commonConfig = require('./webpack.config');

commonConfig.plugins = [];
commonConfig.entry = undefined;
commonConfig.debug = true;
commonConfig.devtool = 'inline-source-map';

module.exports = commonConfig;
Loading

0 comments on commit 1c326a1

Please sign in to comment.