From 551e911eb4f82cec39958f2890973a5b3b085c6d Mon Sep 17 00:00:00 2001 From: Pan Date: Tue, 22 Aug 2017 15:43:34 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=A8=E5=B1=80lint=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .eslintrc.js | 408 ++++---------- build/webpack.base.conf.js | 18 +- src/App.vue | 4 +- src/api/article.js | 10 +- src/api/article_table.js | 10 +- src/api/login.js | 6 +- src/api/qiniu.js | 6 +- src/api/remoteSearch.js | 6 +- src/components/BackToTop/index.vue | 126 ++--- src/components/Charts/keyboard.vue | 208 ++++---- src/components/Charts/keyboard2.vue | 272 +++++----- src/components/Charts/lineMarker.vue | 420 +++++++-------- src/components/Charts/mixChart.vue | 499 +++++++++--------- src/components/Dropzone/index.vue | 348 ++++++------ src/components/ErrLog/index.vue | 22 +- src/components/Hamburger/index.vue | 22 +- src/components/Icon-svg/index.vue | 24 +- src/components/ImageCropper/lang.js | 4 +- src/components/MDinput/index.vue | 56 +- src/components/MdEditor/index.vue | 126 ++--- src/components/PanThumb/index.vue | 40 +- src/components/Screenfull/index.vue | 60 +-- src/components/SplitPane/Pane.vue | 14 +- src/components/SplitPane/Resizer.vue | 32 +- src/components/SplitPane/index.vue | 138 ++--- src/components/Sticky/index.vue | 118 ++--- src/components/Tinymce/index.vue | 217 ++++---- src/components/TodoList/index.vue | 2 - src/components/Upload/singleImage.vue | 73 +-- src/components/Upload/singleImage2.vue | 37 +- src/components/Upload/singleImage3.vue | 36 +- src/components/jsonEditor/index.vue | 84 +-- src/components/twoDndList/index.vue | 120 ++--- src/directive/sticky.js | 74 +-- src/directive/waves.js | 52 +- src/errorLog.js | 4 +- src/filters/index.js | 50 +- src/main.js | 2 - src/mock/article.js | 12 +- src/mock/article_table.js | 26 +- src/mock/login.js | 14 +- src/mock/remoteSearch.js | 20 +- src/permission.js | 2 +- src/router/index.js | 18 +- src/store/errLog.js | 6 +- src/store/getters.js | 2 +- src/store/index.js | 16 +- src/store/modules/app.js | 12 +- src/store/modules/permission.js | 8 +- src/store/modules/user.js | 112 ++-- src/utils/createUniqueString.js | 6 +- src/utils/fetch.js | 26 +- src/utils/index.js | 207 ++++---- src/utils/openWindow.js | 17 +- src/utils/validate.js | 19 +- src/views/charts/keyboard.vue | 8 +- src/views/charts/keyboard2.vue | 8 +- src/views/charts/line.vue | 8 +- src/views/charts/mixChart.vue | 8 +- src/views/components/avatarUpload.vue | 42 +- src/views/components/backToTop.vue | 29 +- src/views/components/countTo.vue | 131 ++--- src/views/components/dndlist.vue | 46 +- src/views/components/dropzone.vue | 26 +- src/views/components/jsoneditor.vue | 18 +- src/views/components/markdown.vue | 34 +- src/views/components/mixin.vue | 26 +- src/views/components/splitpane.vue | 16 +- src/views/components/sticky.vue | 30 +- src/views/components/tinymce.vue | 16 +- src/views/dashboard/default/index.vue | 32 +- src/views/dashboard/editor/barChart.vue | 167 +++--- src/views/dashboard/editor/index.vue | 47 +- src/views/dashboard/editor/lineChart.vue | 202 +++---- src/views/dashboard/editor/pieChart.vue | 122 ++--- src/views/dashboard/index.vue | 48 +- src/views/errlog/index.vue | 8 +- src/views/error/401.vue | 35 +- src/views/error/404.vue | 26 +- src/views/example/form.vue | 254 ++++----- src/views/example/tab/components/tabPane.vue | 84 +-- src/views/example/tab/index.vue | 32 +- src/views/example/table/dragTable.vue | 106 ++-- src/views/example/table/dynamictable.vue | 10 +- .../example/table/dynamictable/fixedThead.vue | 61 +-- .../table/dynamictable/unfixedThead.vue | 40 +- src/views/example/table/inlineEditTable.vue | 72 +-- src/views/example/table/table.vue | 364 ++++++------- src/views/excel/index.vue | 70 +-- src/views/excel/selectExcel.vue | 90 ++-- src/views/layout/AppMain.vue | 2 +- src/views/layout/Layout.vue | 24 +- src/views/layout/Levelbar.vue | 44 +- src/views/layout/Navbar.vue | 70 +-- src/views/layout/Sidebar.vue | 24 +- src/views/layout/SidebarItem.vue | 12 +- src/views/layout/TabsView.vue | 52 +- src/views/layout/index.js | 8 +- src/views/login/authredirect.vue | 8 +- src/views/login/index.vue | 124 ++--- src/views/login/socialsignin.vue | 36 +- src/views/permission/index.vue | 37 +- src/views/qiniu/upload.vue | 50 +- src/views/theme/index.vue | 81 ++- 104 files changed, 3487 insertions(+), 3672 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index a388ba27..006e9824 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -6,7 +6,8 @@ module.exports = { }, env: { browser: true, - node: true + node: true, + es6: true, }, extends: 'eslint:recommended', // required to lint *.vue files @@ -22,297 +23,122 @@ module.exports = { } }, // add your custom rules here + //it is base on https://github.com/vuejs/eslint-config-vue 'rules': { - // don't require .vue extension when importing - // 'import/extensions': ['error', 'always', { - // 'js': 'never', - // 'vue': 'never' - // }], - // allow debugger during development - 'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0, - /* - * Possible Errors - */ - - // disallow unnecessary parentheses - 'no-extra-parens': ['error', 'all', {'nestedBinaryExpressions': false}], - - // disallow negating the left operand of relational operators - 'no-unsafe-negation': 'error', - - // enforce valid JSDoc comments - 'valid-jsdoc': 'off', - - /* - * Best Practices - */ - - // enforce return statements in callbacks of array methods - 'array-callback-return': 'error', - - // enforce consistent brace style for all control statements - curly: ['error', 'multi-line'], - - // enforce consistent newlines before and after dots - 'dot-location': ['error', 'property'], - - // enforce dot notation whenever possible - 'dot-notation': 'error', - - // require the use of === and !== - 'eqeqeq': ['error', 'smart'], - - // disallow the use of arguments.caller or arguments.callee - 'no-caller': 'error', - - // disallow empty functions - 'no-empty-function': 'error', - - // disallow unnecessary calls to .bind() - 'no-extra-bind': 'error', - - // disallow unnecessary labels - 'no-extra-label': 'error', - - // disallow leading or trailing decimal points in numeric literals - 'no-floating-decimal': 'error', - - // disallow assignments to native objects or read-only global variables - 'no-global-assign': 'error', - - // disallow the use of eval()-like methods - 'no-implied-eval': 'error', - - // disallow the use of the __iterator__ property - 'no-iterator': 'error', - - // disallow unnecessary nested blocks - 'no-lone-blocks': 'error', - - // disallow multiple spaces - 'no-multi-spaces': 'error', - - // disallow new operators with the String, Number, and Boolean objects - 'no-new-wrappers': 'error', - - // disallow octal escape sequences in string literals - 'no-octal-escape': 'error', - - // disallow the use of the __proto__ property - 'no-proto': 'error', - - // disallow comparisons where both sides are exactly the same - 'no-self-compare': 'error', - - // disallow throwing literals as exceptions - 'no-throw-literal': 'error', - - // disallow unused expressions - 'no-unused-expressions': 'error', - - // disallow unnecessary calls to .call() and .apply() - 'no-useless-call': 'error', - - // disallow unnecessary concatenation of literals or template literals - 'no-useless-concat': 'error', - - // disallow unnecessary escape characters - 'no-useless-escape': 'error', - - // disallow void operators - 'no-void': 'error', - - // require parentheses around immediate function invocations - 'wrap-iife': 'error', - - // require or disallow “Yoda” conditions - yoda: 'error', - - /* - * Variables - */ - - // disallow labels that share a name with a variable - 'no-label-var': 'error', - - // disallow initializing variables to undefined - 'no-undef-init': 'error', - 'no-undef': 'off', - // disallow the use of variables before they are defined - 'no-use-before-define': 'error', - - /* - * Node.js and CommonJS - */ - - // disallow new operators with calls to require - 'no-new-require': 'error', - - /* - * Stylistic Issues - */ - - // enforce consistent spacing inside array brackets - 'array-bracket-spacing': 'error', - - // enforce consistent spacing inside single-line blocks - 'block-spacing': 'error', - - // enforce consistent brace style for blocks - 'brace-style': ['error', '1tbs', {'allowSingleLine': true}], - - // require or disallow trailing commas - 'comma-dangle': 'error', - - // enforce consistent spacing before and after commas - 'comma-spacing': 'error', - - // enforce consistent comma style - 'comma-style': 'error', - - // enforce consistent spacing inside computed property brackets - 'computed-property-spacing': 'error', - - // require or disallow spacing between function identifiers and their invocations - 'func-call-spacing': 'error', - - // enforce consistent indentation - indent: ['error', 2, {SwitchCase: 1}], - - // enforce the consistent use of either double or single quotes in JSX attributes - 'jsx-quotes': 'error', - - // enforce consistent spacing between keys and values in object literal properties - 'key-spacing': 'error', - - // enforce consistent spacing before and after keywords - 'keyword-spacing': 'error', - - // enforce consistent linebreak style - 'linebreak-style': 'error', - - // require or disallow newlines around directives - 'lines-around-directive': 'error', - - // require constructor names to begin with a capital letter - 'new-cap': 'off', - - // require parentheses when invoking a constructor with no arguments - 'new-parens': 'error', - - // disallow Array constructors - 'no-array-constructor': 'error', - - // disallow Object constructors - 'no-new-object': 'error', - - // disallow trailing whitespace at the end of lines - 'no-trailing-spaces': 'error', - - // disallow ternary operators when simpler alternatives exist - 'no-unneeded-ternary': 'error', - - // disallow whitespace before properties - 'no-whitespace-before-property': 'error', - - // enforce consistent spacing inside braces - 'object-curly-spacing': ['error', 'always'], - - // require or disallow padding within blocks - 'padded-blocks': ['error', 'never'], - - // require quotes around object literal property names - 'quote-props': ['error', 'as-needed'], - - // enforce the consistent use of either backticks, double, or single quotes - quotes: ['error', 'single'], - - // enforce consistent spacing before and after semicolons - 'semi-spacing': 'error', - - // require or disallow semicolons instead of ASI - // semi: ['error', 'never'], - - // enforce consistent spacing before blocks - 'space-before-blocks': 'error', - + 'accessor-pairs': 2, + 'arrow-spacing': [2, { 'before': true, 'after': true }], + 'block-spacing': [2, 'always'], + 'brace-style': [2, '1tbs', { 'allowSingleLine': true }], + 'camelcase': [0, { 'properties': 'always' }], + 'comma-dangle': [2, 'never'], + 'comma-spacing': [2, { 'before': false, 'after': true }], + 'comma-style': [2, 'last'], + 'constructor-super': 2, + 'curly': [2, 'multi-line'], + 'dot-location': [2, 'property'], + 'eol-last': 2, + 'eqeqeq': [2, 'allow-null'], + 'generator-star-spacing': [2, { 'before': true, 'after': true }], + 'handle-callback-err': [2, '^(err|error)$' ], + 'indent': [2, 2, { 'SwitchCase': 1 }], + 'jsx-quotes': [2, 'prefer-single'], + 'key-spacing': [2, { 'beforeColon': false, 'afterColon': true }], + 'keyword-spacing': [2, { 'before': true, 'after': true }], + 'new-cap': [2, { 'newIsCap': true, 'capIsNew': false }], + 'new-parens': 2, + 'no-array-constructor': 2, + 'no-caller': 2, 'no-console': 'off', - - // enforce consistent spacing before function definition opening parenthesis - 'space-before-function-paren': ['error', 'never'], - - // enforce consistent spacing inside parentheses - 'space-in-parens': 'error', - - // require spacing around infix operators - 'space-infix-ops': 'error', - - // enforce consistent spacing before or after unary operators - 'space-unary-ops': 'error', - - // enforce consistent spacing after the // or /* in a comment - 'spaced-comment': 'error', - - // require or disallow Unicode byte order mark (BOM) - 'unicode-bom': 'error', - - - /* - * ECMAScript 6 - */ - - // require braces around arrow function bodies - 'arrow-body-style': 'error', - - // require parentheses around arrow function arguments - 'arrow-parens': ['error', 'as-needed'], - - // enforce consistent spacing before and after the arrow in arrow functions - 'arrow-spacing': 'error', - - // enforce consistent spacing around * operators in generator functions - 'generator-star-spacing': ['error', 'after'], - - // disallow duplicate module imports - 'no-duplicate-imports': 'error', - - // disallow unnecessary computed property keys in object literals - 'no-useless-computed-key': 'error', - - // disallow unnecessary constructors - 'no-useless-constructor': 'error', - - // disallow renaming import, export, and destructured assignments to the same name - 'no-useless-rename': 'error', - - // require let or const instead of var - 'no-var': 'error', - - // require or disallow method and property shorthand syntax for object literals - 'object-shorthand': 'error', - - // require arrow functions as callbacks - 'prefer-arrow-callback': 'error', - - // require const declarations for variables that are never reassigned after declared - 'prefer-const': 'error', - - // disallow parseInt() in favor of binary, octal, and hexadecimal literals - 'prefer-numeric-literals': 'error', - - // require rest parameters instead of arguments - 'prefer-rest-params': 'error', - - // require spread operators instead of .apply() - 'prefer-spread': 'error', - - // enforce spacing between rest and spread operators and their expressions - 'rest-spread-spacing': 'error', - - // require or disallow spacing around embedded expressions of template strings - 'template-curly-spacing': 'error', - - // require or disallow spacing around the * in yield* expressions - 'yield-star-spacing': 'error' + 'no-class-assign': 2, + 'no-cond-assign': 2, + 'no-const-assign': 2, + 'no-control-regex': 2, + 'no-delete-var': 2, + 'no-dupe-args': 2, + 'no-dupe-class-members': 2, + 'no-dupe-keys': 2, + 'no-duplicate-case': 2, + 'no-empty-character-class': 2, + 'no-empty-pattern': 2, + 'no-eval': 2, + 'no-ex-assign': 2, + 'no-extend-native': 2, + 'no-extra-bind': 2, + 'no-extra-boolean-cast': 2, + 'no-extra-parens': [2, 'functions'], + 'no-fallthrough': 2, + 'no-floating-decimal': 2, + 'no-func-assign': 2, + 'no-implied-eval': 2, + 'no-inner-declarations': [2, 'functions'], + 'no-invalid-regexp': 2, + 'no-irregular-whitespace': 2, + 'no-iterator': 2, + 'no-label-var': 2, + 'no-labels': [2, { 'allowLoop': false, 'allowSwitch': false }], + 'no-lone-blocks': 2, + 'no-mixed-spaces-and-tabs': 2, + 'no-multi-spaces': 2, + 'no-multi-str': 2, + 'no-multiple-empty-lines': [2, { 'max': 1 }], + 'no-native-reassign': 2, + 'no-negated-in-lhs': 2, + 'no-new-object': 2, + 'no-new-require': 2, + 'no-new-symbol': 2, + 'no-new-wrappers': 2, + 'no-obj-calls': 2, + 'no-octal': 2, + 'no-octal-escape': 2, + 'no-path-concat': 2, + 'no-proto': 2, + 'no-redeclare': 2, + 'no-regex-spaces': 2, + 'no-return-assign': [2, 'except-parens'], + 'no-self-assign': 2, + 'no-self-compare': 2, + 'no-sequences': 2, + 'no-shadow-restricted-names': 2, + 'no-spaced-func': 2, + 'no-sparse-arrays': 2, + 'no-this-before-super': 2, + 'no-throw-literal': 2, + 'no-trailing-spaces': 2, + 'no-undef': 2, + 'no-undef-init': 2, + 'no-unexpected-multiline': 2, + 'no-unmodified-loop-condition': 2, + 'no-unneeded-ternary': [2, { 'defaultAssignment': false }], + 'no-unreachable': 2, + 'no-unsafe-finally': 2, + 'no-unused-vars': [2, { 'vars': 'all', 'args': 'none' }], + 'no-useless-call': 2, + 'no-useless-computed-key': 2, + 'no-useless-constructor': 2, + 'no-useless-escape': 0, + 'no-whitespace-before-property': 2, + 'no-with': 2, + 'one-var': [2, { 'initialized': 'never' }], + 'operator-linebreak': [2, 'after', { 'overrides': { '?': 'before', ':': 'before' } }], + 'padded-blocks': [2, 'never'], + 'quotes': [2, 'single', { 'avoidEscape': true, 'allowTemplateLiterals': true }], + 'semi': [2, 'never'], + 'semi-spacing': [2, { 'before': false, 'after': true }], + 'space-before-blocks': [2, 'always'], + 'space-before-function-paren': [2, 'never'], + 'space-in-parens': [2, 'never'], + 'space-infix-ops': 2, + 'space-unary-ops': [2, { 'words': true, 'nonwords': false }], + 'spaced-comment': [2, 'always', { 'markers': ['global', 'globals', 'eslint', 'eslint-disable', '*package', '!', ','] }], + 'template-curly-spacing': [2, 'never'], + 'use-isnan': 2, + 'valid-typeof': 2, + 'wrap-iife': [2, 'any'], + 'yield-star-spacing': [2, 'both'], + 'yoda': [2, 'never'], + 'prefer-const': 2, + 'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0, + 'object-curly-spacing': [2, 'always', { objectsInObjects: false }], + 'array-bracket-spacing': [2, 'never'] } } diff --git a/build/webpack.base.conf.js b/build/webpack.base.conf.js index 7ef60687..77a31f5f 100644 --- a/build/webpack.base.conf.js +++ b/build/webpack.base.conf.js @@ -37,15 +37,15 @@ module.exports = { }, module: { rules: [ - // { - // test: /\.(js|vue)$/, - // loader: 'eslint-loader', - // enforce: "pre", - // include: [resolve('src'), resolve('test')], - // options: { - // formatter: require('eslint-friendly-formatter') - // } - // }, + { + test: /\.(js|vue)$/, + loader: 'eslint-loader', + enforce: "pre", + include: [resolve('src'), resolve('test')], + options: { + formatter: require('eslint-friendly-formatter') + } + }, { test: /\.vue$/, loader: 'vue-loader', diff --git a/src/App.vue b/src/App.vue index f8b32acf..440937a9 100644 --- a/src/App.vue +++ b/src/App.vue @@ -11,6 +11,6 @@ diff --git a/src/api/article.js b/src/api/article.js index fad7e132..b137ee5d 100644 --- a/src/api/article.js +++ b/src/api/article.js @@ -1,16 +1,16 @@ -import fetch from 'utils/fetch'; +import fetch from 'utils/fetch' -export function getList() { +export function getList () { return fetch({ url: '/article/list', method: 'get' - }); + }) } -export function getArticle() { +export function getArticle () { return fetch({ url: '/article/detail', method: 'get' - }); + }) } diff --git a/src/api/article_table.js b/src/api/article_table.js index 2e3edf52..767608d6 100644 --- a/src/api/article_table.js +++ b/src/api/article_table.js @@ -1,17 +1,17 @@ -import fetch from 'utils/fetch'; +import fetch from 'utils/fetch' -export function fetchList(query) { +export function fetchList (query) { return fetch({ url: '/article_table/list', method: 'get', params: query - }); + }) } -export function fetchPv(pv) { +export function fetchPv (pv) { return fetch({ url: '/article_table/pv', method: 'get', params: { pv } - }); + }) } diff --git a/src/api/login.js b/src/api/login.js index 4674d1c8..e811e06b 100644 --- a/src/api/login.js +++ b/src/api/login.js @@ -1,6 +1,6 @@ import fetch from 'utils/fetch' -export function loginByUsername(username, password) { +export function loginByUsername (username, password) { const data = { username, password @@ -12,14 +12,14 @@ export function loginByUsername(username, password) { }) } -export function logout() { +export function logout () { return fetch({ url: '/login/logout', method: 'post' }) } -export function getInfo(token) { +export function getInfo (token) { return fetch({ url: '/user/info', method: 'get', diff --git a/src/api/qiniu.js b/src/api/qiniu.js index b2837f72..3b54da6f 100644 --- a/src/api/qiniu.js +++ b/src/api/qiniu.js @@ -1,8 +1,8 @@ -import fetch from 'utils/fetch'; +import fetch from 'utils/fetch' -export function getToken() { +export function getToken () { return fetch({ url: '/qiniu/upload/token', // 假地址 自行替换 method: 'get' - }); + }) } diff --git a/src/api/remoteSearch.js b/src/api/remoteSearch.js index ed45bd74..e2ddbafa 100644 --- a/src/api/remoteSearch.js +++ b/src/api/remoteSearch.js @@ -1,9 +1,9 @@ -import fetch from 'utils/fetch'; +import fetch from 'utils/fetch' -export function userSearch(name) { +export function userSearch (name) { return fetch({ url: '/search/user', method: 'get', params: { name } - }); + }) } diff --git a/src/components/BackToTop/index.vue b/src/components/BackToTop/index.vue index 2c8826ba..fa6b18b0 100644 --- a/src/components/BackToTop/index.vue +++ b/src/components/BackToTop/index.vue @@ -12,73 +12,73 @@