diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..9d08a1a --- /dev/null +++ b/.editorconfig @@ -0,0 +1,9 @@ +root = true + +[*] +charset = utf-8 +indent_style = space +indent_size = 2 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..4199381 --- /dev/null +++ b/.eslintignore @@ -0,0 +1 @@ +build/*.js diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 0000000..fc965ff --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,14 @@ +module.exports = { + root: true, + env: { + 'browser': true, + 'node': true + }, + parser: 'babel-eslint', + // you could use airbnb or standard, + // extends: 'airbnb', + // add your custom rules here + 'rules': { + + } +} diff --git a/package.json b/package.json index 38ab9b8..6dd662d 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "example": "examples" }, "scripts": { - "start":"webpack-dev-server --inline --progress", + "start": "webpack-dev-server --inline --progress", "build": "webpack" }, "keywords": [ @@ -24,8 +24,11 @@ "devDependencies": { "babel-cli": "^6.14.0", "babel-core": "^6.14.0", + "babel-eslint": "^7.1.1", "babel-loader": "^6.2.5", "babel-preset-es2015": "^6.14.0", + "eslint": "^3.17.0", + "eslint-loader": "^1.6.3", "webpack": "^2.2.1", "webpack-dev-server": "^2.4.1" }, diff --git a/webpack.config.js b/webpack.config.js index fa07cdf..763f645 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,16 +1,35 @@ var path = require('path') +var srcPath = path.resolve(__dirname, './src/') const config = { - entry: './src/framework.js', - output: { - path: path.resolve(__dirname, 'build'), - filename: 'neurojs-v2.js' - }, - // module: { - // loaders: [ - // { test: /\.js$/, exclude: /node_modules/, loader: "babel-loader" } - // ] - // } + entry: './src/framework.js', + output: { + path: path.resolve(__dirname, 'build'), + filename: 'neurojs-v2.js' + }, + module: { + rules: [ + { + test: /\.js$/, + enforce: 'pre', + loader: 'eslint-loader', + exclude: /node_modules/, + include: srcPath + }, + { + test: /\.js$/, + loader: 'babel-loader', + exclude: /node_modules/, + include: srcPath + } + ] + } + // webpack2.2 remove preloader and loader option, use rules. + // module: { + // loaders: [ + // { test: /\.js$/, exclude: /node_modules/, loader: "babel-loader" } + // ] + // } } -module.exports = config \ No newline at end of file +module.exports = config