diff --git a/package.json b/package.json index 73f180b5f..599149834 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "scripts": { "bootstrap": "yarn || npm i", "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: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", @@ -76,7 +76,7 @@ "@babel/preset-env": "^7.3.1", "@babel/preset-typescript": "^7.1.0", "@vant/doc": "^1.0.23", - "@vant/eslint-config": "^1.0.8", + "@vant/eslint-config": "^1.1.0", "@vant/markdown-loader": "^1.0.3", "@vue/babel-preset-jsx": "^1.0.0-beta.2", "@vue/server-test-utils": "^1.0.0-beta.29", diff --git a/packages/button/index.tsx b/packages/button/index.tsx index 1b9b19d47..67449bbdf 100644 --- a/packages/button/index.tsx +++ b/packages/button/index.tsx @@ -1,15 +1,14 @@ import { use } from '../utils'; import { emit, inherit } from '../utils/functional'; -import { routeProps, functionalRoute } from '../mixins/router'; +import { routeProps, RouteProps, functionalRoute } from '../mixins/router'; import Loading from '../loading'; // Types -import { RouteProps } from '../mixins/router'; import { FunctionalComponent } from '../utils/use/sfc'; const [sfc, bem] = use('button'); -const Button: FunctionalComponent = function( +const Button: FunctionalComponent = function ( h, props, slots, diff --git a/packages/cell/index.tsx b/packages/cell/index.tsx index 985513674..cb2b35c1d 100644 --- a/packages/cell/index.tsx +++ b/packages/cell/index.tsx @@ -1,17 +1,16 @@ import { use, isDef } from '../utils'; -import { cellProps } from './shared'; +import { cellProps, SharedCellProps } from './shared'; import { emit, inherit } from '../utils/functional'; import { routeProps, functionalRoute } from '../mixins/router'; import Icon from '../icon'; // Types -import { SharedCellProps } from './shared'; import { FunctionalComponent } from '../utils/use/sfc'; import { Mods } from '../utils/use/bem'; const [sfc, bem] = use('cell'); -const Cell: FunctionalComponent = function(h, props, slots, ctx) { +const Cell: FunctionalComponent = function (h, props, slots, ctx) { const { icon, size, title, label, value, isLink, arrowDirection } = props; const showTitle = slots.title || isDef(title); @@ -78,7 +77,7 @@ const Cell: FunctionalComponent = function(h, props, slots, ctx) { {slots.extra && slots.extra()} ); -} +}; export type CellProps = SharedCellProps & { size?: string; diff --git a/packages/icon/index.tsx b/packages/icon/index.tsx index 93dd0fd53..8300e3385 100644 --- a/packages/icon/index.tsx +++ b/packages/icon/index.tsx @@ -8,7 +8,7 @@ import { FunctionalComponent } from '../utils/use/sfc'; const [sfc] = use('icon'); -const Icon: FunctionalComponent = function(h, props, slots, ctx) { +const Icon: FunctionalComponent = function (h, props, slots, ctx) { const urlIcon = isSrc(props.name); return ( diff --git a/packages/info/index.tsx b/packages/info/index.tsx index d05413c1a..0a71263aa 100644 --- a/packages/info/index.tsx +++ b/packages/info/index.tsx @@ -6,7 +6,7 @@ import { FunctionalComponent } from '../utils/use/sfc'; const [sfc, bem] = use('info'); -const Info: FunctionalComponent = function(h, props, slots, ctx) { +const Info: FunctionalComponent = function (h, props, slots, ctx) { if (!isDef(props.info)) { return; } diff --git a/packages/loading/index.tsx b/packages/loading/index.tsx index fbd64155e..e0374e5f6 100644 --- a/packages/loading/index.tsx +++ b/packages/loading/index.tsx @@ -7,7 +7,7 @@ import { FunctionalComponent } from '../utils/use/sfc'; const [sfc, bem] = use('loading'); const DEFAULT_COLOR = '#c9c9c9'; -const Loading: FunctionalComponent = function( +const Loading: FunctionalComponent = function ( h, props, slots, diff --git a/packages/tag/index.tsx b/packages/tag/index.tsx index 10b231326..4e9c91dd1 100644 --- a/packages/tag/index.tsx +++ b/packages/tag/index.tsx @@ -13,7 +13,7 @@ const COLOR_MAP: { [key: string]: string } = { success: GREEN }; -const Tag: FunctionalComponent = function(h, props, slots, ctx) { +const Tag: FunctionalComponent = function (h, props, slots, ctx) { const { type, mark, plain, round, size } = ctx.props; const color = props.color || (type && COLOR_MAP[type]) || GRAY_DARK; diff --git a/packages/utils/use/sfc.ts b/packages/utils/use/sfc.ts index 9abda939d..5bcfdbeb1 100644 --- a/packages/utils/use/sfc.ts +++ b/packages/utils/use/sfc.ts @@ -28,7 +28,7 @@ export type ModelOptions = { export interface VantComponentOptions extends ComponentOptions { functional?: boolean; install?: (Vue: VueConstructor) => void; -}; +} export type DefaultProps = Record; diff --git a/yarn.lock b/yarn.lock index 5c41b510c..95184371d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -777,6 +777,32 @@ "@types/unist" "*" "@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": version "1.0.23" resolved "https://registry.yarnpkg.com/@vant/doc/-/doc-1.0.23.tgz#401752f576f39e46ac8dacf6225906a2355b8093" @@ -789,11 +815,13 @@ nprogress "^0.2.0" shelljs "^0.8.2" -"@vant/eslint-config@^1.0.8": - version "1.0.9" - resolved "https://registry.yarnpkg.com/@vant/eslint-config/-/eslint-config-1.0.9.tgz#c72460dc134366208461a1ec8643317c035cde28" - integrity sha512-DgBBKRugX6GU/CVp0UsR2426iZtQa8sOHZgBuRwdEWS5O7OlSlSO849EVXT4ACCriDzWCgJL8zpQGNGeUA3GlA== +"@vant/eslint-config@^1.1.0": + version "1.1.0" + resolved "https://registry.yarnpkg.com/@vant/eslint-config/-/eslint-config-1.1.0.tgz#27b7f3892a0859245186fd415deca1e2be5cb954" + integrity sha512-3c+A4PUQIn/7gDV1N2yaUv27wb24LwX0RPBMvH2sdV336ZYotL9XgdzelgtdaxLA4dq/77UsyVzvuGzjJUKUKQ== dependencies: + "@typescript-eslint/eslint-plugin" "^1.3.0" + "@typescript-eslint/parser" "^1.3.0" babel-eslint "^10.0.1" eslint-config-airbnb-base "^13.1.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" 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: version "3.1.1" 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" yargs-parser "10.x" -tslib@^1.9.0: +tslib@^1.8.1, tslib@^1.9.0: version "1.9.3" resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.9.3.tgz#d7e4dd79245d85428c4d7e4822a79917954ca286" 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: version "0.0.0" resolved "https://registry.yarnpkg.com/tty-browserify/-/tty-browserify-0.0.0.tgz#a157ba402da24e9bf957f9aa69d524eed42901a6"