Merge pull request #354 from 0xProject/feature/tslint-config/underscore-protected-members
Modify lint rules to enforce underscore for protected members
This commit is contained in:
@@ -20,6 +20,6 @@ export class {{contractName}}Contract extends BaseContract {
|
|||||||
{{/each}}
|
{{/each}}
|
||||||
constructor(web3ContractInstance: Web3.ContractInstance, defaults: Partial<TxData>) {
|
constructor(web3ContractInstance: Web3.ContractInstance, defaults: Partial<TxData>) {
|
||||||
super(web3ContractInstance, defaults);
|
super(web3ContractInstance, defaults);
|
||||||
classUtils.bindAll(this, ['web3ContractInstance', 'defaults']);
|
classUtils.bindAll(this, ['_web3ContractInstance', '_defaults']);
|
||||||
}
|
}
|
||||||
} // tslint:disable:max-file-line-count
|
} // tslint:disable:max-file-line-count
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ public {{this.name}} = {
|
|||||||
): Promise<{{> return_type outputs=outputs}}> {
|
): Promise<{{> return_type outputs=outputs}}> {
|
||||||
const self = this as {{contractName}}Contract;
|
const self = this as {{contractName}}Contract;
|
||||||
const result = await promisify<{{> return_type outputs=outputs}}>(
|
const result = await promisify<{{> return_type outputs=outputs}}>(
|
||||||
self.web3ContractInstance.{{this.name}}.call,
|
self._web3ContractInstance.{{this.name}}.call,
|
||||||
self.web3ContractInstance,
|
self._web3ContractInstance,
|
||||||
)(
|
)(
|
||||||
{{> params inputs=inputs}}
|
{{> params inputs=inputs}}
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ public {{this.name}} = {
|
|||||||
{{/this.payable}}
|
{{/this.payable}}
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
const self = this as {{contractName}}Contract;
|
const self = this as {{contractName}}Contract;
|
||||||
const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
|
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
|
||||||
txData,
|
txData,
|
||||||
self.{{this.name}}.estimateGasAsync.bind(
|
self.{{this.name}}.estimateGasAsync.bind(
|
||||||
self,
|
self,
|
||||||
@@ -17,7 +17,7 @@ public {{this.name}} = {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
const txHash = await promisify<string>(
|
const txHash = await promisify<string>(
|
||||||
self.web3ContractInstance.{{this.name}}, self.web3ContractInstance,
|
self._web3ContractInstance.{{this.name}}, self._web3ContractInstance,
|
||||||
)(
|
)(
|
||||||
{{> params inputs=inputs}}
|
{{> params inputs=inputs}}
|
||||||
txDataWithDefaults,
|
txDataWithDefaults,
|
||||||
@@ -29,11 +29,11 @@ public {{this.name}} = {
|
|||||||
txData: TxData = {},
|
txData: TxData = {},
|
||||||
): Promise<number> {
|
): Promise<number> {
|
||||||
const self = this as {{contractName}}Contract;
|
const self = this as {{contractName}}Contract;
|
||||||
const txDataWithDefaults = await self.applyDefaultsToTxDataAsync(
|
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
|
||||||
txData,
|
txData,
|
||||||
);
|
);
|
||||||
const gas = await promisify<number>(
|
const gas = await promisify<number>(
|
||||||
self.web3ContractInstance.{{this.name}}.estimateGas, self.web3ContractInstance,
|
self._web3ContractInstance.{{this.name}}.estimateGas, self._web3ContractInstance,
|
||||||
)(
|
)(
|
||||||
{{> params inputs=inputs}}
|
{{> params inputs=inputs}}
|
||||||
txDataWithDefaults,
|
txDataWithDefaults,
|
||||||
@@ -45,7 +45,7 @@ public {{this.name}} = {
|
|||||||
txData: TxData = {},
|
txData: TxData = {},
|
||||||
): string {
|
): string {
|
||||||
const self = this as {{contractName}}Contract;
|
const self = this as {{contractName}}Contract;
|
||||||
const abiEncodedTransactionData = self.web3ContractInstance.{{this.name}}.getData();
|
const abiEncodedTransactionData = self._web3ContractInstance.{{this.name}}.getData();
|
||||||
return abiEncodedTransactionData;
|
return abiEncodedTransactionData;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ export class ContractWrapper {
|
|||||||
this._onLogAddedSubscriptionToken = undefined;
|
this._onLogAddedSubscriptionToken = undefined;
|
||||||
this._onLogRemovedSubscriptionToken = undefined;
|
this._onLogRemovedSubscriptionToken = undefined;
|
||||||
}
|
}
|
||||||
protected unsubscribeAll(): void {
|
protected _unsubscribeAll(): void {
|
||||||
const filterTokens = _.keys(this._filterCallbacks);
|
const filterTokens = _.keys(this._filterCallbacks);
|
||||||
_.each(filterTokens, filterToken => {
|
_.each(filterTokens, filterToken => {
|
||||||
this._unsubscribe(filterToken);
|
this._unsubscribe(filterToken);
|
||||||
|
|||||||
@@ -159,11 +159,11 @@ export class EtherTokenWrapper extends ContractWrapper {
|
|||||||
/**
|
/**
|
||||||
* Cancels all existing subscriptions
|
* Cancels all existing subscriptions
|
||||||
*/
|
*/
|
||||||
public unsubscribeAll(): void {
|
public _unsubscribeAll(): void {
|
||||||
super.unsubscribeAll();
|
super._unsubscribeAll();
|
||||||
}
|
}
|
||||||
private _invalidateContractInstance(): void {
|
private _invalidateContractInstance(): void {
|
||||||
this.unsubscribeAll();
|
this._unsubscribeAll();
|
||||||
this._etherTokenContractsByAddress = {};
|
this._etherTokenContractsByAddress = {};
|
||||||
}
|
}
|
||||||
private async _getEtherTokenContractAsync(etherTokenAddress: string): Promise<EtherTokenContract> {
|
private async _getEtherTokenContractAsync(etherTokenAddress: string): Promise<EtherTokenContract> {
|
||||||
|
|||||||
@@ -678,8 +678,8 @@ export class ExchangeWrapper extends ContractWrapper {
|
|||||||
/**
|
/**
|
||||||
* Cancels all existing subscriptions
|
* Cancels all existing subscriptions
|
||||||
*/
|
*/
|
||||||
public unsubscribeAll(): void {
|
public _unsubscribeAll(): void {
|
||||||
super.unsubscribeAll();
|
super._unsubscribeAll();
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Gets historical logs without creating a subscription
|
* Gets historical logs without creating a subscription
|
||||||
@@ -861,7 +861,7 @@ export class ExchangeWrapper extends ContractWrapper {
|
|||||||
return contractAddress;
|
return contractAddress;
|
||||||
}
|
}
|
||||||
private _invalidateContractInstances(): void {
|
private _invalidateContractInstances(): void {
|
||||||
this.unsubscribeAll();
|
this._unsubscribeAll();
|
||||||
delete this._exchangeContractIfExists;
|
delete this._exchangeContractIfExists;
|
||||||
}
|
}
|
||||||
private async _isValidSignatureUsingContractCallAsync(
|
private async _isValidSignatureUsingContractCallAsync(
|
||||||
|
|||||||
@@ -3,9 +3,9 @@ import * as _ from 'lodash';
|
|||||||
import * as Web3 from 'web3';
|
import * as Web3 from 'web3';
|
||||||
|
|
||||||
export class BaseContract {
|
export class BaseContract {
|
||||||
protected web3ContractInstance: Web3.ContractInstance;
|
protected _web3ContractInstance: Web3.ContractInstance;
|
||||||
protected defaults: Partial<TxData>;
|
protected _defaults: Partial<TxData>;
|
||||||
protected async applyDefaultsToTxDataAsync<T extends TxData|TxDataPayable>(
|
protected async _applyDefaultsToTxDataAsync<T extends TxData|TxDataPayable>(
|
||||||
txData: T,
|
txData: T,
|
||||||
estimateGasAsync?: (txData: T) => Promise<number>,
|
estimateGasAsync?: (txData: T) => Promise<number>,
|
||||||
): Promise<TxData> {
|
): Promise<TxData> {
|
||||||
@@ -15,7 +15,7 @@ export class BaseContract {
|
|||||||
// 3. Gas estimate calculation + safety margin
|
// 3. Gas estimate calculation + safety margin
|
||||||
const removeUndefinedProperties = _.pickBy;
|
const removeUndefinedProperties = _.pickBy;
|
||||||
const txDataWithDefaults = {
|
const txDataWithDefaults = {
|
||||||
...removeUndefinedProperties(this.defaults),
|
...removeUndefinedProperties(this._defaults),
|
||||||
...removeUndefinedProperties(txData as any),
|
...removeUndefinedProperties(txData as any),
|
||||||
// HACK: TS can't prove that T is spreadable.
|
// HACK: TS can't prove that T is spreadable.
|
||||||
// Awaiting https://github.com/Microsoft/TypeScript/pull/13288 to be merged
|
// Awaiting https://github.com/Microsoft/TypeScript/pull/13288 to be merged
|
||||||
@@ -27,7 +27,7 @@ export class BaseContract {
|
|||||||
return txDataWithDefaults;
|
return txDataWithDefaults;
|
||||||
}
|
}
|
||||||
constructor(web3ContractInstance: Web3.ContractInstance, defaults: Partial<TxData>) {
|
constructor(web3ContractInstance: Web3.ContractInstance, defaults: Partial<TxData>) {
|
||||||
this.web3ContractInstance = web3ContractInstance;
|
this._web3ContractInstance = web3ContractInstance;
|
||||||
this.defaults = defaults;
|
this._defaults = defaults;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -342,8 +342,8 @@ export class TokenWrapper extends ContractWrapper {
|
|||||||
/**
|
/**
|
||||||
* Cancels all existing subscriptions
|
* Cancels all existing subscriptions
|
||||||
*/
|
*/
|
||||||
public unsubscribeAll(): void {
|
public _unsubscribeAll(): void {
|
||||||
super.unsubscribeAll();
|
super._unsubscribeAll();
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Gets historical logs without creating a subscription
|
* Gets historical logs without creating a subscription
|
||||||
@@ -374,7 +374,7 @@ export class TokenWrapper extends ContractWrapper {
|
|||||||
return logs;
|
return logs;
|
||||||
}
|
}
|
||||||
private _invalidateContractInstances(): void {
|
private _invalidateContractInstances(): void {
|
||||||
this.unsubscribeAll();
|
this._unsubscribeAll();
|
||||||
this._tokenContractsByAddress = {};
|
this._tokenContractsByAddress = {};
|
||||||
}
|
}
|
||||||
private async _getTokenContractAsync(tokenAddress: string): Promise<TokenContract> {
|
private async _getTokenContractAsync(tokenAddress: string): Promise<TokenContract> {
|
||||||
|
|||||||
@@ -144,7 +144,7 @@ describe('EtherTokenWrapper', () => {
|
|||||||
etherTokenAddress = etherToken.address;
|
etherTokenAddress = etherToken.address;
|
||||||
});
|
});
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
zeroEx.etherToken.unsubscribeAll();
|
zeroEx.etherToken._unsubscribeAll();
|
||||||
});
|
});
|
||||||
// Hack: Mocha does not allow a test to be both async and have a `done` callback
|
// Hack: Mocha does not allow a test to be both async and have a `done` callback
|
||||||
// Since we need to await the receipt of the event in the `subscribe` callback,
|
// Since we need to await the receipt of the event in the `subscribe` callback,
|
||||||
|
|||||||
@@ -921,7 +921,7 @@ describe('ExchangeWrapper', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
afterEach(async () => {
|
afterEach(async () => {
|
||||||
zeroEx.exchange.unsubscribeAll();
|
zeroEx.exchange._unsubscribeAll();
|
||||||
});
|
});
|
||||||
// Hack: Mocha does not allow a test to be both async and have a `done` callback
|
// Hack: Mocha does not allow a test to be both async and have a `done` callback
|
||||||
// Since we need to await the receipt of the event in the `subscribe` callback,
|
// Since we need to await the receipt of the event in the `subscribe` callback,
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ describe('SubscriptionTest', () => {
|
|||||||
tokenAddress = token.address;
|
tokenAddress = token.address;
|
||||||
});
|
});
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
zeroEx.token.unsubscribeAll();
|
zeroEx.token._unsubscribeAll();
|
||||||
_.each(stubs, s => s.restore());
|
_.each(stubs, s => s.restore());
|
||||||
stubs = [];
|
stubs = [];
|
||||||
});
|
});
|
||||||
@@ -76,7 +76,7 @@ describe('SubscriptionTest', () => {
|
|||||||
const callback = (err: Error | null, logEvent?: DecodedLogEvent<ApprovalContractEventArgs>) => _.noop;
|
const callback = (err: Error | null, logEvent?: DecodedLogEvent<ApprovalContractEventArgs>) => _.noop;
|
||||||
zeroEx.token.subscribe(tokenAddress, TokenEvents.Approval, indexFilterValues, callback);
|
zeroEx.token.subscribe(tokenAddress, TokenEvents.Approval, indexFilterValues, callback);
|
||||||
stubs = [Sinon.stub((zeroEx as any)._web3Wrapper, 'getBlockAsync').throws(new Error('JSON RPC error'))];
|
stubs = [Sinon.stub((zeroEx as any)._web3Wrapper, 'getBlockAsync').throws(new Error('JSON RPC error'))];
|
||||||
zeroEx.token.unsubscribeAll();
|
zeroEx.token._unsubscribeAll();
|
||||||
done();
|
done();
|
||||||
})().catch(done);
|
})().catch(done);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -377,7 +377,7 @@ describe('TokenWrapper', () => {
|
|||||||
tokenAddress = token.address;
|
tokenAddress = token.address;
|
||||||
});
|
});
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
zeroEx.token.unsubscribeAll();
|
zeroEx.token._unsubscribeAll();
|
||||||
});
|
});
|
||||||
// Hack: Mocha does not allow a test to be both async and have a `done` callback
|
// Hack: Mocha does not allow a test to be both async and have a `done` callback
|
||||||
// Since we need to await the receipt of the event in the `subscribe` callback,
|
// Since we need to await the receipt of the event in the `subscribe` callback,
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
# CHANGELOG
|
# CHANGELOG
|
||||||
|
|
||||||
## v0.2.0 - _???_
|
## v0.2.0 - _???_
|
||||||
|
|
||||||
* Added CLI options for explicit specifying location of partials and main template (#346)
|
* Added CLI options for explicit specifying location of partials and main template (#346)
|
||||||
|
|
||||||
## v0.1.0 - _January 11, 2018_
|
## v0.1.0 - _January 11, 2018_
|
||||||
|
|||||||
@@ -42,8 +42,10 @@ const args = yargs
|
|||||||
demandOption: true,
|
demandOption: true,
|
||||||
normalize: true,
|
normalize: true,
|
||||||
})
|
})
|
||||||
.example("$0 --abis 'src/artifacts/**/*.json' --out 'src/contracts/generated/' --partials 'src/templates/partials/**/*.handlebars' --template 'src/templates/contract.handlebars'", 'Full usage example')
|
.example(
|
||||||
.argv;
|
"$0 --abis 'src/artifacts/**/*.json' --out 'src/contracts/generated/' --partials 'src/templates/partials/**/*.handlebars' --template 'src/templates/contract.handlebars'",
|
||||||
|
'Full usage example',
|
||||||
|
).argv;
|
||||||
|
|
||||||
function registerPartials(partialsGlob: string) {
|
function registerPartials(partialsGlob: string) {
|
||||||
const partialTemplateFileNames = globSync(partialsGlob);
|
const partialTemplateFileNames = globSync(partialsGlob);
|
||||||
|
|||||||
@@ -9,14 +9,14 @@ import { utils } from './utils';
|
|||||||
const DISPENSE_AMOUNT_ETHER = 0.1;
|
const DISPENSE_AMOUNT_ETHER = 0.1;
|
||||||
|
|
||||||
export class EtherRequestQueue extends RequestQueue {
|
export class EtherRequestQueue extends RequestQueue {
|
||||||
protected async processNextRequestFireAndForgetAsync(recipientAddress: string) {
|
protected async _processNextRequestFireAndForgetAsync(recipientAddress: string) {
|
||||||
utils.consoleLog(`Processing ETH ${recipientAddress}`);
|
utils.consoleLog(`Processing ETH ${recipientAddress}`);
|
||||||
const sendTransactionAsync = promisify(this.web3.eth.sendTransaction);
|
const sendTransactionAsync = promisify(this._web3.eth.sendTransaction);
|
||||||
try {
|
try {
|
||||||
const txHash = await sendTransactionAsync({
|
const txHash = await sendTransactionAsync({
|
||||||
from: configs.DISPENSER_ADDRESS,
|
from: configs.DISPENSER_ADDRESS,
|
||||||
to: recipientAddress,
|
to: recipientAddress,
|
||||||
value: this.web3.toWei(DISPENSE_AMOUNT_ETHER, 'ether'),
|
value: this._web3.toWei(DISPENSE_AMOUNT_ETHER, 'ether'),
|
||||||
});
|
});
|
||||||
utils.consoleLog(`Sent ${DISPENSE_AMOUNT_ETHER} ETH to ${recipientAddress} tx: ${txHash}`);
|
utils.consoleLog(`Sent ${DISPENSE_AMOUNT_ETHER} ETH to ${recipientAddress} tx: ${txHash}`);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
@@ -11,46 +11,46 @@ const MAX_QUEUE_SIZE = 500;
|
|||||||
const DEFAULT_QUEUE_INTERVAL_MS = 1000;
|
const DEFAULT_QUEUE_INTERVAL_MS = 1000;
|
||||||
|
|
||||||
export class RequestQueue {
|
export class RequestQueue {
|
||||||
protected queueIntervalMs: number;
|
protected _queueIntervalMs: number;
|
||||||
protected queue: string[];
|
protected _queue: string[];
|
||||||
protected queueIntervalId: NodeJS.Timer;
|
protected _queueIntervalId: NodeJS.Timer;
|
||||||
protected web3: Web3;
|
protected _web3: Web3;
|
||||||
constructor(web3: any) {
|
constructor(web3: any) {
|
||||||
this.queueIntervalMs = DEFAULT_QUEUE_INTERVAL_MS;
|
this._queueIntervalMs = DEFAULT_QUEUE_INTERVAL_MS;
|
||||||
this.queue = [];
|
this._queue = [];
|
||||||
|
|
||||||
this.web3 = web3;
|
this._web3 = web3;
|
||||||
|
|
||||||
this.start();
|
this._start();
|
||||||
}
|
}
|
||||||
public add(recipientAddress: string): boolean {
|
public add(recipientAddress: string): boolean {
|
||||||
if (this.isFull()) {
|
if (this.isFull()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
this.queue.push(recipientAddress);
|
this._queue.push(recipientAddress);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
public size(): number {
|
public size(): number {
|
||||||
return this.queue.length;
|
return this._queue.length;
|
||||||
}
|
}
|
||||||
public isFull(): boolean {
|
public isFull(): boolean {
|
||||||
return this.size() >= MAX_QUEUE_SIZE;
|
return this.size() >= MAX_QUEUE_SIZE;
|
||||||
}
|
}
|
||||||
protected start() {
|
protected _start() {
|
||||||
this.queueIntervalId = timers.setInterval(() => {
|
this._queueIntervalId = timers.setInterval(() => {
|
||||||
const recipientAddress = this.queue.shift();
|
const recipientAddress = this._queue.shift();
|
||||||
if (_.isUndefined(recipientAddress)) {
|
if (_.isUndefined(recipientAddress)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// tslint:disable-next-line:no-floating-promises
|
// tslint:disable-next-line:no-floating-promises
|
||||||
this.processNextRequestFireAndForgetAsync(recipientAddress);
|
this._processNextRequestFireAndForgetAsync(recipientAddress);
|
||||||
}, this.queueIntervalMs);
|
}, this._queueIntervalMs);
|
||||||
}
|
}
|
||||||
protected stop() {
|
protected _stop() {
|
||||||
clearInterval(this.queueIntervalId);
|
clearInterval(this._queueIntervalId);
|
||||||
}
|
}
|
||||||
// tslint:disable-next-line:prefer-function-over-method
|
// tslint:disable-next-line:prefer-function-over-method
|
||||||
protected async processNextRequestFireAndForgetAsync(recipientAddress: string) {
|
protected async _processNextRequestFireAndForgetAsync(recipientAddress: string) {
|
||||||
throw new Error('Expected processNextRequestFireAndForgetAsync to be implemented by a subclass');
|
throw new Error('Expected processNextRequestFireAndForgetAsync to be implemented by a subclass');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,13 +20,13 @@ export class ZRXRequestQueue extends RequestQueue {
|
|||||||
private _zeroEx: ZeroEx;
|
private _zeroEx: ZeroEx;
|
||||||
constructor(web3: Web3, networkId: number) {
|
constructor(web3: Web3, networkId: number) {
|
||||||
super(web3);
|
super(web3);
|
||||||
this.queueIntervalMs = QUEUE_INTERVAL_MS;
|
this._queueIntervalMs = QUEUE_INTERVAL_MS;
|
||||||
const zeroExConfig = {
|
const zeroExConfig = {
|
||||||
networkId,
|
networkId,
|
||||||
};
|
};
|
||||||
this._zeroEx = new ZeroEx(web3.currentProvider, zeroExConfig);
|
this._zeroEx = new ZeroEx(web3.currentProvider, zeroExConfig);
|
||||||
}
|
}
|
||||||
protected async processNextRequestFireAndForgetAsync(recipientAddress: string) {
|
protected async _processNextRequestFireAndForgetAsync(recipientAddress: string) {
|
||||||
utils.consoleLog(`Processing ZRX ${recipientAddress}`);
|
utils.consoleLog(`Processing ZRX ${recipientAddress}`);
|
||||||
const baseUnitAmount = ZeroEx.toBaseUnitAmount(DISPENSE_AMOUNT_ZRX, 18);
|
const baseUnitAmount = ZeroEx.toBaseUnitAmount(DISPENSE_AMOUNT_ZRX, 18);
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
# CHANGELOG
|
# CHANGELOG
|
||||||
|
|
||||||
|
## v0.5.0 - _TBD, 2018_
|
||||||
|
|
||||||
|
* Modified custom 'underscore-privates' rule, changing it to 'underscore-private-and-protected' requiring underscores to be prepended to both private and protected variable names (#354)
|
||||||
|
|
||||||
## v0.4.0 - _December 28, 2017_
|
## v0.4.0 - _December 28, 2017_
|
||||||
|
|
||||||
* Added custom 'underscore-privates' rule, requiring underscores to be prepended to private variable names
|
* Added custom 'underscore-privates' rule, requiring underscores to be prepended to private variable names
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ type RelevantClassMember =
|
|||||||
// Copied from: https://github.com/DanielRosenwasser/underscore-privates-tslint-rule
|
// Copied from: https://github.com/DanielRosenwasser/underscore-privates-tslint-rule
|
||||||
// The version on github is not published on npm
|
// The version on github is not published on npm
|
||||||
export class Rule extends Lint.Rules.AbstractRule {
|
export class Rule extends Lint.Rules.AbstractRule {
|
||||||
public static FAILURE_STRING = 'private members must be prefixed with an underscore';
|
public static FAILURE_STRING = 'private and protected members must be prefixed with an underscore';
|
||||||
|
|
||||||
public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] {
|
public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] {
|
||||||
return this.applyWithFunction(sourceFile, walk);
|
return this.applyWithFunction(sourceFile, walk);
|
||||||
@@ -54,7 +54,7 @@ function nameStartsWithUnderscore(text: string) {
|
|||||||
return text.charCodeAt(0) === UNDERSCORE.charCodeAt(0);
|
return text.charCodeAt(0) === UNDERSCORE.charCodeAt(0);
|
||||||
}
|
}
|
||||||
function memberIsPrivate(node: ts.Declaration) {
|
function memberIsPrivate(node: ts.Declaration) {
|
||||||
return Lint.hasModifier(node.modifiers, ts.SyntaxKind.PrivateKeyword);
|
return Lint.hasModifier(node.modifiers, ts.SyntaxKind.PrivateKeyword, ts.SyntaxKind.ProtectedKeyword);
|
||||||
}
|
}
|
||||||
function nameIsIdentifier(node: ts.Node): node is ts.Identifier {
|
function nameIsIdentifier(node: ts.Node): node is ts.Identifier {
|
||||||
return node.kind === ts.SyntaxKind.Identifier;
|
return node.kind === ts.SyntaxKind.Identifier;
|
||||||
@@ -73,7 +73,7 @@
|
|||||||
],
|
],
|
||||||
"space-within-parens": false,
|
"space-within-parens": false,
|
||||||
"type-literal-delimiter": true,
|
"type-literal-delimiter": true,
|
||||||
"underscore-privates": true,
|
"underscore-private-and-protected": true,
|
||||||
"variable-name": [true, "ban-keywords", "allow-pascal-case"],
|
"variable-name": [true, "ban-keywords", "allow-pascal-case"],
|
||||||
"whitespace": [
|
"whitespace": [
|
||||||
true,
|
true,
|
||||||
|
|||||||
@@ -689,7 +689,7 @@ export class Blockchain {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
private _stopWatchingExchangeLogFillEvents(): void {
|
private _stopWatchingExchangeLogFillEvents(): void {
|
||||||
this._zeroEx.exchange.unsubscribeAll();
|
this._zeroEx.exchange._unsubscribeAll();
|
||||||
}
|
}
|
||||||
private async _getTokenRegistryTokensByAddressAsync(): Promise<TokenByAddress> {
|
private async _getTokenRegistryTokensByAddressAsync(): Promise<TokenByAddress> {
|
||||||
utils.assert(!_.isUndefined(this._zeroEx), 'ZeroEx must be instantiated.');
|
utils.assert(!_.isUndefined(this._zeroEx), 'ZeroEx must be instantiated.');
|
||||||
|
|||||||
Reference in New Issue
Block a user