Browse Source

linting

rewrite
Rich Harris 8 years ago
parent
commit
ad4ca750a5
  1. 5
      .eslintrc
  2. 2
      src/ast/nodes/AssignmentExpression.js
  3. 2
      src/ast/nodes/ClassDeclaration.js
  4. 4
      src/ast/nodes/ExportAllDeclaration.js
  5. 28
      src/ast/nodes/ExportDefaultDeclaration.js
  6. 2
      src/ast/nodes/FunctionDeclaration.js
  7. 12
      src/ast/nodes/shared/isUsedByBundle.js
  8. 2
      src/utils/path.js

5
.eslintrc

@ -35,5 +35,10 @@
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module"
},
"settings": {
"import/ignore": [ 0, [
"\\.path.js$"
] ]
}
}

2
src/ast/nodes/AssignmentExpression.js

@ -1,7 +1,7 @@
import Node from '../Node.js';
import disallowIllegalReassignment from './shared/disallowIllegalReassignment.js';
import isUsedByBundle from './shared/isUsedByBundle.js';
import { NUMBER, STRING, UNKNOWN } from '../values.js';
import { NUMBER, STRING } from '../values.js';
export default class AssignmentExpression extends Node {
bind ( scope ) {

2
src/ast/nodes/ClassDeclaration.js

@ -9,7 +9,7 @@ export default class ClassDeclaration extends Node {
this.body.run();
}
addReference ( reference ) {
addReference () {
/* noop? */
}

4
src/ast/nodes/ExportAllDeclaration.js

@ -1,11 +1,11 @@
import Node from '../Node.js';
export default class ExportAllDeclaration extends Node {
initialise ( scope ) {
initialise () {
this.isExportDeclaration = true;
}
render ( code, es ) {
render ( code ) {
code.remove( this.leadingCommentStart || this.start, this.next || this.end );
}
}

28
src/ast/nodes/ExportDefaultDeclaration.js

@ -2,34 +2,6 @@ import Node from '../Node.js';
const functionOrClassDeclaration = /^(?:Function|Class)Declaration/;
class SyntheticDefaultDeclaration {
constructor ( node, name ) {
this.node = node;
this.name = name;
this.isDefault = true;
}
activate () {
if ( this.activated ) return;
this.activated = true;
this.node.run();
}
addReference ( reference ) {
this.name = reference.name;
if ( this.original ) this.original.addReference( reference );
}
render ( es ) {
if ( this.original && !this.original.isReassigned ) {
return this.original.getName( es );
}
return this.name;
}
}
export default class ExportDefaultDeclaration extends Node {
initialise ( scope ) {
this.isExportDeclaration = true;

2
src/ast/nodes/FunctionDeclaration.js

@ -10,7 +10,7 @@ export default class FunctionDeclaration extends Node {
this.body.run();
}
addReference ( reference ) {
addReference () {
/* noop? */
}

12
src/ast/nodes/shared/isUsedByBundle.js

@ -1,17 +1,9 @@
import {
ARRAY,
BOOLEAN,
FUNCTION,
NUMBER,
OBJECT,
STRING,
UNKNOWN
} from '../../values.js';
import { UNKNOWN } from '../../values.js';
export default function isUsedByBundle ( scope, node ) {
while ( node.type === 'ParenthesizedExpression' ) node = node.expression;
const expression = node;
// const expression = node;
while ( node.type === 'MemberExpression' ) node = node.object;
const declaration = scope.findDeclaration( node.name );

2
src/utils/path.js

@ -13,4 +13,4 @@ export function normalize ( path ) {
return path.replace( /\\/g, '/' );
}
export * from 'path';
export { basename, dirname, extname, relative, resolve } from 'path';

Loading…
Cancel
Save