Skip to content
This repository was archived by the owner on Apr 3, 2024. It is now read-only.

Commit f13d122

Browse files
authored
lint, tooling, and other misc. changes (#304)
* Remove jshint files and devDependency * Update tslint config. Use typechecked lint. Remove options that are subsumed by the compiler now. * Start shipping type definitions. * Address newly found lint errors. * Formatting.
1 parent dd8ef67 commit f13d122

File tree

9 files changed

+53
-104
lines changed

9 files changed

+53
-104
lines changed

.jshintignore

Lines changed: 0 additions & 4 deletions
This file was deleted.

.jshintrc

Lines changed: 0 additions & 27 deletions
This file was deleted.

bin/run-test.sh

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,6 @@ while true; do
1818
shift
1919
done
2020

21-
# Lint
22-
# TODO: Re-enable this when the transition to Typescript is complete
23-
# $(npm bin)/jshint . || exit 1
24-
2521
# Get test/coverage command
2622
counter=0
2723
function run {

gulpfile.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,14 @@ gulp.task('format', () => {
5454
});
5555

5656
gulp.task('test.check-lint', () => {
57+
const program = require('tslint').Linter.createProgram('./tsconfig.json');
5758
return gulp.src(sources)
58-
.pipe(tslint(
59-
{configuration: tslintPath, formatter: 'verbose'}))
60-
.pipe(tslint.report())
59+
.pipe(tslint(
60+
{
61+
configuration: tslintPath,
62+
formatter: 'prose', program
63+
}))
64+
.pipe(tslint.report())
6165
.on('warning', onError);
6266
});
6367

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"author": "Google Inc.",
55
"description": "Stackdriver Debug Agent for Node.js",
66
"main": "./build/src/index.js",
7+
"types": "./build/types/index.d.ts",
78
"repository": "googlecloudplatform/cloud-debug-nodejs",
89
"keywords": [
910
"google",
@@ -41,7 +42,6 @@
4142
"gulp-tslint": "^8.1.1",
4243
"gulp-typescript": "^3.1.6",
4344
"istanbul": "^0.4.1",
44-
"jshint": "^2.7.0",
4545
"merge2": "^1.0.3",
4646
"mocha": "^3.0.0",
4747
"nock": "^9.0.0",
@@ -74,6 +74,7 @@
7474
"CHANGELOG.md",
7575
"LICENSE",
7676
"README.md",
77-
"build/src"
77+
"build/src",
78+
"build/types"
7879
]
7980
}

src/agent/sourcemapper.ts

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -34,27 +34,6 @@ export interface MapInfoOutput {
3434
column?: number;
3535
}
3636

37-
export function create(
38-
sourcemapPaths: string[],
39-
callback: (err: Error|null, mapper?: SourceMapper) => void): void {
40-
const mapper = new SourceMapper();
41-
const callList =
42-
Array.prototype.slice.call(sourcemapPaths).map(function(p: string) {
43-
return function(cb: (err: Error|null) => void) {
44-
processSourcemap(mapper.infoMap_, p, cb);
45-
};
46-
});
47-
48-
async.parallelLimit(callList, 10, function(err) {
49-
if (err) {
50-
return callback(new Error(
51-
'An error occurred while processing the sourcemap files' + err));
52-
}
53-
54-
callback(null, mapper);
55-
});
56-
}
57-
5837
/**
5938
* @param {!Map} infoMap The map that maps input source files to
6039
* SourceMapConsumer objects that are used to calculate mapping information
@@ -236,3 +215,24 @@ export class SourceMapper {
236215
};
237216
}
238217
}
218+
219+
export function create(
220+
sourcemapPaths: string[],
221+
callback: (err: Error|null, mapper?: SourceMapper) => void): void {
222+
const mapper = new SourceMapper();
223+
const callList =
224+
Array.prototype.slice.call(sourcemapPaths).map(function(p: string) {
225+
return function(cb: (err: Error|null) => void) {
226+
processSourcemap(mapper.infoMap_, p, cb);
227+
};
228+
});
229+
230+
async.parallelLimit(callList, 10, function(err) {
231+
if (err) {
232+
return callback(new Error(
233+
'An error occurred while processing the sourcemap files' + err));
234+
}
235+
236+
callback(null, mapper);
237+
});
238+
}

src/agent/state.ts

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,6 @@ const NATIVE_PROPERTY_MESSAGE_INDEX = 1;
4040
const GETTER_MESSAGE_INDEX = 2;
4141
const ARG_LOCAL_LIMIT_MESSAGE_INDEX = 3;
4242

43-
/**
44-
* Captures the stack and current execution state.
45-
*
46-
* @return an object with stackFrames, variableTable, and
47-
* evaluatedExpressions fields
48-
*/
49-
export function capture(
50-
execState: v8Types.ExecutionState, expressions: string[],
51-
config: DebugAgentConfig, v8: v8Types.Debug): apiTypes.Breakpoint {
52-
return (new StateResolver(execState, expressions, config, v8)).capture_();
53-
}
54-
55-
5643
/**
5744
* Checks that the provided expressions will not have side effects and
5845
* then evaluates the expression in the current execution context.
@@ -582,3 +569,15 @@ class StateResolver {
582569
export function testAssert(): void {
583570
assert.equal(0, 1);
584571
}
572+
573+
/**
574+
* Captures the stack and current execution state.
575+
*
576+
* @return an object with stackFrames, variableTable, and
577+
* evaluatedExpressions fields
578+
*/
579+
export function capture(
580+
execState: v8Types.ExecutionState, expressions: string[],
581+
config: DebugAgentConfig, v8: v8Types.Debug): apiTypes.Breakpoint {
582+
return (new StateResolver(execState, expressions, config, v8)).capture_();
583+
}

src/agent/v8debugapi.ts

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,15 @@ export interface V8DebugApi {
6767
numListeners_: () => number;
6868
}
6969

70-
interface BreakPointData {
71-
v8Breakpoint: v8Types.BreakPoint;
72-
// TODO: The code in this method assumes this method exists. Verify that
73-
// is correct.
74-
// TODO: Update this so that `null|` is not needed here.
75-
compile: null|((text: string) => string);
70+
class BreakpointData {
71+
constructor(
72+
public apiBreakpoint: apiTypes.Breakpoint,
73+
public v8Breakpoint: v8Types.BreakPoint,
74+
public parsedCondition: estree.Node,
75+
// TODO: The code in this method assumes that `compile` exists. Verify
76+
// that is correct.
77+
// TODO: Update this so that `null|` is not needed for `compile`.
78+
public compile: null|((src: string) => string)) {}
7679
}
7780

7881
/**
@@ -99,7 +102,7 @@ export function create(
99102
let logger: Logger|null = null;
100103
let config: DebugAgentConfig|null = null;
101104
let fileStats: ScanStats|null = null;
102-
let breakpoints: {[id: string]: BreakPointData} = {};
105+
let breakpoints: {[id: string]: BreakpointData} = {};
103106
let sourcemapper: SourceMapper|null = null;
104107
// Entries map breakpoint id to { enabled: <bool>, listener: <function> }
105108
// TODO: Determine if the listener type is correct
@@ -659,25 +662,6 @@ export function create(
659662
}; // intentional !!
660663
}
661664

662-
class BreakpointData {
663-
apiBreakpoint: apiTypes.Breakpoint;
664-
v8Breakpoint: v8Types.BreakPoint;
665-
parsedCondition: estree.Node;
666-
compile: null|((src: string) => string);
667-
668-
/**
669-
* @constructor
670-
*/
671-
constructor(
672-
apiBreakpoint: apiTypes.Breakpoint, v8Breakpoint: v8Types.BreakPoint,
673-
parsedCondition: estree.Node, compile: null|((src: string) => string)) {
674-
this.apiBreakpoint = apiBreakpoint;
675-
this.v8Breakpoint = v8Breakpoint;
676-
this.parsedCondition = parsedCondition;
677-
this.compile = compile;
678-
}
679-
}
680-
681665
function setErrorStatusAndCallback(
682666
fn: (err: Error|null) => void, breakpoint: apiTypes.Breakpoint,
683667
refersTo: apiTypes.Reference, message: string): void {

tslint.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,18 @@
77
"indent": [true, "spaces"],
88
"jsdoc-format": true,
99
"label-position": true,
10-
"label-undefined": true,
1110
"no-arg": true,
1211
"no-conditional-assignment": true,
1312
"no-construct": true,
1413
"no-debugger": true,
15-
"no-duplicate-key": true,
1614
"no-duplicate-variable": true,
1715
"no-empty": true,
1816
"no-inferrable-types": true,
1917
"no-internal-module": true,
2018
"no-shadowed-variable": true,
2119
"no-switch-case-fall-through": true,
2220
"no-trailing-whitespace": true,
23-
"no-unreachable": true,
2421
"no-unused-expression": true,
25-
"no-unused-variable": true,
2622
"no-use-before-declare": true,
2723
"no-var-keyword": true,
2824
"quotemark": [true, "single"],

0 commit comments

Comments
 (0)