From 6e24ba42a228289ae3c058d1438fab9683e04d73 Mon Sep 17 00:00:00 2001 From: neverland Date: Tue, 13 Apr 2021 11:14:56 +0800 Subject: [PATCH] chore: setup eslint for prohibited syntax (#8516) --- .eslintrc | 18 +++++++++++++++++- packages/vant-eslint-config/index.js | 2 +- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/.eslintrc b/.eslintrc index d0707a444..467d458f1 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,4 +1,20 @@ { "root": true, - "extends": ["@vant"] + "extends": ["@vant"], + "overrides": [ + { + "files": ["src/**/*"], + "excludedFiles": ["**/test/*", "**/demo/*"], + "rules": { + "prefer-object-spread": "off", + // since we target ES2015 for baseline support, we need to forbid object + // rest spread usage (both assign and destructure) + "no-restricted-syntax": [ + "error", + "ObjectExpression > SpreadElement", + "ObjectPattern > RestElement" + ] + } + } + ] } diff --git a/packages/vant-eslint-config/index.js b/packages/vant-eslint-config/index.js index 9cf0701fc..124ec37fa 100644 --- a/packages/vant-eslint-config/index.js +++ b/packages/vant-eslint-config/index.js @@ -69,7 +69,7 @@ module.exports = { overrides: [ { files: ['*.vue'], - parser: require.resolve('vue-eslint-parser') + parser: require.resolve('vue-eslint-parser'), }, { files: ['**/*.md/*.js', '**/*.md/*.ts'],