Permalink
Browse files

build: upgrade eslint and use only non-stylistic rules

  • Loading branch information...
yyx990803 committed Oct 24, 2018
1 parent 980801c commit 76fd45c9fd611fecfa79997706a5d218de206b68
Showing with 187 additions and 281 deletions.
  1. +29 βˆ’0 .eslintrc.js
  2. +0 βˆ’14 .eslintrc.json
  3. +1 βˆ’1 dist/vue.min.js
  4. +2 βˆ’4 package.json
  5. +1 βˆ’2 src/compiler/codegen/events.js
  6. +2 βˆ’2 src/compiler/codegen/index.js
  7. +1 βˆ’1 src/core/instance/state.js
  8. +6 βˆ’5 src/core/observer/index.js
  9. +1 βˆ’2 src/platforms/weex/compiler/directives/model.js
  10. +1 βˆ’1 src/platforms/weex/compiler/modules/append.js
  11. +1 βˆ’1 src/platforms/weex/compiler/modules/props.js
  12. +1 βˆ’4 src/platforms/weex/compiler/modules/recycle-list/component-root.js
  13. +5 βˆ’5 src/platforms/weex/compiler/modules/recycle-list/index.js
  14. +1 βˆ’1 src/platforms/weex/compiler/modules/recycle-list/text.js
  15. +1 βˆ’1 src/platforms/weex/compiler/modules/recycle-list/v-bind.js
  16. +1 βˆ’1 src/platforms/weex/compiler/modules/recycle-list/v-on.js
  17. +1 βˆ’1 src/platforms/weex/compiler/modules/recycle-list/v-once.js
  18. +2 βˆ’2 src/platforms/weex/runtime/modules/transition.js
  19. +3 βˆ’3 src/platforms/weex/util/element.js
  20. +1 βˆ’0 src/server/render-context.js
  21. +1 βˆ’1 src/sfc/parser.js
  22. +4 βˆ’0 src/shared/util.js
  23. 0 test/e2e/{.eslintrc β†’ .eslintrc.json}
  24. 0 test/helpers/{.eslintrc β†’ .eslintrc.json}
  25. +1 βˆ’1 test/ssr/ssr-basic-renderer.spec.js
  26. +1 βˆ’1 test/ssr/ssr-string.spec.js
  27. +2 βˆ’1 test/unit/{.eslintrc β†’ .eslintrc.json}
  28. +1 βˆ’1 test/unit/features/error-handling.spec.js
  29. +1 βˆ’1 test/unit/modules/compiler/compiler-options.spec.js
  30. +115 βˆ’224 yarn.lock
@@ -0,0 +1,29 @@
module.exports = {
root: true,
parserOptions: {
parser: require.resolve('babel-eslint'),
ecmaVersion: 2018,
sourceType: 'module'
},
env: {
es6: true,
node: true,
browser: true
},
plugins: [
"flowtype"
],
extends: [
"eslint:recommended",
"plugin:flowtype/recommended"
],
globals: {
"__WEEX__": true,
"WXEnvironment": true
},
rules: {
'no-console': process.env.NODE_ENV !== 'production' ? 0 : 2,
'no-useless-escape': 0,
'no-empty': 0
}
}

This file was deleted.

