Skip to content

Commit

Permalink
Add tslint. Fixes #108.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sean Kelley committed Jan 12, 2017
1 parent 8b426a1 commit 5efd5c8
Show file tree
Hide file tree
Showing 11 changed files with 626 additions and 232 deletions.
394 changes: 197 additions & 197 deletions examples/test-data.ts

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -13,7 +13,7 @@
},
"scripts": {
"start": "webpack-dev-server --config webpack.config.hot.js --inline --content-base examples/build/ --host 0.0.0.0 --port 8085 --hot true",
"test": "mocha 'test/**/*.ts'",
"test": "mocha 'test/**/*.ts' && tslint --project tsconfig.json",
"prepublish": "tsc --project tsconfig-build.json && lessc --source-map styles/index.less react-layered-chart.css"
},
"devDependencies": {
Expand Down Expand Up @@ -52,6 +52,7 @@
"style-loader": "^0.13.1",
"ts-loader": "^1.3.3",
"ts-node": "^2.0.0",
"tslint": "^4.3.1",
"typescript": "^2.1.4",
"webpack": "^1.12.11",
"webpack-dev-server": "^1.14.1",
Expand Down
18 changes: 8 additions & 10 deletions src/connected/dataUtils.ts
Expand Up @@ -7,14 +7,12 @@ export function createStaticDataLoader(
dataBySeriesId: TBySeriesId<SeriesData>,
yDomainBySeriesId: TBySeriesId<Interval>
): DataLoader {
return () => {
return _.mapValues(dataBySeriesId, (data, seriesId) =>
new Promise((resolve, reject) => {
resolve({
data,
yDomain: yDomainBySeriesId[seriesId]
});
})
)
};
return () => _.mapValues(dataBySeriesId, (data, seriesId) =>
new Promise((resolve, reject) => {
resolve({
data,
yDomain: yDomainBySeriesId[seriesId]
});
})
);
}
4 changes: 2 additions & 2 deletions src/connected/flux/reducerUtils.ts
Expand Up @@ -4,7 +4,7 @@ import { TBySeriesId } from '../interfaces';

export function objectWithKeys<T>(keys: string[], value: T): { [key: string]: T } {
const object: { [key: string]: T } = {};
keys.forEach(k => { object[k] = value });
keys.forEach(k => { object[k] = value; });
return object;
}

Expand All @@ -14,6 +14,6 @@ export function replaceValuesWithConstant<T>(anyBySeriesId: TBySeriesId<any>, va

export function objectWithKeysFromObject<T>(anyBySeriesId: TBySeriesId<any>, keys: string[], defaultValue: T): TBySeriesId<T> {
const object: { [key: string]: T } = {};
keys.forEach(k => { object[k] = anyBySeriesId[k] !== undefined ? anyBySeriesId[k] : defaultValue });
keys.forEach(k => { object[k] = anyBySeriesId[k] !== undefined ? anyBySeriesId[k] : defaultValue; });
return object;
}
4 changes: 4 additions & 0 deletions src/connected/layers/connectedDataLayers.tsx
Expand Up @@ -16,13 +16,15 @@ import { SeriesId } from '../interfaces';
import { wrapDataLayerWithConnect, SeriesIdProp } from './wrapDataLayerWithConnect';


// tslint:disable-next-line:class-name
export interface _CommonConnectedBarLayerProps {
color?: Color;
}
export type ConnectedBarLayerProps = _CommonConnectedBarLayerProps & SeriesIdProp;
export const ConnectedBarLayer = wrapDataLayerWithConnect<_CommonConnectedBarLayerProps, BarLayerProps>(BarLayer);


// tslint:disable-next-line:class-name
export interface _CommonConnectedBucketedLineLayerProps {
yScale?: ScaleFunction;
color?: Color;
Expand All @@ -32,6 +34,7 @@ export type ConnectedBucketedLineLayerProps = _CommonConnectedBucketedLineLayerP
export const ConnectedBucketedLineLayer = wrapDataLayerWithConnect<_CommonConnectedBucketedLineLayerProps, BucketedLineLayerProps>(BucketedLineLayer);


// tslint:disable-next-line:class-name
export interface _CommonConnectedPointLayerProps {
yScale?: ScaleFunction;
color?: Color;
Expand All @@ -42,6 +45,7 @@ export type ConnectedPointLayerProps = _CommonConnectedPointLayerProps & SeriesI
export const ConnectedPointLayer = wrapDataLayerWithConnect<_CommonConnectedPointLayerProps, PointLayerProps>(PointLayer);


// tslint:disable-next-line:class-name
export interface _CommonConnectedSimpleLineLayerProps {
yScale?: ScaleFunction;
color?: Color;
Expand Down
2 changes: 1 addition & 1 deletion src/core/decorators/mixinToDecorator.ts
Expand Up @@ -14,5 +14,5 @@ export default function<P, S>(mixin: React.Mixin<P, S>): ClassDecorator {
return returnValue;
};
});
}
};
}
2 changes: 1 addition & 1 deletion src/core/intervalUtils.ts
Expand Up @@ -74,7 +74,7 @@ export function niceInterval(interval: Interval): Interval {
return {
min: nicedInterval[0],
max: nicedInterval[1]
}
};
}

