Skip to content

Commit

Permalink
Add linting for es/jsx code
Browse files Browse the repository at this point in the history
We want to treat using undefined variables or having unused variables
as errors.

Closes cockpit-project#5800
Reviewed-by: Stef Walter <[email protected]>
  • Loading branch information
dperpeet authored and stefwalter committed Feb 23, 2017
1 parent 4e57831 commit de11477
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules/*
bower_components/*

24 changes: 24 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"env": {
"browser": true,
"es6": true
},
"extends": "eslint:recommended",
"parserOptions": {
"ecmaFeatures": {
"experimentalObjectRestSpread": true,
"jsx": true
},
"sourceType": "module"
},
"plugins": ["react"],
"rules": {
"react/jsx-uses-vars": "error",
"no-console": "off",
"no-undef": "error"
},
"globals": {
"require": false,
"module": false
}
}
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@
"devDependencies": {
"babel-core": "~5.8.38",
"babel-loader": "~5.4.2",
"babel-eslint": "~7.1.1",
"bower": "~1.7.9",
"clean-css": "~3.4.20",
"copy-webpack-plugin": "~3.0.1",
"css-loader": "~0.23.1",
"eslint": "^3.0.0",
"eslint-loader": "~1.6.1",
"eslint-plugin-react": "~6.9.0",
"exports-loader": "~0.6.3",
"extend": "~3.0.0",
"extract-text-webpack-plugin": "~1.0.1",
Expand Down
9 changes: 7 additions & 2 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -390,18 +390,23 @@ module.exports = {
preLoaders: [
{
test: /\.js$/, // include .js files
exclude: /bower_components\/.*\/|\/node_modules\//, // exclude external dependencies
exclude: /bower_components\/.*\/|\/node_modules/, // exclude external dependencies
loader: "jshint-loader"
},
{
test: /\.es6$/, // include .js files
loader: "jshint-loader?esversion=6"
},
{
test: /\.jsx$/,
exclude: /bower_components\/.*\/|\/node_modules/, // exclude external dependencies
loader: "eslint-loader"
}
],
loaders: [
{
test: /\.js$/,
exclude: /bower_components\/.*\//,
exclude: /bower_components\/.*\/|\/node_modules/,
loader: 'strict' // Adds "use strict"
},
{
Expand Down

0 comments on commit de11477

Please sign in to comment.