TSLint --fix part II

pull/427/head
Rick Carlino 2017-08-28 07:23:53 -05:00
parent ab173f1fbe
commit cb10c840e0
13 changed files with 19 additions and 9 deletions

View File

@ -1,5 +1,6 @@
import { ReactWrapper } from "enzyme";
// tslint:disable-next-line:no-any
export function getProp(i: ReactWrapper<any, {}>, key: string): any {
return i.props()[key];
}

View File

@ -61,10 +61,12 @@ describe("<ChangePassword/>", function () {
it("sets a field", () => {
const { el, instance } = testCase();
// tslint:disable-next-line:no-any
instance().set("password")({ currentTarget: { value: "foo" } } as any);
el.update();
expect(instance().state.form.password).toBe("foo");
});
describe("AJAX", () => {
beforeEach(function () {
// import and pass your custom axios instance to this method

View File

@ -39,7 +39,7 @@ function incomingStatus(statusMessage: HardwareState) {
export function isLog(x: object): x is Log {
return _.isObject(x) && _.isString(_.get(x, "message" as keyof Log));
}
const commandErr = (noun = "Command") => (x: any) => {
const commandErr = (noun = "Command") => (x: {}) => {
console.dir(x);
console.info("Took longer than 6 seconds: " + noun);
};

View File

@ -23,6 +23,7 @@ const KEYS: McuParamName[] = [
"encoder_type_z"
];
// tslint:disable-next-line:no-any
function isEncoderValue(x: any): x is Encoder { return !!Encoder[x]; }
function findByType(input: number | string | undefined) {

View File

@ -98,6 +98,7 @@ describe("<FarmEventForm/>", () => {
const p = props();
const i = instance(p);
i.forceUpdate();
// tslint:disable-next-line:no-any
i.fieldSet("repeat")(({ currentTarget: { value: "4" } } as any));
i.forceUpdate();
expect(i.state.fe.repeat).toEqual("4");

View File

@ -18,6 +18,7 @@ interface MetaInfoProps {
*/
label?: string;
attr: string;
// tslint:disable-next-line:no-any
obj: any; /** Really, it's OK here! See safeStringFetch */
}

View File

@ -15,6 +15,7 @@ export type GetState = () => Everything;
/** A Redux Thunk function. */
export interface Thunk {
// TODO: CONVERT THIS TO A GENERIC (Thunk<T>)
// tslint:disable-next-line:no-any
(dispatch: Function, getState: GetState): any;
}

View File

@ -20,11 +20,13 @@ export let mwConfig: MiddlewareConfig[] = [
}
];
declare var __REDUX_DEVTOOLS_EXTENSION_COMPOSE__: Function;
export function getMiddleware(env: EnvName) {
const middlewareFns = mwConfig
.filter(function (mwc) { return (mwc.env === env) || (mwc.env === "*"); })
.map((mwc) => mwc.fn);
const dtCompose = (window as any).__REDUX_DEVTOOLS_EXTENSION_COMPOSE__;
const dtCompose = __REDUX_DEVTOOLS_EXTENSION_COMPOSE__;
const composeEnhancers = dtCompose || compose;
const middlewares = applyMiddleware(...middlewareFns);

View File

@ -20,7 +20,7 @@ export let reducers = combineReducers({
* "normal" reducer this is the place to do it */
export function rootReducer(
/** Sorry for the `any` here. */
state: any,
state: Everything,
action: ReduxAction<{}>) {
if (action.type === Actions.LOGOUT) {
Session.clear();

View File

@ -133,7 +133,7 @@ export type PointerType =
| TaggedGenericPointer
| TaggedPlantPointer;
function isTaggedPoint(x: any): x is PointerType {
function isTaggedPoint(x: {}): x is PointerType {
return (is("points")(x)) && (x.kind === "points");
}

View File

@ -3,6 +3,7 @@ import { updateStep } from "../step_tiles/index";
import { isString, isNumber } from "lodash";
import { StepInputProps } from "../interfaces";
import { BlurableInput } from "../../ui";
import { Dictionary } from "farmbot/dist";
export function InputDefault({
step,
@ -12,9 +13,8 @@ export function InputDefault({
type_,
index
}: StepInputProps) {
const raw = (step.args as any)[field];
const notUndefied = (isString(raw) || isNumber(raw));
const val = notUndefied ? raw : "";
const raw = (step.args as Dictionary<string | number | undefined>)[field];
const val = (isNumber(raw) || isString(raw)) ? raw : "";
return <BlurableInput
type={type_ || "text"}

View File

@ -30,6 +30,7 @@ describe("<StepButton/>", () => {
expect(action).toBeTruthy();
expect(action.type).toBe("OVERWRITE_RESOURCE");
if (p.current && p.current.body.body) {
// tslint:disable-next-line:no-any
expect((action.payload.update as any).body[0]).toMatchObject(p.step);
} else {
fail("No");

View File

@ -17,10 +17,10 @@ export class FallbackImg extends React.Component<Props, State> {
state: State = { needsFallback: false };
get imgProps() {
const imProps: ImgTag = defensiveClone(this.props);
const imProps: Props = defensiveClone(this.props);
// React will complain at runtime if <img/> has extra props.
// Typescript will compile at compile if I don't use `any` here:
delete (imProps as any).fallback;
delete imProps.fallback;
return imProps;
}