From d2cc0aadeac0fd129a49415681123c846b9a16a8 Mon Sep 17 00:00:00 2001 From: Eugene Kuzmenko Date: Sat, 9 Jul 2016 11:24:09 +0300 Subject: [PATCH] [fixed] lint the interface files --- .eslintignore | 1 - bin/build.js | 3 ++- interfaces/autoprefixer.js | 2 ++ interfaces/chai.js | 28 ++++++++++++------------ interfaces/cheerio.js | 16 +++++++------- interfaces/codemirror.js | 2 ++ interfaces/eslint.js | 15 ++++++++++--- interfaces/fb-watchman.js | 2 ++ interfaces/jsdom.js | 16 +++++++------- interfaces/node-sass-import-once.js | 2 ++ interfaces/node-sass.js | 9 ++++++-- interfaces/postcss.js | 10 +++++++-- interfaces/react.js | 33 ++++++++++++----------------- interfaces/sinon-chai.js | 2 ++ interfaces/sinon.js | 16 ++++++++------ interfaces/tiny-lr.js | 5 ++++- interfaces/webpack.js | 7 +++++- 17 files changed, 102 insertions(+), 67 deletions(-) diff --git a/.eslintignore b/.eslintignore index 814b58e..007f2b0 100644 --- a/.eslintignore +++ b/.eslintignore @@ -2,5 +2,4 @@ /config/** /coverage/** /docs/** -/interfaces/** /node_modules/** diff --git a/bin/build.js b/bin/build.js index 3a8dbed..6122bbd 100644 --- a/bin/build.js +++ b/bin/build.js @@ -10,10 +10,11 @@ const rootDir = join(__dirname, '..'), srcDir = join(rootDir, 'src'), libDir = join(rootDir, 'lib'), testDir = join(rootDir, 'test'), + interfacesDir = join(rootDir, 'interfaces'), js = new JS(), npm = new NativeProcess('npm'); -js.be(srcDir, libDir, [testDir, binDir], () => { +js.be(srcDir, libDir, [testDir, binDir, interfacesDir], () => { npm.run(stderr => { if (stderr) { return console.error(stderr); diff --git a/interfaces/autoprefixer.js b/interfaces/autoprefixer.js index 9b0be60..76de03f 100644 --- a/interfaces/autoprefixer.js +++ b/interfaces/autoprefixer.js @@ -1,3 +1,5 @@ /* @flow */ +/* eslint-disable no-empty */ + declare module 'autoprefixer' {} diff --git a/interfaces/chai.js b/interfaces/chai.js index 93cef3d..187f5fb 100644 --- a/interfaces/chai.js +++ b/interfaces/chai.js @@ -1,20 +1,20 @@ /* @flow */ type Assert = { - not: Assert, - a: (type: string) => void, - calledWith: (...args: Array) => void, - called: void, - equal: (obj: any) => void, - eql: (obj: any) => void, - instanceof: (obj: any) => void, - contain: (obj: Object|string|number) => void, - returned: (obj: any) => void, - calledOnce: void, - calledTwice: void, - null: void, - false: void, - true: void + not: Assert; + a(type: string): void; + calledWith(...args: Array): void; + called: void; + equal(obj: any): void; + eql(obj: any): void; + instanceof(obj: any): void; + contain(obj: Object|string|number): void; + returned(obj: any): void; + calledOnce: void; + calledTwice: void; + null: void; + false: void; + true: void; }; declare module 'chai' { diff --git a/interfaces/cheerio.js b/interfaces/cheerio.js index aea70b6..7b0f2c4 100644 --- a/interfaces/cheerio.js +++ b/interfaces/cheerio.js @@ -1,17 +1,17 @@ /* @flow */ type DOM = { - toArray: () => Array, - html: () => string, - children: () => DOM, - each: (iteratee: (i: number, el: Object) => any) => DOM, - find: (selector: string) => DOM, - removeAttr: (attr: string) => void + toArray(): Array; + html(): string; + children(): DOM; + each(iteratee: (i: number, el: Object) => any): DOM; + find(selector: string): DOM; + removeAttr(attr: string): void; }; declare module 'cheerio' { declare function load(html: string): { - (): DOM, - root: () => DOM + (): DOM; + root(): DOM; }; } diff --git a/interfaces/codemirror.js b/interfaces/codemirror.js index cdcf932..5e64d35 100644 --- a/interfaces/codemirror.js +++ b/interfaces/codemirror.js @@ -1,5 +1,7 @@ /* @flow */ +/* eslint-disable no-empty */ + declare module 'codemirror' { declare function exports(el: any, options: ?Object): void; } diff --git a/interfaces/eslint.js b/interfaces/eslint.js index e63a28b..68000b6 100644 --- a/interfaces/eslint.js +++ b/interfaces/eslint.js @@ -1,12 +1,21 @@ /* @flow */ -type ESLintMessage = {message: string, ruleId?: string, line: number, column: number, filePath: string}; -type ESLintResult = {filePath: string, messages: Array}; +type ESLintMessage = { + message: string; + ruleId?: string; + line: number; + column: number; + filePath: string; +}; +type ESLintResult = { + filePath: string; + messages: Array; +}; declare module 'eslint' { declare class CLIEngine { options: {rules: Object}; constructor(config: Object): void; - executeOnFiles(files: Array): {results: Array} + executeOnFiles(files: Array): {results: Array}; } } diff --git a/interfaces/fb-watchman.js b/interfaces/fb-watchman.js index 55caa09..d46b930 100644 --- a/interfaces/fb-watchman.js +++ b/interfaces/fb-watchman.js @@ -1,5 +1,7 @@ /* @flow */ +/* eslint-disable no-unused-vars */ + import type {ObjectOrErrorCallback} from '../src/typedef'; import EventEmitter from 'events'; diff --git a/interfaces/jsdom.js b/interfaces/jsdom.js index da6c55c..a3a14ed 100644 --- a/interfaces/jsdom.js +++ b/interfaces/jsdom.js @@ -3,14 +3,14 @@ declare module 'jsdom' { declare function jsdom(): { defaultView: { - navigator: any, + navigator: any; document: { - createRange: () => { - setEnd: () => void, - setStart: () => void, - getBoundingClientRect: () => {} - } - } - } + createRange(): { + setEnd(): void; + setStart(): void; + getBoundingClientRect(): Object; + }; + }; + }; }; } diff --git a/interfaces/node-sass-import-once.js b/interfaces/node-sass-import-once.js index b0748e5..784903e 100644 --- a/interfaces/node-sass-import-once.js +++ b/interfaces/node-sass-import-once.js @@ -1,3 +1,5 @@ /* @flow */ +/* eslint-disable no-empty */ + declare module 'node-sass-import-once' {} diff --git a/interfaces/node-sass.js b/interfaces/node-sass.js index c1e48c6..33c0ffa 100644 --- a/interfaces/node-sass.js +++ b/interfaces/node-sass.js @@ -1,7 +1,12 @@ /* @flow */ -type NodeSassError = {message: string, file: string, line: number, column: number}; -type NodeSassCallback = (error: ?NodeSassError, result: {css: string, map: string}) => void; +type NodeSassError = { + message: string; + file: string; + line: number; + column: number; +}; +type NodeSassCallback = (error: ?NodeSassError, result: {css: string; map: string;}) => void; declare module 'node-sass' { declare function render(options: Object, callback: NodeSassCallback): void; diff --git a/interfaces/postcss.js b/interfaces/postcss.js index ec35453..58ecd5b 100644 --- a/interfaces/postcss.js +++ b/interfaces/postcss.js @@ -1,7 +1,13 @@ /* @flow */ -type PostCSSResult = {css: string, map: Object, warnings: () => Array}; -type PostCSSPromise = {then: (callback: (result: PostCSSResult) => void) => void}; +type PostCSSResult = { + css: string; + map: Object; + warnings(): Array; +}; +type PostCSSPromise = { + then(callback: (result: PostCSSResult) => void): void; +}; declare module 'postcss' { declare function exports(plugins: Array): {process: (code: string, config: Object) => PostCSSPromise}; diff --git a/interfaces/react.js b/interfaces/react.js index 585a7af..76c66d0 100644 --- a/interfaces/react.js +++ b/interfaces/react.js @@ -1,28 +1,21 @@ /* @flow */ -type PropTypesObject = { - instanceOf: (obj: any) => void, - arrayOf: (obj: any) => void, - string: {isRequired: void}, - any: {isRequired: void}, - object: {isRequired: void}, - bool: {isRequired: void}, - array: {isRequired: void}, - number: {isRequired: void}, - func: {isRequired: void} -}; - declare module 'react' { declare function createElement(type: any, props: ?Object, ...children: Array): void; - declare var PropTypes: PropTypesObject; + declare var PropTypes: { + instanceOf(obj: any): void; + arrayOf(obj: any): void; + string: {isRequired: void}; + any: {isRequired: void}; + object: {isRequired: void}; + bool: {isRequired: void}; + array: {isRequired: void}; + number: {isRequired: void}; + func: {isRequired: void}; + }; declare class Component {} } -declare module 'react/lib/ReactWithAddons' { - declare function createElement(type: any, props: ?Object, ...children: Array): void; - declare var PropTypes: PropTypesObject; - declare class Component {} - declare var addons: { - shallowCompare: (component: any, props: Object, state: Object) => boolean - }; +declare module 'react/lib/shallowCompare' { + declare function exports(component: any, props: Object, state: Object): boolean; } diff --git a/interfaces/sinon-chai.js b/interfaces/sinon-chai.js index 98de572..2d0504e 100644 --- a/interfaces/sinon-chai.js +++ b/interfaces/sinon-chai.js @@ -1,3 +1,5 @@ /* @flow */ +/* eslint-disable no-empty */ + declare module 'sinon-chai' {} diff --git a/interfaces/sinon.js b/interfaces/sinon.js index 959823b..ee4e0a5 100644 --- a/interfaces/sinon.js +++ b/interfaces/sinon.js @@ -6,15 +6,19 @@ type Spy = { }; type Stub = { - returns: (obj: any) => any, - returnsArg: (i: number) => any, - throws: (err: Error) => any, - callsArg: (i: number) => any, - callsArgWith: (i: number, ...args: Array) => any + returns(obj: any): any; + returnsArg(i: number): any; + throws(err: Error): any; + callsArg(i: number): any; + callsArgWith(i: number, ...args: Array): any; }; declare module 'sinon' { declare function spy(obj: ?any, method: ?string): Spy; declare function stub(obj: ?any, method: ?string, func: ?(...args: Array) => any): Stub; - declare var match: {(callback: (value: any) => boolean): void, func: void, instanceOf: (obj: any) => void}; + declare var match: { + (callback: (value: any) => boolean): void; + func: void; + instanceOf(obj: any): void; + }; } diff --git a/interfaces/tiny-lr.js b/interfaces/tiny-lr.js index e9d06a9..9fd8a72 100644 --- a/interfaces/tiny-lr.js +++ b/interfaces/tiny-lr.js @@ -1,5 +1,8 @@ /* @flow */ declare module 'tiny-lr' { - declare function exports(): {changed: (config: Object) => void, listen: (port: number) => void}; + declare function exports(): { + changed(config: Object): void; + listen(port: number): void; + }; } diff --git a/interfaces/webpack.js b/interfaces/webpack.js index e51b478..fe42199 100644 --- a/interfaces/webpack.js +++ b/interfaces/webpack.js @@ -1,6 +1,11 @@ /* @flow */ -type WebPackStats = {toJson: () => {errors: Array, warnings: Array}}; +type WebPackStats = { + toJson(): { + errors: Array; + warnings: Array; + }; +}; type WebPackCallback = (error: ?string, stats: WebPackStats) => void; declare module 'webpack' {