Skip to content

Commit 0a8f62b

Browse files
committed
Improve linting and testing behavior
1 parent a179cb5 commit 0a8f62b

File tree

6 files changed

+82
-11
lines changed

6 files changed

+82
-11
lines changed

.eslintignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Disable linting in root directory
2+
**/*.js
3+
!src/**/*.js

karma.conf.babel.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import KarmaJunitReporter from 'karma-junit-reporter';
66
import KarmaSourcemapLoader from 'karma-sourcemap-loader';
77
import KarmaPhantomjsLauncher from 'karma-phantomjs-launcher';
88
import KarmaNotifyReporter from 'karma-notify-reporter';
9-
import webpackConfig from './webpack.config.dev.babel';
9+
import webpackConfig from './webpack.config.test.babel';
1010

1111
export default function setConfig(config) {
1212
config.set({
@@ -20,7 +20,6 @@ export default function setConfig(config) {
2020
outputDir: (process.env.CIRCLE_TEST_REPORTS || 'public') + '/karma',
2121
suite: 'karma'
2222
},
23-
singleRun: true,
2423
plugins: [
2524
KarmaCoverage,
2625
KarmaJasmine,
@@ -39,7 +38,7 @@ export default function setConfig(config) {
3938
type: 'json'
4039
},
4140
notifyReporter: {
42-
reportEachFailure: true, // Default: false, Will notify on every failed spec
41+
reportEachFailure: false, // Default: false, Will notify on every failed spec
4342
reportSuccess: false, // Default: true, Will notify when a suite was successful
4443
},
4544
});

package.json

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,11 @@
1111
"clean:umd": "rimraf dist/umd",
1212
"start": "cross-env NODE_ENV=development webpack-dev-server --hot --inline --config webpack.config.dev.babel.js",
1313
"lint": "eslint src",
14-
"prepublish": "npm run lint && npm run build:umd",
14+
"prepublish": "npm run test && npm run build:umd",
1515
"posttest": "[ -z \"$CI\" ] || codecov",
16-
"test": "npm run lint && npm run test:unit",
17-
"test:unit": "cross-env NODE_ENV=test karma start",
18-
"deploy": "npm run build && gh-pages -d build",
19-
"watch": "watch 'clear && npm run test -s' src",
20-
"watch:nolint": "watch 'clear && npm run test:unit' src"
16+
"test": "cross-env NODE_ENV=test karma start --single-run",
17+
"test:watch": "cross-env NODE_ENV=test karma start",
18+
"deploy": "npm run build && gh-pages -d build"
2119
},
2220
"main": "dist/umd/react-sortable-tree.js",
2321
"files": [
@@ -52,6 +50,7 @@
5250
"css-loader": "^0.23.1",
5351
"eslint": "^3.2.2",
5452
"eslint-config-blue-hour": "0.x.x",
53+
"eslint-loader": "^1.5.0",
5554
"eslint-plugin-import": "^1.10.2",
5655
"eslint-plugin-jsx-a11y": "^2.0.1",
5756
"eslint-plugin-react": "^6.0.0",

src/tests.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import Bluebird from 'bluebird';
1+
import Bluebird from 'bluebird'; // eslint-disable-line import/no-extraneous-dependencies
22

33
// Polyfill a full ES6 environment
44
// Reference: https://babeljs.io/docs/usage/polyfill/
55
// Reference: https://github.com/zloirock/core-js
6-
import 'babel-polyfill';
6+
import 'babel-polyfill'; // eslint-disable-line import/no-extraneous-dependencies
77

88
// Replace the scheduler with setImmediate so we can write sync tests
99
Bluebird.setScheduler(fn => {

webpack.config.dev.babel.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ module.exports = {
2525
autoprefixer,
2626
],
2727
module: {
28+
preLoaders: [
29+
{
30+
test: /\.jsx?$/,
31+
loader: 'eslint-loader',
32+
include: path.join(__dirname, 'src')
33+
},
34+
],
2835
loaders: [
2936
{
3037
test: /\.jsx?$/,

webpack.config.test.babel.js

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import HtmlWebpackPlugin from 'html-webpack-plugin';
2+
import path from 'path';
3+
import webpack from 'webpack';
4+
import autoprefixer from 'autoprefixer';
5+
6+
module.exports = {
7+
devtool: 'eval',
8+
entry: {
9+
demo: './src/examples/basicExample/app',
10+
},
11+
output: {
12+
path: 'build',
13+
filename: 'static/[name].js',
14+
},
15+
plugins: [
16+
new HtmlWebpackPlugin({
17+
filename: 'index.html',
18+
inject: true,
19+
template: './src/examples/basicExample/index.html'
20+
}),
21+
new webpack.HotModuleReplacementPlugin(),
22+
],
23+
postcss: [
24+
autoprefixer,
25+
],
26+
module: {
27+
preLoaders: [
28+
{
29+
test: /\.jsx?$/,
30+
loader: 'eslint-loader',
31+
include: path.join(__dirname, 'src')
32+
},
33+
],
34+
loaders: [
35+
{
36+
test: /\.jsx?$/,
37+
loaders: ['react-hot', 'babel'],
38+
include: path.join(__dirname, 'src')
39+
},
40+
{
41+
test: /\.scss$/,
42+
loaders: [
43+
'style-loader',
44+
'css-loader?modules&importLoaders=1&localIdentName=[local]___[hash:base64:5]',
45+
'postcss-loader',
46+
'sass-loader',
47+
],
48+
include: path.join(__dirname, 'src')
49+
},
50+
{
51+
test: /\.(jpe?g|png|gif)$/,
52+
loaders: [
53+
'file-loader?name=static/[name]-[hash:6].[ext]',
54+
],
55+
include: path.join(__dirname, 'src')
56+
},
57+
],
58+
},
59+
devServer: {
60+
contentBase: 'build',
61+
port: 3001
62+
},
63+
};

0 commit comments

Comments
 (0)