Skip to content
This repository has been archived by the owner on Sep 25, 2019. It is now read-only.

Non-intrusive ESLint messages while in development 🕺 #386

Merged
merged 2 commits into from
Jul 28, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ matrix:
node_js: 6.11.1

# Test with PhantomJS available
- sudo: false
- dist: precise
sudo: false
env:
- TEST_TYPE=integration_test
- BROWSER=PhantomJS
Expand Down
6 changes: 5 additions & 1 deletion src/configure-webpack/loaders/javascript.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,11 @@ export default {
options: {
configFile: path.join(projectPath, '.eslintrc'),
useEslintrc: false,
cwd: projectPath
cwd: projectPath,

// While in development make the eslint messages non-intrusive
// by turning them all into warnings
emitWarning: action === actions.DEVELOP
}
},
{
Expand Down
15 changes: 15 additions & 0 deletions src/configure-webpack/loaders/javascript.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import path from 'path'
import { expect } from 'chai'
import loader from './javascript'
import actions from '../../actions'

describe('javaScript', () => {
const projectPath = '/tmp/test-project'
Expand All @@ -13,6 +14,20 @@ describe('javaScript', () => {
expect(webpack.module.rules[0].enforce).to.eql('pre')
})

it('should emit all eslint warning/errors as warnings while in developmment', () => {
const projectPath = 'a/demo/path'
const webpack = loader.configure({ projectPath, action: actions.DEVELOP })

expect(webpack.module.rules[0].options.emitWarning).to.eql(true)
})

it('should emit normal eslint errors if not in development', () => {
const projectPath = 'a/demo/path'
const webpack = loader.configure({ projectPath, action: actions.BUILD })

expect(webpack.module.rules[0].options.emitWarning).to.eql(false)
})

it('should only build files inside the src folder by default', () => {
const webpack = loader.configure({ projectPath })
const excludeCheck = webpack.module.rules[1].exclude
Expand Down