Skip to content

Commit 8757c22

Browse files
committed
Upgrade webpack to 3.x and optimize babel, karma, eslint configurations
1 parent 8090c1a commit 8757c22

File tree

13 files changed

+150
-202
lines changed

13 files changed

+150
-202
lines changed

.babelrc

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,23 @@
11
{
2-
presets: ['es2015'],
3-
plugins: ['transform-runtime']
4-
}
2+
presets: [
3+
['env', {
4+
modules: false,
5+
targets: {
6+
browsers: [
7+
'> 1%',
8+
'last 1 versions',
9+
'last 4 Android versions',
10+
'last 3 iOS versions'
11+
]
12+
}
13+
}],
14+
'stage-2'
15+
],
16+
plugins: ['transform-runtime'],
17+
env: {
18+
test: {
19+
presets: ['env', 'stage-2'],
20+
plugins: ['istanbul']
21+
}
22+
}
23+
}

.eslintignore

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/node_modules/
21
/karma.conf.js
32
/webpack.config.js
4-
/dist/
5-
/example/
3+
/dist/*.js

.eslintrc.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
root: true
3+
extends: airbnb-base
4+
parser: babel-eslint
5+
parserOptions:
6+
ecmaVersion: 6
7+
sourceType: module
8+
ecmaFeatures:
9+
impliedStrict: true
10+
env:
11+
browser: true
12+
plugins:
13+
- html
14+
settings:
15+
import/resolver:
16+
webpack:
17+
config: ./webpack.config.js
18+
rules:
19+
import/extensions:
20+
- error
21+
- always
22+
-
23+
js: never
24+
vue: never

example/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<meta charset="UTF-8">
55
<title>vue-infinite-loading</title>
6-
<script src="../node_modules/vue/dist/vue.min.js"></script>
6+
<script src="../node_modules/vue/dist/vue.js"></script>
77
<script src="../dist/vue-infinite-loading.js"></script>
88
<style>
99
body{

karma.conf.js

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,19 @@
1-
var webpackConfig = require('./webpack.config');
2-
delete webpackConfig.entry;
3-
4-
// Add code coverage loader
5-
webpackConfig.vue = {
6-
loaders: {
7-
js: 'isparta'
8-
}
9-
}
1+
const path = require('path');
2+
const webpackConfig = require('./webpack.config');
103

11-
// remove eslint
12-
delete webpackConfig.module.preLoaders;
4+
delete webpackConfig.entry;
135

146
// Karma configuration
157
module.exports = function(config) {
168
config.set({
17-
// frameworks to use
18-
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
199
frameworks: ['mocha', 'chai'],
20-
// list of files / patterns to load in the browser
2110
files: [
2211
'./test/unit/index.js'
2312
],
24-
// preprocess matching files before serving them to the browser
25-
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
2613
preprocessors: {
2714
'./test/unit/index.js': 'webpack'
2815
},
29-
// start these browsers
30-
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
3116
browsers: ['PhantomJS'],
32-
// test results reporter to use
33-
// possible values: 'dots', 'progress'
34-
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
3517
reporters: ['spec', 'coverage'],
3618
coverageReporter: {
3719
dir: './test/unit/coverage',
@@ -43,6 +25,7 @@ module.exports = function(config) {
4325
webpack: webpackConfig,
4426
webpackMiddleware: {
4527
noInfo: true
46-
}
28+
},
29+
singleRun: true
4730
});
4831
}

package.json

Lines changed: 44 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
"email": "[email protected]"
1313
},
1414
"scripts": {
15-
"dev": "webpack-dev-server --inline --hot --quiet --port=8000",
16-
"build": "NODE_ENV=production webpack --progress --hide-modules",
17-
"test": "karma start --single-run",
18-
"lint": "eslint './src/**(vue|js)'",
15+
"dev": "webpack-dev-server --hot --info=false --port 8000",
16+
"build": "NODE_ENV=production webpack -p --progress --hide-modules",
17+
"lint": "eslint --ext .js,.vue src",
18+
"test": "BABEL_ENV=test karma start",
1919
"release": "bash ./release.sh"
2020
},
2121
"keywords": [
@@ -34,49 +34,55 @@
3434
},
3535
"homepage": "https://github.com/PeachScript/vue-infinite-loading",
3636
"devDependencies": {
37-
"babel-core": "^6.7.7",
38-
"babel-loader": "^6.2.4",
39-
"babel-plugin-transform-runtime": "^6.7.5",
40-
"babel-preset-es2015": "^6.6.0",
41-
"babel-runtime": "^6.0.0",
42-
"chai": "^3.5.0",
43-
"css-loader": "^0.23.1",
44-
"eslint": "^3.3.1",
45-
"eslint-config-airbnb-base": "^5.0.2",
46-
"eslint-loader": "^1.3.0",
47-
"eslint-plugin-html": "^1.4.0",
48-
"eslint-plugin-import": "^1.6.1",
49-
"file-loader": "^0.9.0",
50-
"html-webpack-plugin": "^2.16.0",
51-
"isparta-loader": "^2.0.0",
52-
"karma": "^1.2.0",
37+
"autoprefixer": "^7.1.2",
38+
"babel-core": "^6.25.0",
39+
"babel-eslint": "^7.2.3",
40+
"babel-loader": "^7.1.1",
41+
"babel-plugin-istanbul": "^4.1.4",
42+
"babel-plugin-transform-runtime": "^6.23.0",
43+
"babel-preset-env": "^1.6.0",
44+
"babel-preset-stage-2": "^6.24.1",
45+
"chai": "^4.1.1",
46+
"css-loader": "^0.28.4",
47+
"eslint": "^4.4.1",
48+
"eslint-config-airbnb-base": "^11.3.1",
49+
"eslint-friendly-formatter": "^3.0.0",
50+
"eslint-import-resolver-webpack": "^0.8.3",
51+
"eslint-loader": "^1.9.0",
52+
"eslint-plugin-html": "^3.2.0",
53+
"eslint-plugin-import": "^2.7.0",
54+
"html-webpack-plugin": "^2.30.1",
55+
"karma": "^1.7.0",
5356
"karma-chai": "^0.1.0",
54-
"karma-coverage": "^1.0.0",
55-
"karma-mocha": "^1.0.1",
56-
"karma-phantomjs-launcher": "^1.0.0",
57-
"karma-spec-reporter": "0.0.26",
58-
"karma-webpack": "^1.7.0",
59-
"less": "^2.6.1",
60-
"less-loader": "^2.2.3",
61-
"mocha": "^3.0.2",
62-
"phantomjs-prebuilt": "^2.1.7",
57+
"karma-coverage": "^1.1.1",
58+
"karma-mocha": "^1.3.0",
59+
"karma-phantomjs-launcher": "^1.0.4",
60+
"karma-spec-reporter": "0.0.31",
61+
"karma-webpack": "^2.0.4",
62+
"less": "^2.7.2",
63+
"less-loader": "^4.0.5",
64+
"mocha": "^3.5.0",
65+
"phantomjs-prebuilt": "^2.1.15",
6366
"pre-commit": "^1.2.2",
64-
"style-loader": "^0.13.1",
65-
"url-loader": "^0.5.7",
67+
"style-loader": "^0.18.2",
68+
"uglifyjs-webpack-plugin": "^0.4.6",
6669
"vue": "^2.2.0",
67-
"vue-hot-reload-api": "^1.3.3",
68-
"vue-html-loader": "^1.2.2",
69-
"vue-loader": "^10.0.0",
70-
"vue-style-loader": "^1.0.0",
71-
"vue-template-compiler": "^2.2.0",
72-
"webpack": "^1.13.0",
73-
"webpack-dev-server": "^1.14.1"
70+
"vue-loader": "^13.0.4",
71+
"vue-template-compiler": "^2.4.2",
72+
"webpack": "^3.5.4",
73+
"webpack-dev-server": "^2.7.1"
7474
},
7575
"peerDependencies": {
7676
"vue": "^2.2.0"
7777
},
7878
"license": "MIT",
7979
"pre-commit": [
8080
"lint"
81+
],
82+
"browserslist": [
83+
"> 1%",
84+
"last 1 versions",
85+
"last 4 Android versions",
86+
"last 3 iOS versions"
8187
]
8288
}

src/.eslintrc.json

Lines changed: 0 additions & 16 deletions
This file was deleted.

src/components/InfiniteLoading.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@
5353
} else {
5454
const infiniteElmOffsetTopFromBottom = infiniteElm.getBoundingClientRect().top;
5555
const scrollElmOffsetTopFromBottom = scrollElm === window ?
56-
window.innerHeight :
57-
scrollElm.getBoundingClientRect().bottom;
56+
window.innerHeight :
57+
scrollElm.getBoundingClientRect().bottom;
5858
5959
distance = infiniteElmOffsetTopFromBottom - scrollElmOffsetTopFromBottom;
6060
}

test/unit/.eslintrc.json

Lines changed: 0 additions & 23 deletions
This file was deleted.

test/unit/.eslintrc.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
env:
3+
mocha: true
4+
globals:
5+
expect: true
6+
rules:
7+
no-unused-expressions: 0

0 commit comments

Comments
 (0)