chore: enable tslint for test files

This commit is contained in:
Roman Hotsiy 2018-05-16 13:08:27 +03:00
parent 9115be8378
commit 08253ee1b1
No known key found for this signature in database
GPG Key ID: 5CB7B3ACABA57CB0
8 changed files with 30 additions and 18 deletions

View File

@ -1,7 +1,9 @@
/* tslint:disable:no-implicit-dependencies */
import * as React from 'react'; import * as React from 'react';
import { renderToString } from 'react-dom/server'; import { renderToString } from 'react-dom/server';
import { Redoc, createStore } from '../';
import * as yaml from 'yaml-js'; import * as yaml from 'yaml-js';
import { createStore, Redoc } from '../';
import { readFileSync } from 'fs'; import { readFileSync } from 'fs';
import { resolve } from 'path'; import { resolve } from 'path';

View File

@ -1,5 +1,6 @@
import * as React from 'react'; /* tslint:disable:no-implicit-dependencies */
import { mount } from 'enzyme'; import { mount } from 'enzyme';
import * as React from 'react';
import * as yaml from 'yaml-js'; import * as yaml from 'yaml-js';
import { readFileSync } from 'fs'; import { readFileSync } from 'fs';
@ -7,14 +8,14 @@ import { resolve } from 'path';
// import { filterPropsDeep } from '../../../utils/test-utils'; // import { filterPropsDeep } from '../../../utils/test-utils';
import { RedocStandalone, Loading, StoreProvider, ErrorBoundary } from '../components/'; import { ErrorBoundary, Loading, RedocStandalone, StoreProvider } from '../components/';
describe('Components', () => { describe('Components', () => {
describe('RedocStandalone', () => { describe('RedocStandalone', () => {
test('should show loading first', () => { test('should show loading first', () => {
const spec = yaml.load(readFileSync(resolve(__dirname, '../../demo/openapi.yaml'))); const spec = yaml.load(readFileSync(resolve(__dirname, '../../demo/openapi.yaml')));
let inst = mount(<RedocStandalone spec={spec} options={{}} />); const inst = mount(<RedocStandalone spec={spec} options={{}} />);
expect(inst.find(Loading)).toHaveLength(1); expect(inst.find(Loading)).toHaveLength(1);
}); });
}); });

View File

@ -1,12 +1,14 @@
import * as React from 'react'; /* tslint:disable:no-implicit-dependencies */
import { shallow } from 'enzyme'; import { shallow } from 'enzyme';
import toJson from 'enzyme-to-json'; import toJson from 'enzyme-to-json';
import * as React from 'react';
import { filterPropsDeep } from '../../utils/test-utils'; import { filterPropsDeep } from '../../utils/test-utils';
import { RedocNormalizedOptions } from '../../services/RedocNormalizedOptions'; import { ObjectSchema, Schema } from '../';
import { OpenAPIParser, SchemaModel } from '../../services'; import { OpenAPIParser, SchemaModel } from '../../services';
import { Schema, ObjectSchema } from '../'; import { RedocNormalizedOptions } from '../../services/RedocNormalizedOptions';
import * as simpleDiscriminatorFixture from './fixtures/simple-discriminator.json'; import * as simpleDiscriminatorFixture from './fixtures/simple-discriminator.json';
const options = new RedocNormalizedOptions({}); const options = new RedocNormalizedOptions({});

View File

@ -1,5 +1,7 @@
import * as React from 'react'; /* tslint:disable:no-implicit-dependencies */
import { mount, ReactWrapper } from 'enzyme'; import { mount, ReactWrapper } from 'enzyme';
import * as React from 'react';
import { JsonViewer } from '../'; import { JsonViewer } from '../';
import { withTheme } from '../testProviders'; import { withTheme } from '../testProviders';

View File

@ -1,12 +1,14 @@
import * as React from 'react'; /* tslint:disable:no-implicit-dependencies */
import { shallow } from 'enzyme'; import { shallow } from 'enzyme';
import toJson from 'enzyme-to-json'; import toJson from 'enzyme-to-json';
import * as React from 'react';
import { filterPropsDeep } from '../../utils/test-utils'; import { filterPropsDeep } from '../../utils/test-utils';
import { RedocNormalizedOptions } from '../../services/RedocNormalizedOptions'; import { OneOfSchema, Schema } from '../';
import { OpenAPIParser, SchemaModel } from '../../services'; import { OpenAPIParser, SchemaModel } from '../../services';
import { Schema, OneOfSchema } from '../'; import { RedocNormalizedOptions } from '../../services/RedocNormalizedOptions';
const options = new RedocNormalizedOptions({}); const options = new RedocNormalizedOptions({});
describe('Components', () => { describe('Components', () => {

View File

@ -1,20 +1,24 @@
/* tslint:disable:no-implicit-dependencies */
import { has, set } from 'lodash';
import { instanceOf } from 'prop-types'; import { instanceOf } from 'prop-types';
import { RedocNormalizedOptions } from '../services/RedocNormalizedOptions'; import { RedocNormalizedOptions } from '../services/RedocNormalizedOptions';
import { set, has } from 'lodash';
function traverseComponent(root, fn) { function traverseComponent(root, fn) {
if (!root) return; if (!root) {
return;
}
fn(root); fn(root);
if (root.children) { if (root.children) {
for (let child of root.children) { for (const child of root.children) {
traverseComponent(child, fn); traverseComponent(child, fn);
} }
} }
} }
export function filterPropsDeep<T extends Object>(component: T, paths: string[]): T { export function filterPropsDeep<T extends object>(component: T, paths: string[]): T {
traverseComponent(component, comp => { traverseComponent(component, comp => {
if (comp.props) { if (comp.props) {
for (const path of paths) { for (const path of paths) {

View File

@ -36,8 +36,7 @@
"include": [ "include": [
"./custom.d.ts", "./custom.d.ts",
"./demo/playground/hmr-playground.tsx", "./demo/playground/hmr-playground.tsx",
"./src/index.ts", "./src/**/*.ts?",
"./src/standalone.tsx",
"demo/*.tsx" "demo/*.tsx"
] ]
} }

View File

@ -17,7 +17,7 @@
"quotemark": [true, "single", "avoid-template", "jsx-double"], "quotemark": [true, "single", "avoid-template", "jsx-double"],
"variable-name": [true, "ban-keywords", "check-format", "allow-leading-underscore", "allow-pascal-case"], "variable-name": [true, "ban-keywords", "check-format", "allow-leading-underscore", "allow-pascal-case"],
"arrow-parens": [true, "ban-single-arg-parens"], "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"], "object-literal-key-quotes": [true, "as-needed"],
"no-unused-expression": [true, "allow-tagged-template"], "no-unused-expression": [true, "allow-tagged-template"],
"semicolon": [true, "always", "ignore-bound-class-methods"], "semicolon": [true, "always", "ignore-bound-class-methods"],