Skip to content

Commit

Permalink
Add linting tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
constgen committed Jul 27, 2017
1 parent 1a45500 commit 6d63925
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 27 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/src/polyfills.js
/*.*
26 changes: 21 additions & 5 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,32 @@
"node": true
},
"extends": "eslint:recommended",
"parserOptions": {
"sourceType": "module"
},
"rules": {
"comma-dangle": ["error", "never"],
"indent": ["error", "tab"],
"indent": ["error", "tab", {"MemberExpression": "off"}],
"linebreak-style": ["error", "unix"],
"quotes": ["error", "single"],
"semi": ["error", "never"],
"no-unused-vars": ["warn"],
"no-console": 0
"no-console": ["warn", { "allow": ["error"] }],
"eqeqeq": ["error", "always"],
"getter-return": ["error"],
"id-length": "error",
"no-eval": "error",
"no-trailing-spaces": "error",
"no-with": "error",
"no-unused-expressions": ["error", { "allowShortCircuit": true, "allowTernary": true, "allowTaggedTemplates": true }],
"strict": ["warn", "safe"],
"curly": ["error", "multi-line"],
"unicode-bom": ["error", "never"],
"vars-on-top": "error",
"max-len": [1, 120, 2, { "ignoreComments": true }],
"quote-props": [1, "consistent-as-needed"],
"no-cond-assign": [2, "except-parens"],
"space-infix-ops": 0,
"default-case": 0,
"no-else-return": 0,
"no-param-reassign": 0,
"new-cap": 2
}
}
10 changes: 7 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,18 @@
},
"homepage": "https://github.com/constgen/neutrino-preset-svelte",
"keywords": [
"svelte",
"neutrino",
"preset",
"svelte",
"neutrino-preset",
"webpack"
],
"scripts": {
"test": "npm run lint",
"lint": "eslint --ext .js src/ "
},
"dependencies": {
"svelte": "~1.26.0",
"svelte": "~1.26.1",
"neutrino-middleware-svelte-loader": "~3.1.0",
"neutrino-middleware-chunk": "~6.1.4",
"neutrino-middleware-clean": "~6.1.4",
Expand Down Expand Up @@ -48,7 +52,7 @@
"ip": "~1.1.5"
},
"devDependencies": {
"eslint": "^3.19.0"
"eslint": "^4.3.0"
},
"peerDependencies": {
"neutrino": "^6.0.0"
Expand Down
20 changes: 10 additions & 10 deletions src/dev-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ module.exports = function (neutrino, options = {}) {
let publicHost = ip.address('public', 'ipv4')

config.devServer
.host(host)
.port(Number(port))
.https(Boolean(https))
.contentBase(contentBase)
.historyApiFallback(true)
.host(host)
.port(Number(port))
.https(Boolean(https))
.contentBase(contentBase)
.historyApiFallback(true)
.hot(true)
.headers({
host: publicHost
})
.public(publicHost) //.public(`${publicHost}:${port}`)
.public(publicHost) //.public(`${publicHost}:${port}`)
.publicPath('/')
.stats({
assets: false,
Expand All @@ -54,8 +54,8 @@ module.exports = function (neutrino, options = {}) {
opn(`${protocol}://${localHost}:${port}`)
})
})
.end()
.entry('index')
.prepend(require.resolve('webpack/hot/dev-server'))
.prepend(`${require.resolve('webpack-dev-server/client')}?${protocol}://${host}:${port}`)
.end()
.entry('index')
.prepend(require.resolve('webpack/hot/dev-server'))
.prepend(`${require.resolve('webpack-dev-server/client')}?${protocol}://${host}:${port}`)
}
8 changes: 4 additions & 4 deletions src/html-template.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ module.exports = function (neutrino, options = {}) {
inject: 'head',
mobile: true,
minify: {
collapseWhitespace: true,
collapseWhitespace: true,
preserveLineBreaks: true
},
chunksSortMode: function(a, b){
let aIndex = chunkOrder.indexOf(a.names[0])
let bIndex = chunkOrder.indexOf(b.names[0])
chunksSortMode: function(aChunk, bChunk){
let aIndex = chunkOrder.indexOf(aChunk.names[0])
let bIndex = chunkOrder.indexOf(bChunk.names[0])
if (aIndex < 0) {
return 1
}
Expand Down
10 changes: 5 additions & 5 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ module.exports = function (neutrino, options = {}) {
neutrino.use(env)
neutrino.use(babel, {
include: [
neutrino.options.source,
neutrino.options.tests,
neutrino.options.source,
neutrino.options.tests,
require.resolve('./polyfills.js')
],
targets: {
Expand All @@ -94,13 +94,13 @@ module.exports = function (neutrino, options = {}) {
neutrino.use(styleLoader)
neutrino.use(fontLoader)
neutrino.use(imageLoader)

if (!testRun) {
neutrino.use(chunk)
}
if (devRun) {
neutrino.use(devServer, options.server)
}
}
else {
neutrino.use(progress)
neutrino.use(clean, { paths: [neutrino.options.output] })
Expand All @@ -115,7 +115,7 @@ module.exports = function (neutrino, options = {}) {
config.output.filename('[name].[chunkhash].bundle.js')
}

if (eslintLoader) {
if (eslintLoader) {
lintRule
.pre()
eslintLoader
Expand Down

0 comments on commit 6d63925

Please sign in to comment.