[improvement] lint ts/tsx files (#2776)

This commit is contained in:
neverland 2019-02-18 14:45:31 +08:00 committed by GitHub
parent 29fad2235a
commit 0013185d38
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 57 additions and 19 deletions

View File

@ -16,7 +16,7 @@
"scripts": { "scripts": {
"bootstrap": "yarn || npm i", "bootstrap": "yarn || npm i",
"dev": "npm run build:entry && webpack-serve --config build/webpack.dev.js", "dev": "npm run build:entry && webpack-serve --config build/webpack.dev.js",
"lint": "eslint ./packages --ext .js,.vue && stylelint \"packages/*.css\"", "lint": "eslint ./packages --ext .js,.vue,.ts,.tsx && stylelint \"packages/*.css\"",
"build:entry": "node build/build-entry.js", "build:entry": "node build/build-entry.js",
"build:components": "node build/build-components.js --color", "build:components": "node build/build-components.js --color",
"build:vant": "cross-env NODE_ENV=production webpack --color --config build/webpack.build.js && cross-env NODE_ENV=production webpack -p --color --config build/webpack.build.js", "build:vant": "cross-env NODE_ENV=production webpack --color --config build/webpack.build.js && cross-env NODE_ENV=production webpack -p --color --config build/webpack.build.js",
@ -76,7 +76,7 @@
"@babel/preset-env": "^7.3.1", "@babel/preset-env": "^7.3.1",
"@babel/preset-typescript": "^7.1.0", "@babel/preset-typescript": "^7.1.0",
"@vant/doc": "^1.0.23", "@vant/doc": "^1.0.23",
"@vant/eslint-config": "^1.0.8", "@vant/eslint-config": "^1.1.0",
"@vant/markdown-loader": "^1.0.3", "@vant/markdown-loader": "^1.0.3",
"@vue/babel-preset-jsx": "^1.0.0-beta.2", "@vue/babel-preset-jsx": "^1.0.0-beta.2",
"@vue/server-test-utils": "^1.0.0-beta.29", "@vue/server-test-utils": "^1.0.0-beta.29",

View File

@ -1,15 +1,14 @@
import { use } from '../utils'; import { use } from '../utils';
import { emit, inherit } from '../utils/functional'; import { emit, inherit } from '../utils/functional';
import { routeProps, functionalRoute } from '../mixins/router'; import { routeProps, RouteProps, functionalRoute } from '../mixins/router';
import Loading from '../loading'; import Loading from '../loading';
// Types // Types
import { RouteProps } from '../mixins/router';
import { FunctionalComponent } from '../utils/use/sfc'; import { FunctionalComponent } from '../utils/use/sfc';
const [sfc, bem] = use('button'); const [sfc, bem] = use('button');
const Button: FunctionalComponent<ButtonProps> = function( const Button: FunctionalComponent<ButtonProps> = function (
h, h,
props, props,
slots, slots,

View File

@ -1,17 +1,16 @@
import { use, isDef } from '../utils'; import { use, isDef } from '../utils';
import { cellProps } from './shared'; import { cellProps, SharedCellProps } from './shared';
import { emit, inherit } from '../utils/functional'; import { emit, inherit } from '../utils/functional';
import { routeProps, functionalRoute } from '../mixins/router'; import { routeProps, functionalRoute } from '../mixins/router';
import Icon from '../icon'; import Icon from '../icon';
// Types // Types
import { SharedCellProps } from './shared';
import { FunctionalComponent } from '../utils/use/sfc'; import { FunctionalComponent } from '../utils/use/sfc';
import { Mods } from '../utils/use/bem'; import { Mods } from '../utils/use/bem';
const [sfc, bem] = use('cell'); const [sfc, bem] = use('cell');
const Cell: FunctionalComponent<CellProps> = function(h, props, slots, ctx) { const Cell: FunctionalComponent<CellProps> = function (h, props, slots, ctx) {
const { icon, size, title, label, value, isLink, arrowDirection } = props; const { icon, size, title, label, value, isLink, arrowDirection } = props;
const showTitle = slots.title || isDef(title); const showTitle = slots.title || isDef(title);
@ -78,7 +77,7 @@ const Cell: FunctionalComponent<CellProps> = function(h, props, slots, ctx) {
{slots.extra && slots.extra()} {slots.extra && slots.extra()}
</div> </div>
); );
} };
export type CellProps = SharedCellProps & { export type CellProps = SharedCellProps & {
size?: string; size?: string;

View File

@ -8,7 +8,7 @@ import { FunctionalComponent } from '../utils/use/sfc';
const [sfc] = use('icon'); const [sfc] = use('icon');
const Icon: FunctionalComponent<IconProps> = function(h, props, slots, ctx) { const Icon: FunctionalComponent<IconProps> = function (h, props, slots, ctx) {
const urlIcon = isSrc(props.name); const urlIcon = isSrc(props.name);
return ( return (

View File

@ -6,7 +6,7 @@ import { FunctionalComponent } from '../utils/use/sfc';
const [sfc, bem] = use('info'); const [sfc, bem] = use('info');
const Info: FunctionalComponent<InfoProps> = function(h, props, slots, ctx) { const Info: FunctionalComponent<InfoProps> = function (h, props, slots, ctx) {
if (!isDef(props.info)) { if (!isDef(props.info)) {
return; return;
} }

View File

@ -7,7 +7,7 @@ import { FunctionalComponent } from '../utils/use/sfc';
const [sfc, bem] = use('loading'); const [sfc, bem] = use('loading');
const DEFAULT_COLOR = '#c9c9c9'; const DEFAULT_COLOR = '#c9c9c9';
const Loading: FunctionalComponent<LoadingProps> = function( const Loading: FunctionalComponent<LoadingProps> = function (
h, h,
props, props,
slots, slots,

View File

@ -13,7 +13,7 @@ const COLOR_MAP: { [key: string]: string } = {
success: GREEN success: GREEN
}; };
const Tag: FunctionalComponent<TagProps> = function(h, props, slots, ctx) { const Tag: FunctionalComponent<TagProps> = function (h, props, slots, ctx) {
const { type, mark, plain, round, size } = ctx.props; const { type, mark, plain, round, size } = ctx.props;
const color = props.color || (type && COLOR_MAP[type]) || GRAY_DARK; const color = props.color || (type && COLOR_MAP[type]) || GRAY_DARK;

View File

@ -28,7 +28,7 @@ export type ModelOptions = {
export interface VantComponentOptions extends ComponentOptions<Vue> { export interface VantComponentOptions extends ComponentOptions<Vue> {
functional?: boolean; functional?: boolean;
install?: (Vue: VueConstructor) => void; install?: (Vue: VueConstructor) => void;
}; }
export type DefaultProps = Record<string, any>; export type DefaultProps = Record<string, any>;

View File

@ -777,6 +777,32 @@
"@types/unist" "*" "@types/unist" "*"
"@types/vfile-message" "*" "@types/vfile-message" "*"
"@typescript-eslint/eslint-plugin@^1.3.0":
version "1.3.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-1.3.0.tgz#e64c859a3eec10d96731eb5f72b5f48796a2f9ad"
integrity sha512-s+vjO9+PvYS2A6FnQC/imyEDOkrEKIzSpPf2OEGnkKqa5+1d0cuXgCi/oROtuBht2/u/iK22nrYcO/Ei4R8F/g==
dependencies:
"@typescript-eslint/parser" "1.3.0"
requireindex "^1.2.0"
tsutils "^3.7.0"
"@typescript-eslint/parser@1.3.0", "@typescript-eslint/parser@^1.3.0":
version "1.3.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-1.3.0.tgz#e61e795aa050351b7312a757e0864b6d90b84078"
integrity sha512-Q5cz9nyEQyRrtItRElvQXdNs0Xja1xvOdphDQR7N6MqUdi4juWVNxHKypdHQCx9OcEBev6pWHOda8lwg/2W9/g==
dependencies:
"@typescript-eslint/typescript-estree" "1.3.0"
eslint-scope "^4.0.0"
eslint-visitor-keys "^1.0.0"
"@typescript-eslint/typescript-estree@1.3.0":
version "1.3.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-1.3.0.tgz#1d1f36680e5c32c3af38c1180153f018152f65f9"
integrity sha512-h6UxHSmBUopFcxHg/eryrA+GwHMbh7PxotMbkq9p2f3nX60CKm5Zc0VN8krBD3IS5KqsK0iOz24VpEWrP+JZ2Q==
dependencies:
lodash.unescape "4.0.1"
semver "5.5.0"
"@vant/doc@^1.0.23": "@vant/doc@^1.0.23":
version "1.0.23" version "1.0.23"
resolved "https://registry.yarnpkg.com/@vant/doc/-/doc-1.0.23.tgz#401752f576f39e46ac8dacf6225906a2355b8093" resolved "https://registry.yarnpkg.com/@vant/doc/-/doc-1.0.23.tgz#401752f576f39e46ac8dacf6225906a2355b8093"
@ -789,11 +815,13 @@
nprogress "^0.2.0" nprogress "^0.2.0"
shelljs "^0.8.2" shelljs "^0.8.2"
"@vant/eslint-config@^1.0.8": "@vant/eslint-config@^1.1.0":
version "1.0.9" version "1.1.0"
resolved "https://registry.yarnpkg.com/@vant/eslint-config/-/eslint-config-1.0.9.tgz#c72460dc134366208461a1ec8643317c035cde28" resolved "https://registry.yarnpkg.com/@vant/eslint-config/-/eslint-config-1.1.0.tgz#27b7f3892a0859245186fd415deca1e2be5cb954"
integrity sha512-DgBBKRugX6GU/CVp0UsR2426iZtQa8sOHZgBuRwdEWS5O7OlSlSO849EVXT4ACCriDzWCgJL8zpQGNGeUA3GlA== integrity sha512-3c+A4PUQIn/7gDV1N2yaUv27wb24LwX0RPBMvH2sdV336ZYotL9XgdzelgtdaxLA4dq/77UsyVzvuGzjJUKUKQ==
dependencies: dependencies:
"@typescript-eslint/eslint-plugin" "^1.3.0"
"@typescript-eslint/parser" "^1.3.0"
babel-eslint "^10.0.1" babel-eslint "^10.0.1"
eslint-config-airbnb-base "^13.1.0" eslint-config-airbnb-base "^13.1.0"
eslint-plugin-import "^2.14.0" eslint-plugin-import "^2.14.0"
@ -8614,6 +8642,11 @@ require-main-filename@^1.0.1:
resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-1.0.1.tgz#97f717b69d48784f5f526a6c5aa8ffdda055a4d1" resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-1.0.1.tgz#97f717b69d48784f5f526a6c5aa8ffdda055a4d1"
integrity sha1-l/cXtp1IeE9fUmpsWqj/3aBVpNE= integrity sha1-l/cXtp1IeE9fUmpsWqj/3aBVpNE=
requireindex@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/requireindex/-/requireindex-1.2.0.tgz#3463cdb22ee151902635aa6c9535d4de9c2ef1ef"
integrity sha512-L9jEkOi3ASd9PYit2cwRfyppc9NoABujTP8/5gFcbERmo5jUoAKovIC3fsF17pkTnGsrByysqX+Kxd2OTNI1ww==
requirejs-config-file@^3.1.1: requirejs-config-file@^3.1.1:
version "3.1.1" version "3.1.1"
resolved "https://registry.yarnpkg.com/requirejs-config-file/-/requirejs-config-file-3.1.1.tgz#ccb8efbe2301c24ac0cf34dd3f3c862741750f5c" resolved "https://registry.yarnpkg.com/requirejs-config-file/-/requirejs-config-file-3.1.1.tgz#ccb8efbe2301c24ac0cf34dd3f3c862741750f5c"
@ -9770,11 +9803,18 @@ ts-jest@^23.10.5:
semver "^5.5" semver "^5.5"
yargs-parser "10.x" yargs-parser "10.x"
tslib@^1.9.0: tslib@^1.8.1, tslib@^1.9.0:
version "1.9.3" version "1.9.3"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.9.3.tgz#d7e4dd79245d85428c4d7e4822a79917954ca286" resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.9.3.tgz#d7e4dd79245d85428c4d7e4822a79917954ca286"
integrity sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ== integrity sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ==
tsutils@^3.7.0:
version "3.8.0"
resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-3.8.0.tgz#7a3dbadc88e465596440622b65c04edc8e187ae5"
integrity sha512-XQdPhgcoTbCD8baXC38PQ0vpTZ8T3YrE+vR66YIj/xvDt1//8iAhafpIT/4DmvzzC1QFapEImERu48Pa01dIUA==
dependencies:
tslib "^1.8.1"
tty-browserify@0.0.0: tty-browserify@0.0.0:
version "0.0.0" version "0.0.0"
resolved "https://registry.yarnpkg.com/tty-browserify/-/tty-browserify-0.0.0.tgz#a157ba402da24e9bf957f9aa69d524eed42901a6" resolved "https://registry.yarnpkg.com/tty-browserify/-/tty-browserify-0.0.0.tgz#a157ba402da24e9bf957f9aa69d524eed42901a6"