export function mergeIntervals(intervals: Interval[], defaultInterval?: Interval): Interval {
Expand Down
2 changes: 1 addition & 1 deletion src/core/renderUtils.ts
Expand Up @@ -76,7 +76,7 @@ export function getIndexBoundsForSpanData<T>(data: T[], xValueBounds: Interval,
} else {
return minXValueAccessor(value as T);
}
}
};
}

const lowerBoundAccessor = _.isString(maxXValueAccessor)
Expand Down
2 changes: 1 addition & 1 deletion test/compoundActions-test.ts
Expand Up @@ -140,7 +140,7 @@ describe('(compound actions)', () => {
});

describe('setDataLoaderAndLoad', () => {
const LOADER: DataLoader =(() => {}) as any;
const LOADER: DataLoader = (() => {}) as any;

it('should request a data load for all existing series', () => {
store.dispatch(setDataLoaderAndLoad(LOADER));
Expand Down
104 changes: 104 additions & 0 deletions tslint.json
@@ -0,0 +1,104 @@
{
"jsRules": {
"class-name": true,
"comment-format": [
true,
"check-space"
],
"indent": [
true,
"spaces"
],
"no-duplicate-variable": true,
"no-eval": true,
"no-trailing-whitespace": true,
"no-unsafe-finally": true,
"one-line": [
true,
"check-open-brace",
"check-whitespace"
],
"quotemark": [
true,
"single"
],
"semicolon": [
true,
"always"
],
"triple-equals": [
true,
"allow-null-check"
],
"variable-name": [
true,
"ban-keywords"
],
"whitespace": [
true,
"check-branch",
"check-decl",
"check-operator",
"check-separator",
"check-type"
]
},
"rules": {
"class-name": true,
"comment-format": [
true,
"check-space"
],
"indent": [
true,
"spaces"
],
"curly": true,
"no-eval": true,
"no-internal-module": true,
"no-trailing-whitespace": true,
"no-unsafe-finally": true,
"no-var-keyword": true,
"one-line": [
true,
"check-open-brace",
"check-whitespace"
],
"quotemark": [
true,
"single"
],
"semicolon": [
true,
"always",
"ignore-interfaces",
"ignore-bound-class-methods"
],
"triple-equals": [
true,
"allow-null-check"
],
"typedef-whitespace": [
true,
{
"call-signature": "nospace",
"index-signature": "nospace",
"parameter": "nospace",
"property-declaration": "nospace",
"variable-declaration": "nospace"
}
],
"variable-name": [
true,
"ban-keywords"
],
"whitespace": [
true,
"check-branch",
"check-decl",
"check-operator",
"check-separator",
"check-type"
]
}
}

0 comments on commit 5efd5c8

Please sign in to comment.