Browse Source

rig up eslint, do some linting

contingency-plan
Rich Harris 10 years ago
parent
commit
5cbd7afb1a
  1. 19
      .eslintrc
  2. 10
      .jshintrc
  3. 4
      package.json
  4. 9
      src/Module.js
  5. 2
      src/ast/Scope.js
  6. 2
      src/finalisers/es6.js
  7. 2
      src/utils/normalizePlatform.js

19
.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
}
}

10
.jshintrc

@ -1,10 +0,0 @@
{
"esnext": true,
"undef": true,
"unused": true,
"globals": {
"process": true,
"module": true,
"assert": true
}
}

4
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",

9
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' ) ) {

2
src/ast/Scope.js

@ -48,7 +48,7 @@ export default class Scope {
}
findDefiningScope ( name ) {
if ( !!this.declarations[ name ] ) {
if ( this.declarations[ name ] ) {
return this;
}

2
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 = [];

2
src/utils/normalizePlatform.js

@ -1,3 +1,3 @@
export function unixizePath( path ) {
export function unixizePath ( path ) {
return path.split( /[\/\\]/ ).join( '/' );
}

Loading…
Cancel
Save