Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add eslint and apply initial rules #21

Merged
merged 1 commit into from
Oct 14, 2016
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
16 changes: 16 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
root = true

[*]
indent_style = space
indent_size = 2
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
max_line_length = 80

[*.json]
indent_style = space
indent_size = 2

[*.md]
trim_trailing_whitespace = false
12 changes: 12 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"parser": "babel-eslint",
"env": {
"node": true
},
"rules": {
"indent": ["error", 2, { "SwitchCase": 1 }],
"semi": ["error", "always"],
"comma-dangle": ["error", "always-multiline"],
"quotes": ["error", "single", { "allowTemplateLiterals": true }]
}
}
1 change: 0 additions & 1 deletion app/car.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,3 @@ export class SportsCar {
console.log(
new SportsCar(new V8Engine()).toString()
);

19 changes: 9 additions & 10 deletions app/car.spec.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@

import {V6Engine, V8Engine, getVersion} from './engine';

import {SportsCar} from './car';
import { V6Engine, V8Engine, getVersion } from './engine';
import { SportsCar } from './car';

describe('Car - ',() => {
it('should have a V8 Engine',() => {
it('should have a V8 Engine',() => {
let car = new SportsCar(new V8Engine());
expect(car.toString()).toBe('V8 Sports Car')
})
expect(car.toString()).toBe('V8 Sports Car');
});

it('should have a V6 Engine',() => {
it('should have a V6 Engine',() => {
let car = new SportsCar(new V6Engine());
expect(car.toString()).toBe('V6 Sports Car')
})
})
expect(car.toString()).toBe('V6 Sports Car');
});
});
2 changes: 1 addition & 1 deletion app/engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ export class V8Engine {

export function getVersion() {
return '1.0';
}
}
28 changes: 13 additions & 15 deletions app/engine.spec.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
import {V6Engine, V8Engine, getVersion} from './engine';
import { V6Engine, V8Engine, getVersion } from './engine';

describe('Engine - ',() => {
it('should have a v6 engine', () => {
let v6 = new V6Engine();
expect(v6.toString()).toBe('V6');
})
it('should have a v6 engine', () => {
let v6 = new V6Engine();
expect(v6.toString()).toBe('V6');
});

it('should have a v8 engine', () => {
let v8 = new V8Engine();
expect(v8.toString()).toBe('V8');
})
it('should have a v8 engine', () => {
let v8 = new V8Engine();
expect(v8.toString()).toBe('V8');
});

it('should get version', () => {
expect(getVersion()).toBe('1.0');
})


})
it('should get version', () => {
expect(getVersion()).toBe('1.0');
});
});
8 changes: 3 additions & 5 deletions custom-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ module.exports = loader;
// The simplest loaders are functions which take a files source (as raw string)
// and return the modified source. This is a great starting place to learn to use loaders.
function loader(source) {
debugger;


return source;
}
debugger;
return source;
}
6 changes: 3 additions & 3 deletions e2e.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe('Webpack Dev Kit - Dev Script', () => {
npmTask = child.spawn('npm', ['run', 'dev']);
let run = false; //make sure to only call done once
npmTask.stdout.on('data', (data) => {
//search for 'bundle valid' string to make sure it's finished running
//search for 'bundle valid' string to make sure it's finished running
let str = data.toString();
if (str.indexOf('webpack: bundle is now VALID.') !== -1) {
if (!run) {
Expand All @@ -44,7 +44,7 @@ describe('Webpack Dev Kit - Dev Script', () => {
npmTask.kill();
done();
});
})
});

it('should have the title "Webpack Developer Kit"', (done) => {
expect($('title').text()).toBe('Webpack Developer Kit');
Expand All @@ -55,4 +55,4 @@ describe('Webpack Dev Kit - Dev Script', () => {
expect($('script').attr('src')).toBe('car.bundle.js');
done();
});
});
});
9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"scripts": {
"dev": "webpack-dev-server --inline --content-base build/",
"build": "rimraf ./dist && webpack --config webpack.config.js",
"test:unit":"jest",
"lint": "eslint .",
"test:unit": "jest",
"test:e2e": "jasmine e2e.spec.js",
"debug": "node --inspect --debug-brk ./node_modules/webpack/bin/webpack.js --config webpack.config.js"
},
Expand All @@ -26,12 +27,13 @@
"email": "[email protected]"
},
"license": "MIT",
"jest":{
"rootDir":"./app/"
"jest": {
"rootDir": "./app/"
},
"dependencies": {},
"devDependencies": {
"babel-core": "^6.14.0",
"babel-eslint": "^7.0.0",
"babel-loader": "^6.2.5",
"babel-preset-es2015": "^6.14.0",
"babel-preset-latest": "^6.14.0",
Expand All @@ -40,6 +42,7 @@
"cheerio": "0.22.0",
"chromedriver": "2.24.1",
"enhanced-resolve": "^2.3.0",
"eslint": "^3.7.1",
"html-webpack-plugin": "^2.22.0",
"http-server": "^0.9.0",
"jasmine": "2.5.2",
Expand Down
44 changes: 22 additions & 22 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,58 +9,58 @@ const path = require('path');

module.exports = {
entry: {
'car': ['./app/car.js']
'car': ['./app/car.js'],
},
output: {
path: path.join(__dirname,'/dist'),
filename: '[name].bundle.js'
filename: '[name].bundle.js',
},
module: {
rules: [
// We are chianing the custom loader to babel loader.
// We are chianing the custom loader to babel loader.
// Purely optional but know that the `first` loader in the chain (babel in this case)
// must always return JavaScript (as it is then processed into the compilation)
{
test: /\.js$/,
test: /\.js$/,
oneOf: [
{
{
loaders: [
'babel',
'custom-loader'
]
}
]
}
]
'babel',
'custom-loader',
],
},
],
},
],
},
// This allows us to add resolving functionality for our custom loader
// It's used just like the resolve property and we are referencing the
// It's used just like the resolve property and we are referencing the
// custom loader file.
resolveLoader: {
alias: {
"custom-loader": require.resolve('./custom-loader')
}
'custom-loader': require.resolve('./custom-loader'),
},
},
plugins: [
// This function is the `apply` function if you were to create an external plugin
// Having it inline provides some nice conviences for debugging and development
function() {
var compiler = this;
compiler.plugin("compilation", function(compilation) {
compilation.plugin("after-optimize-modules", function(modules) {
compiler.plugin('compilation', function(compilation) {
compilation.plugin('after-optimize-modules', function(modules) {
// debugger;
});
compilation.plugin("after-optimize-chunks", function(chunks) {
compilation.plugin('after-optimize-chunks', function(chunks) {
// debugger;
});
});
},
new HtmlWebpackPlugin({
template: './app/index.html'
})
template: './app/index.html',
}),
],
resolve: {
extensions: ['.js']
extensions: ['.js'],
},
devtool: false
devtool: false,
};