Skip to content

Commit

Permalink
Merge pull request #10 from zawislakdawidj/dev/no-unused-variables
Browse files Browse the repository at this point in the history
Typescript noUnusedLocals & noUnusedParameters set
  • Loading branch information
chuanqisun committed Mar 14, 2019
2 parents d2fb5fa + 7947e42 commit c39c73e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
12 changes: 6 additions & 6 deletions src/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export interface SpyFacade<T> {

export declare type Spied<T> = {
[K in keyof T]: SpiedMember;
}
};

export interface SpiedAny {
[id: string]: SpiedMember;
Expand All @@ -30,7 +30,7 @@ class DynamicBase<T extends object> {

// create a spy before it is directly read/written
private stubProxyHandler = {
get: (target: T, propertyName: keyof T, receiver) => {
get: (_target: T, propertyName: keyof T, _receiver) => {
if (propertyName === '_spy') {
return this.spyProxy;
}
Expand All @@ -44,7 +44,7 @@ class DynamicBase<T extends object> {

return this.stub[propertyName];
},
set: (target, propertyName: keyof T, value, receiver) => {
set: (_target, propertyName: keyof T, value, _receiver) => {
if (propertyName === '_spy') {
throw Error('Cannot modify _spy. It is part of the MockFactory');
}
Expand All @@ -68,7 +68,7 @@ class DynamicBase<T extends object> {

// create a spy before it is read from the spyFacade
private spyProxyHanlder = {
get: (target: T, propertyName: keyof T, receiver) => {
get: (_target: T, propertyName: keyof T, _receiver) => {
if (typeof propertyName !== 'string') {
throw Error(`${propertyName.toString()} is a "${typeof propertyName}" named property. Jasmine can only spy "string" so only "string" named properties expose the _spy interface`);
}
Expand All @@ -77,7 +77,7 @@ class DynamicBase<T extends object> {

return this.spy[propertyName];
},
set: (target, propertyName: keyof T, value, receiver) => {
set: (_target, propertyName: keyof T, _value, _receiver) => {
throw Error(`Cannot change _spy.${propertyName.toString()}, because it is part of the MockFactory`);
},
}
Expand Down Expand Up @@ -132,7 +132,7 @@ class DynamicBase<T extends object> {
// we add getters and setters to all properties to make the read and write spy-able
const descriptor = {
get: /* istanbul ignore next: Can't reach. spyOnProperty() requires its presence to install spies */ () => {},
set: /* istanbul ignore next: Can't reach. spyOnProperty() requires its presence to install spies */ (value) => {},
set: /* istanbul ignore next: Can't reach. spyOnProperty() requires its presence to install spies */ (_value) => {},
enumerable: true,
configurable: true, // required by spyOnProperty
};
Expand Down
4 changes: 3 additions & 1 deletion src/tsconfig.spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
"baseUrl": "",
"types": [
"jasmine"
]
],
"noUnusedLocals": false,
"noUnusedParameters": false
},
"files": [
"test.ts"
Expand Down
2 changes: 2 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
"experimentalDecorators": true,
"strictNullChecks": true,
"target": "es5",
"noUnusedLocals": true,
"noUnusedParameters": true,
"typeRoots": [
"node_modules/@types"
],
Expand Down

0 comments on commit c39c73e

Please sign in to comment.