From 838b2b4aa25729fafc4567dafbac31258a7835fe Mon Sep 17 00:00:00 2001 From: Carlos Date: Thu, 4 Oct 2018 22:57:14 +0800 Subject: [PATCH] CI: setup lint --- .gitignore | 1 + package.json | 2 ++ src/Themes.tsx | 16 +++++++------- src/withThemesProvider.tsx | 2 +- tslint.json | 42 +++++++++++++++++++++++++++++++++++++ yarn.lock | 43 +++++++++++++++++++++++++++++++++++--- 6 files changed, 94 insertions(+), 12 deletions(-) create mode 100644 tslint.json diff --git a/.gitignore b/.gitignore index 87a7e6e..fc81671 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ node_modules dist .idea coverage +yarn-error.log diff --git a/package.json b/package.json index 99351b5..f7b9108 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,7 @@ "scripts": { "clean": "rimraf dist", "build": "npm run clean && tsc -p .", + "pretest": "tslint -p .", "test": "jest", "prepare": "npm run build" }, @@ -34,6 +35,7 @@ "sinon": "^6.2.0", "styled-components": "^3.3.2", "ts-jest": "^23.1.4", + "tslint": "^5.11.0", "typescript": "^2.9.2" }, "peerDependencies": { diff --git a/src/Themes.tsx b/src/Themes.tsx index 2d55962..12299f9 100644 --- a/src/Themes.tsx +++ b/src/Themes.tsx @@ -6,7 +6,7 @@ import {Theme} from "./types/Theme"; export interface ThemeProps { channel: any; api: any; - active: Boolean; + active: boolean; } interface ThemeState { @@ -25,13 +25,13 @@ type BaseComponentProps = ThemeProps & ThemeState & ThemeHandler; const BaseComponent: React.SFC = ({onSelectTheme, themes, theme, active}) => ( active ? ( -
- {themes.map((th, i) => { - const buttonStyle = th === theme ? SelectedButtonStyle : ButtonStyle; - return
onSelectTheme(th)}>{th.name}
; - }).toArray()} -
) - : (
) +
+ {themes.map((th, i) => { + const buttonStyle = th === theme ? SelectedButtonStyle : ButtonStyle; + return
onSelectTheme(th)}>{th.name}
; + }).toArray()} +
+ ) : (
) ); export const Themes = compose( diff --git a/src/withThemesProvider.tsx b/src/withThemesProvider.tsx index 41bcd9a..1df0c67 100644 --- a/src/withThemesProvider.tsx +++ b/src/withThemesProvider.tsx @@ -1,6 +1,6 @@ import {List} from "immutable"; import * as React from "react"; -import {makeDecorator} from '@storybook/addons'; +import {makeDecorator} from "@storybook/addons"; import {ThemesProvider} from "./ThemesProvider"; import {Theme} from "./types/Theme"; diff --git a/tslint.json b/tslint.json new file mode 100644 index 0000000..46f208d --- /dev/null +++ b/tslint.json @@ -0,0 +1,42 @@ +{ + "extends": [ + "tslint:latest" + ], + "rules": { + "max-line-length": [ + true, + 150 + ], + "no-submodule-imports": false, + "no-empty-interface": false, + "no-console": false, + "no-var-requires": false, + "no-unused-expression": false, + "no-bitwise": false, + "no-implicit-dependencies": false, + "no-conditional-assignment": false, + "triple-equals": false, + "interface-name": false, + "object-literal-sort-keys": false, + "object-literal-key-quotes": [true, "as-needed"], + "prefer-object-spread": false, + "jsx-no-multiline-js": false, + "ordered-imports": false, + "member-ordering": [ + true, + { + "order": [ + "private-static-field", + "public-static-field", + "public-instance-field", + "public-constructor", + "private-instance-field", + "private-constructor", + "public-instance-method", + "protected-instance-method", + "private-instance-method" + ] + } + ] + } +} diff --git a/yarn.lock b/yarn.lock index 98b5598..3ee4482 100644 --- a/yarn.lock +++ b/yarn.lock @@ -244,7 +244,7 @@ aws4@^1.8.0: version "1.8.0" resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.8.0.tgz#f0e003d9ca9e7f59c7a508945d7b2ef9a04a542f" -babel-code-frame@^6.26.0: +babel-code-frame@^6.22.0, babel-code-frame@^6.26.0: version "6.26.0" resolved "https://registry.yarnpkg.com/babel-code-frame/-/babel-code-frame-6.26.0.tgz#63fd43f7dc1e3bb7ce35947db8fe369a3f58c74b" dependencies: @@ -476,7 +476,7 @@ buffer@^5.0.3: base64-js "^1.0.2" ieee754 "^1.1.4" -builtin-modules@^1.0.0: +builtin-modules@^1.0.0, builtin-modules@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/builtin-modules/-/builtin-modules-1.1.1.tgz#270f076c5a72c02f5b65a47df94c5fe3a278892f" @@ -522,7 +522,7 @@ chalk@^1.1.3: strip-ansi "^3.0.0" supports-color "^2.0.0" -chalk@^2.0.0, chalk@^2.0.1: +chalk@^2.0.0, chalk@^2.0.1, chalk@^2.3.0: version "2.4.1" resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.1.tgz#18c49ab16a037b6eb0152cc83e3471338215b66e" dependencies: @@ -609,6 +609,10 @@ combined-stream@1.0.6, combined-stream@~1.0.6: dependencies: delayed-stream "~1.0.0" +commander@^2.12.1: + version "2.18.0" + resolved "https://registry.yarnpkg.com/commander/-/commander-2.18.0.tgz#2bf063ddee7c7891176981a2cc798e5754bc6970" + commander@~2.17.1: version "2.17.1" resolved "https://registry.yarnpkg.com/commander/-/commander-2.17.1.tgz#bd77ab7de6de94205ceacc72f1716d29f20a77bf" @@ -3054,6 +3058,12 @@ resolve@1.1.7: version "1.1.7" resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.1.7.tgz#203114d82ad2c5ed9e8e0411b3932875e889e97b" +resolve@^1.3.2: + version "1.8.1" + resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.8.1.tgz#82f1ec19a423ac1fbd080b0bab06ba36e84a7a26" + dependencies: + path-parse "^1.0.5" + ret@~0.1.10: version "0.1.15" resolved "https://registry.yarnpkg.com/ret/-/ret-0.1.15.tgz#b8a4825d5bdb1fc3f6f53c2bc33f81388681c7bc" @@ -3511,6 +3521,33 @@ ts-jest@^23.1.4: json5 "^0.5.0" lodash "^4.17.10" +tslib@^1.8.0, tslib@^1.8.1: + version "1.9.3" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.9.3.tgz#d7e4dd79245d85428c4d7e4822a79917954ca286" + +tslint@^5.11.0: + version "5.11.0" + resolved "https://registry.yarnpkg.com/tslint/-/tslint-5.11.0.tgz#98f30c02eae3cde7006201e4c33cb08b48581eed" + dependencies: + babel-code-frame "^6.22.0" + builtin-modules "^1.1.1" + chalk "^2.3.0" + commander "^2.12.1" + diff "^3.2.0" + glob "^7.1.1" + js-yaml "^3.7.0" + minimatch "^3.0.4" + resolve "^1.3.2" + semver "^5.3.0" + tslib "^1.8.0" + tsutils "^2.27.2" + +tsutils@^2.27.2: + version "2.29.0" + resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-2.29.0.tgz#32b488501467acbedd4b85498673a0812aca0b99" + dependencies: + tslib "^1.8.1" + tunnel-agent@^0.6.0: version "0.6.0" resolved "https://registry.yarnpkg.com/tunnel-agent/-/tunnel-agent-0.6.0.tgz#27a5dea06b36b04a0a9966774b290868f0fc40fd"