diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 0000000..11f6d54 --- /dev/null +++ b/.eslintrc @@ -0,0 +1,19 @@ +{ + "rules": { + "indent": [ 2, "tab", { "SwitchCase": 1}], + "quotes": [ 2, "single" ], + "linebreak-style": [ 2, "unix" ], + "semi": [ 2, "always" ], + "no-mixed-spaces-and-tabs": [ 2, "smart-tabs" ], + "no-cond-assign": [ 0 ] + }, + "env": { + "es6": true, + "browser": true, + "node": true + }, + "extends": "eslint:recommended", + "ecmaFeatures": { + "modules": true + } +} diff --git a/.jshintrc b/.jshintrc deleted file mode 100644 index f0bfe85..0000000 --- a/.jshintrc +++ /dev/null @@ -1,10 +0,0 @@ -{ - "esnext": true, - "undef": true, - "unused": true, - "globals": { - "process": true, - "module": true, - "assert": true - } -} diff --git a/package.json b/package.json index b68a38d..8ad964e 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,8 @@ "test": "mocha", "pretest": "npm run build", "build": "gobble build -f dist", - "prepublish": "npm test" + "prepublish": "npm test", + "lint": "eslint src" }, "repository": { "type": "git", @@ -33,6 +34,7 @@ "devDependencies": { "babel-core": "^5.5.8", "console-group": "^0.1.2", + "eslint": "^1.1.0", "gobble": "^0.10.1", "gobble-babel": "^5.5.8", "gobble-browserify": "^0.6.1", diff --git a/src/Module.js b/src/Module.js index 9790351..008051a 100644 --- a/src/Module.js +++ b/src/Module.js @@ -554,7 +554,7 @@ export default class Module { // remove the leading var/let/const this.magicString.remove( node.start, node.declarations[0].start ); - node.declarations.forEach( ( declarator, i ) => { + node.declarations.forEach( declarator => { const { start, end } = declarator; const syntheticNode = { @@ -608,10 +608,7 @@ export default class Module { render ( allBundleExports, format ) { let magicString = this.magicString.clone(); - let previousIndex = -1; - let previousMargin = 0; - - this.statements.forEach( ( statement, i ) => { + this.statements.forEach( statement => { if ( !statement.isIncluded ) { magicString.remove( statement.start, statement.next ); return; @@ -623,7 +620,7 @@ export default class Module { if ( statement.node.specifiers.length ) { magicString.remove( statement.start, statement.next ); return; - }; + } // skip `export var foo;` if foo is exported if ( isEmptyExportedVarDeclaration( statement.node.declaration, statement.module, allBundleExports, format === 'es6' ) ) { diff --git a/src/ast/Scope.js b/src/ast/Scope.js index 8dd054a..d9bfae8 100644 --- a/src/ast/Scope.js +++ b/src/ast/Scope.js @@ -48,7 +48,7 @@ export default class Scope { } findDefiningScope ( name ) { - if ( !!this.declarations[ name ] ) { + if ( this.declarations[ name ] ) { return this; } diff --git a/src/finalisers/es6.js b/src/finalisers/es6.js index d70283f..85c25ce 100644 --- a/src/finalisers/es6.js +++ b/src/finalisers/es6.js @@ -1,6 +1,6 @@ import { keys } from '../utils/object'; -export default function es6 ( bundle, magicString, { exportMode }, options ) { +export default function es6 ( bundle, magicString ) { const importBlock = bundle.externalModules .map( module => { const specifiers = []; diff --git a/src/utils/normalizePlatform.js b/src/utils/normalizePlatform.js index c16edaa..5c8fd33 100644 --- a/src/utils/normalizePlatform.js +++ b/src/utils/normalizePlatform.js @@ -1,3 +1,3 @@ -export function unixizePath( path ) { - return path.split( /[\/\\]/ ).join( '/' ); +export function unixizePath ( path ) { + return path.split( /[\/\\]/ ).join( '/' ); }