Oops, something went wrong.

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -34,7 +34,7 @@
"test:ssr": "npm run build:ssr && jasmine JASMINE_CONFIG_PATH=test/ssr/jasmine.js",
"test:sauce": "npm run sauce -- 0 && npm run sauce -- 1 && npm run sauce -- 2",
"test:types": "tsc -p ./types/test/tsconfig.json",
"lint": "eslint --fix src scripts test",
"lint": "eslint src scripts test",
"flow": "flow check",
"sauce": "karma start test/unit/karma.sauce.config.js",
"bench:ssr": "npm run build:ssr && node benchmarks/ssr/renderToString.js && node benchmarks/ssr/renderToStream.js",
@@ -94,11 +94,9 @@
"de-indent": "^1.0.2",
"es6-promise": "^4.1.0",
"escodegen": "^1.8.1",
"eslint": "^4.13.1",
"eslint-loader": "^1.7.1",
"eslint": "^5.7.0",
"eslint-plugin-flowtype": "^2.34.0",
"eslint-plugin-jasmine": "^2.8.4",
"eslint-plugin-vue-libs": "^2.0.1",
"file-loader": "^1.1.5",
"flow-bin": "^0.61.0",
"hash-sum": "^1.0.2",
@@ -51,8 +51,7 @@ const modifierCode: { [key: string]: string } = {
export function genHandlers (
events: ASTElementHandlers,
isNative: boolean,
warn: Function
isNative: boolean
): string {
let res = isNative ? 'nativeOn:{' : 'on:{'
for (const name in events) {
@@ -237,10 +237,10 @@ export function genData (el: ASTElement, state: CodegenState): string {
}
// event handlers
if (el.events) {
data += `${genHandlers(el.events, false, state.warn)},`
data += `${genHandlers(el.events, false)},`
}
if (el.nativeEvents) {
data += `${genHandlers(el.nativeEvents, true, state.warn)},`
data += `${genHandlers(el.nativeEvents, true)},`
}
// slot target
// only for non-scoped slots
@@ -321,7 +321,7 @@ export function stateMixin (Vue: Class<Component>) {
const propsDef = {}
propsDef.get = function () { return this._props }
if (process.env.NODE_ENV !== 'production') {
dataDef.set = function (newData: Object) {
dataDef.set = function () {
warn(
'Avoid replacing instance root $data. ' +
'Use nested data properties instead.',
@@ -45,10 +45,11 @@ export class Observer {
this.vmCount = 0
def(value, '__ob__', this)
if (Array.isArray(value)) {
const augment = hasProto
? protoAugment
: copyAugment
augment(value, arrayMethods, arrayKeys)
if (hasProto) {
protoAugment(value, arrayMethods)
} else {
copyAugment(value, arrayMethods, arrayKeys)
}
this.observeArray(value)
} else {
this.walk(value)
@@ -83,7 +84,7 @@ export class Observer {
* Augment an target Object or Array by intercepting
* the prototype chain using __proto__
*/
function protoAugment (target, src: Object, keys: any) {
function protoAugment (target, src: Object) {
/* eslint-disable no-proto */
target.__proto__ = src
/* eslint-enable no-proto */
@@ -5,8 +5,7 @@ import { genComponentModel, genAssignmentCode } from 'compiler/directives/model'
export default function model (
el: ASTElement,
dir: ASTDirective,
_warn: Function
dir: ASTDirective
): ?boolean {
if (el.tag === 'input' || el.tag === 'textarea') {
genDefaultModel(el, dir.value, dir.modifiers)
@@ -6,7 +6,7 @@ import { makeMap } from 'shared/util'
// must be sent to the native together.
const isUnitaryTag = makeMap('cell,header,cell-slot,recycle-list', true)
function preTransformNode (el: ASTElement, options: CompilerOptions) {
function preTransformNode (el: ASTElement) {
if (isUnitaryTag(el.tag) && !el.attrsList.some(item => item.name === 'append')) {
el.attrsMap.append = 'tree'
el.attrsList.push({ name: 'append', value: 'tree' })
@@ -13,7 +13,7 @@ function normalizeKeyName (str: string): string {
return normalize(str)
}
function transformNode (el: ASTElement, options: CompilerOptions) {
function transformNode (el: ASTElement) {
if (Array.isArray(el.attrsList)) {
el.attrsList.forEach(attr => {
if (attr.name && attr.name.match(/\-/)) {
@@ -3,10 +3,7 @@
import { addAttr } from 'compiler/helpers'
// mark component root nodes as
export function postTransformComponentRoot (
el: ASTElement,
options: WeexCompilerOptions
) {
export function postTransformComponentRoot (el: ASTElement) {
if (!el.parent) {
// component root
addAttr(el, '@isComponentRoot', 'true')
@@ -23,10 +23,10 @@ function preTransformNode (el: ASTElement, options: WeexCompilerOptions) {
currentRecycleList = el
}
if (shouldCompile(el, options)) {
preTransformVBind(el, options)
preTransformVBind(el)
preTransformVIf(el, options) // also v-else-if and v-else
preTransformVFor(el, options)
preTransformVOnce(el, options)
preTransformVOnce(el)
}
}
@@ -41,12 +41,12 @@ function postTransformNode (el: ASTElement, options: WeexCompilerOptions) {
// mark child component in parent template
postTransformComponent(el, options)
// mark root in child component template
postTransformComponentRoot(el, options)
postTransformComponentRoot(el)
// <text>: transform children text into value attr
if (el.tag === 'text') {
postTransformText(el, options)
postTransformText(el)
}
postTransformVOn(el, options)
postTransformVOn(el)
}
if (el === currentRecycleList) {
currentRecycleList = null
@@ -13,7 +13,7 @@ function genText (node: ASTNode) {
return JSON.stringify(value)
}
export function postTransformText (el: ASTElement, options: WeexCompilerOptions) {
export function postTransformText (el: ASTElement) {
// weex <text> can only contain text, so the parser
// always generates a single child.
if (el.children.length) {
@@ -9,7 +9,7 @@ function parseAttrName (name: string): string {
return camelize(name.replace(bindRE, ''))
}
export function preTransformVBind (el: ASTElement, options: WeexCompilerOptions) {
export function preTransformVBind (el: ASTElement) {
for (const attr in el.attrsMap) {
if (bindRE.test(attr)) {
const name: string = parseAttrName(attr)
@@ -9,7 +9,7 @@ function parseHandlerParams (handler: ASTElementHandler) {
}
}
export function postTransformVOn (el: ASTElement, options: WeexCompilerOptions) {
export function postTransformVOn (el: ASTElement) {
const events: ASTElementHandlers | void = el.events
if (!events) {
return
@@ -11,7 +11,7 @@ function containVOnce (el: ASTElement): boolean {
return false
}
export function preTransformVOnce (el: ASTElement, options: WeexCompilerOptions) {
export function preTransformVOnce (el: ASTElement) {
if (containVOnce(el)) {
getAndRemoveAttr(el, 'v-once', true)
addRawAttr(el, '[[once]]', true)
@@ -75,7 +75,7 @@ function enter (_, vnode) {
const stylesheet = vnode.context.$options.style || {}
const startState = stylesheet[startClass]
const transitionProperties = (stylesheet['@TRANSITION'] && stylesheet['@TRANSITION'][activeClass]) || {}
const endState = getEnterTargetState(el, stylesheet, startClass, toClass, activeClass, vnode.context)
const endState = getEnterTargetState(el, stylesheet, startClass, toClass, activeClass)
const needAnimation = Object.keys(endState).length > 0
const cb = el._enterCb = once(() => {
@@ -229,7 +229,7 @@ function leave (vnode, rm) {
}
// determine the target animation style for an entering transition.
function getEnterTargetState (el, stylesheet, startClass, endClass, activeClass, vm) {
function getEnterTargetState (el, stylesheet, startClass, endClass, activeClass) {
const targetState = {}
const startState = stylesheet[startClass]
const endState = stylesheet[endClass]
@@ -33,13 +33,13 @@ export const isUnaryTag = makeMap(
true
)
export function mustUseProp (tag: string, type: ?string, name: string): boolean {
export function mustUseProp (): boolean {
return false
}
export function getTagNamespace (tag?: string): string | void { }
export function getTagNamespace (): void { }
export function isUnknownElement (tag?: string): boolean {
export function isUnknownElement (): boolean {
return false
}
@@ -70,6 +70,7 @@ export class RenderContext {
if (isUndef(lastState)) {
return this.done()
}
/* eslint-disable no-case-declarations */
switch (lastState.type) {
case 'Element':
case 'Fragment':
@@ -80,7 +80,7 @@ export function parseComponent (
}
}
function end (tag: string, start: number, end: number) {
function end (tag: string, start: number) {
if (depth === 1 && currentBlock) {
currentBlock.end = start
let text = deindent(content.slice(currentBlock.start, currentBlock.end))
@@ -240,6 +240,8 @@ export function toObject (arr: Array<any>): Object {
return res
}
/* eslint-disable no-unused-vars */
/**
* Perform no operation.
* Stubbing args to make Flow happy without leaving useless transpiled code
@@ -252,6 +254,8 @@ export function noop (a?: any, b?: any, c?: any) {}
*/
export const no = (a?: any, b?: any, c?: any) => false
/* eslint-enable no-unused-vars */
/**
* Return the same value.
*/
File renamed without changes.
File renamed without changes.
@@ -61,7 +61,7 @@ describe('SSR: basicRenderer', () => {
created () {
ssrContext = this.$ssrContext
}
}), (err, result) => {
}), (err) => {
expect(err).toBeNull()
expect(ssrContext).toBeUndefined()
done()
@@ -1102,7 +1102,7 @@ describe('SSR: renderToString', () => {
it('should catch template compilation error', done => {
renderToString(new Vue({
template: `<div></div><div></div>`
}), (err, res) => {
}), (err) => {
expect(err.toString()).toContain('Component template should contain exactly one root element')
done()
})
@@ -9,6 +9,7 @@
},
"plugins": ["jasmine"],
"rules": {
"jasmine/no-focused-tests": 2
"jasmine/no-focused-tests": 2,
"no-unused-vars": 0
}
}
@@ -5,7 +5,7 @@ const components = createErrorTestComponents()
describe('Error handling', () => {
// hooks that prevents the component from rendering, but should not
// break parent component
;[
[
['data', 'data()'],
['render', 'render'],
['beforeCreate', 'beforeCreate hook'],
@@ -81,7 +81,7 @@ describe('compile options', () => {
computed: {
valid () {
let ret = true
for (let i = 0; i > this.validators.length; i++) {
for (let i = 0; i < this.validators.length; i++) {
const { name } = this.validators[i]
if (!this.result[name]) {
ret = false
Oops, something went wrong.

0 comments on commit 76fd45c

Please sign in to comment.