From 08253ee1b15cc302538447f888c0b8a6a77704e0 Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Wed, 16 May 2018 13:08:27 +0300 Subject: [PATCH] chore: enable tslint for test files --- src/__tests__/ssr.test.tsx | 4 +++- src/__tests__/standalone.test.tsx | 7 ++++--- .../__tests__/DiscriminatorDropdown.test.tsx | 8 +++++--- src/components/__tests__/JsonViewer.tsx | 4 +++- src/components/__tests__/OneOfSchema.test.tsx | 8 +++++--- src/utils/test-utils.ts | 12 ++++++++---- tsconfig.json | 3 +-- tslint.json | 2 +- 8 files changed, 30 insertions(+), 18 deletions(-) diff --git a/src/__tests__/ssr.test.tsx b/src/__tests__/ssr.test.tsx index d7c6dfd8..88e4f14f 100644 --- a/src/__tests__/ssr.test.tsx +++ b/src/__tests__/ssr.test.tsx @@ -1,7 +1,9 @@ +/* tslint:disable:no-implicit-dependencies */ + import * as React from 'react'; import { renderToString } from 'react-dom/server'; -import { Redoc, createStore } from '../'; import * as yaml from 'yaml-js'; +import { createStore, Redoc } from '../'; import { readFileSync } from 'fs'; import { resolve } from 'path'; diff --git a/src/__tests__/standalone.test.tsx b/src/__tests__/standalone.test.tsx index 31f5aee8..f4ae0b81 100644 --- a/src/__tests__/standalone.test.tsx +++ b/src/__tests__/standalone.test.tsx @@ -1,5 +1,6 @@ -import * as React from 'react'; +/* tslint:disable:no-implicit-dependencies */ import { mount } from 'enzyme'; +import * as React from 'react'; import * as yaml from 'yaml-js'; import { readFileSync } from 'fs'; @@ -7,14 +8,14 @@ import { resolve } from 'path'; // import { filterPropsDeep } from '../../../utils/test-utils'; -import { RedocStandalone, Loading, StoreProvider, ErrorBoundary } from '../components/'; +import { ErrorBoundary, Loading, RedocStandalone, StoreProvider } from '../components/'; describe('Components', () => { describe('RedocStandalone', () => { test('should show loading first', () => { const spec = yaml.load(readFileSync(resolve(__dirname, '../../demo/openapi.yaml'))); - let inst = mount(); + const inst = mount(); expect(inst.find(Loading)).toHaveLength(1); }); }); diff --git a/src/components/__tests__/DiscriminatorDropdown.test.tsx b/src/components/__tests__/DiscriminatorDropdown.test.tsx index 0ccbd23c..284baeac 100644 --- a/src/components/__tests__/DiscriminatorDropdown.test.tsx +++ b/src/components/__tests__/DiscriminatorDropdown.test.tsx @@ -1,12 +1,14 @@ -import * as React from 'react'; +/* tslint:disable:no-implicit-dependencies */ + import { shallow } from 'enzyme'; import toJson from 'enzyme-to-json'; +import * as React from 'react'; import { filterPropsDeep } from '../../utils/test-utils'; -import { RedocNormalizedOptions } from '../../services/RedocNormalizedOptions'; +import { ObjectSchema, Schema } from '../'; import { OpenAPIParser, SchemaModel } from '../../services'; -import { Schema, ObjectSchema } from '../'; +import { RedocNormalizedOptions } from '../../services/RedocNormalizedOptions'; import * as simpleDiscriminatorFixture from './fixtures/simple-discriminator.json'; const options = new RedocNormalizedOptions({}); diff --git a/src/components/__tests__/JsonViewer.tsx b/src/components/__tests__/JsonViewer.tsx index 33677c0a..c9deb7da 100644 --- a/src/components/__tests__/JsonViewer.tsx +++ b/src/components/__tests__/JsonViewer.tsx @@ -1,5 +1,7 @@ -import * as React from 'react'; +/* tslint:disable:no-implicit-dependencies */ + import { mount, ReactWrapper } from 'enzyme'; +import * as React from 'react'; import { JsonViewer } from '../'; import { withTheme } from '../testProviders'; diff --git a/src/components/__tests__/OneOfSchema.test.tsx b/src/components/__tests__/OneOfSchema.test.tsx index 350628b8..a49136f6 100644 --- a/src/components/__tests__/OneOfSchema.test.tsx +++ b/src/components/__tests__/OneOfSchema.test.tsx @@ -1,12 +1,14 @@ -import * as React from 'react'; +/* tslint:disable:no-implicit-dependencies */ + import { shallow } from 'enzyme'; import toJson from 'enzyme-to-json'; +import * as React from 'react'; import { filterPropsDeep } from '../../utils/test-utils'; -import { RedocNormalizedOptions } from '../../services/RedocNormalizedOptions'; +import { OneOfSchema, Schema } from '../'; import { OpenAPIParser, SchemaModel } from '../../services'; -import { Schema, OneOfSchema } from '../'; +import { RedocNormalizedOptions } from '../../services/RedocNormalizedOptions'; const options = new RedocNormalizedOptions({}); describe('Components', () => { diff --git a/src/utils/test-utils.ts b/src/utils/test-utils.ts index b21f6931..f150e141 100644 --- a/src/utils/test-utils.ts +++ b/src/utils/test-utils.ts @@ -1,20 +1,24 @@ +/* tslint:disable:no-implicit-dependencies */ + +import { has, set } from 'lodash'; import { instanceOf } from 'prop-types'; import { RedocNormalizedOptions } from '../services/RedocNormalizedOptions'; -import { set, has } from 'lodash'; function traverseComponent(root, fn) { - if (!root) return; + if (!root) { + return; + } fn(root); if (root.children) { - for (let child of root.children) { + for (const child of root.children) { traverseComponent(child, fn); } } } -export function filterPropsDeep(component: T, paths: string[]): T { +export function filterPropsDeep(component: T, paths: string[]): T { traverseComponent(component, comp => { if (comp.props) { for (const path of paths) { diff --git a/tsconfig.json b/tsconfig.json index 28e98b3c..861b97d8 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -36,8 +36,7 @@ "include": [ "./custom.d.ts", "./demo/playground/hmr-playground.tsx", - "./src/index.ts", - "./src/standalone.tsx", + "./src/**/*.ts?", "demo/*.tsx" ] } diff --git a/tslint.json b/tslint.json index 352ea5ae..9c980dcb 100644 --- a/tslint.json +++ b/tslint.json @@ -17,7 +17,7 @@ "quotemark": [true, "single", "avoid-template", "jsx-double"], "variable-name": [true, "ban-keywords", "check-format", "allow-leading-underscore", "allow-pascal-case"], "arrow-parens": [true, "ban-single-arg-parens"], - "no-submodule-imports": [true, "prismjs", "perfect-scrollbar", "core-js"], + "no-submodule-imports": [true, "prismjs", "perfect-scrollbar", "react-dom", "core-js"], "object-literal-key-quotes": [true, "as-needed"], "no-unused-expression": [true, "allow-tagged-template"], "semicolon": [true, "always", "ignore-bound-class-methods"],