Skip to content

Commit 76fd45c

Browse files
committed
build: upgrade eslint and use only non-stylistic rules
1 parent 980801c commit 76fd45c

30 files changed

+187
-281
lines changed

.eslintrc.js

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
module.exports = {
2+
root: true,
3+
parserOptions: {
4+
parser: require.resolve('babel-eslint'),
5+
ecmaVersion: 2018,
6+
sourceType: 'module'
7+
},
8+
env: {
9+
es6: true,
10+
node: true,
11+
browser: true
12+
},
13+
plugins: [
14+
"flowtype"
15+
],
16+
extends: [
17+
"eslint:recommended",
18+
"plugin:flowtype/recommended"
19+
],
20+
globals: {
21+
"__WEEX__": true,
22+
"WXEnvironment": true
23+
},
24+
rules: {
25+
'no-console': process.env.NODE_ENV !== 'production' ? 0 : 2,
26+
'no-useless-escape': 0,
27+
'no-empty': 0
28+
}
29+
}

.eslintrc.json

-14
This file was deleted.

dist/vue.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-4
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"test:ssr": "npm run build:ssr && jasmine JASMINE_CONFIG_PATH=test/ssr/jasmine.js",
3535
"test:sauce": "npm run sauce -- 0 && npm run sauce -- 1 && npm run sauce -- 2",
3636
"test:types": "tsc -p ./types/test/tsconfig.json",
37-
"lint": "eslint --fix src scripts test",
37+
"lint": "eslint src scripts test",
3838
"flow": "flow check",
3939
"sauce": "karma start test/unit/karma.sauce.config.js",
4040
"bench:ssr": "npm run build:ssr && node benchmarks/ssr/renderToString.js && node benchmarks/ssr/renderToStream.js",
@@ -94,11 +94,9 @@
9494
"de-indent": "^1.0.2",
9595
"es6-promise": "^4.1.0",
9696
"escodegen": "^1.8.1",
97-
"eslint": "^4.13.1",
98-
"eslint-loader": "^1.7.1",
97+
"eslint": "^5.7.0",
9998
"eslint-plugin-flowtype": "^2.34.0",
10099
"eslint-plugin-jasmine": "^2.8.4",
101-
"eslint-plugin-vue-libs": "^2.0.1",
102100
"file-loader": "^1.1.5",
103101
"flow-bin": "^0.61.0",
104102
"hash-sum": "^1.0.2",

src/compiler/codegen/events.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ const modifierCode: { [key: string]: string } = {
5151

5252
export function genHandlers (
5353
events: ASTElementHandlers,
54-
isNative: boolean,
55-
warn: Function
54+
isNative: boolean
5655
): string {
5756
let res = isNative ? 'nativeOn:{' : 'on:{'
5857
for (const name in events) {

src/compiler/codegen/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -237,10 +237,10 @@ export function genData (el: ASTElement, state: CodegenState): string {
237237
}
238238
// event handlers
239239
if (el.events) {
240-
data += `${genHandlers(el.events, false, state.warn)},`
240+
data += `${genHandlers(el.events, false)},`
241241
}
242242
if (el.nativeEvents) {
243-
data += `${genHandlers(el.nativeEvents, true, state.warn)},`
243+
data += `${genHandlers(el.nativeEvents, true)},`
244244
}
245245
// slot target
246246
// only for non-scoped slots

src/core/instance/state.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ export function stateMixin (Vue: Class<Component>) {
321321
const propsDef = {}
322322
propsDef.get = function () { return this._props }
323323
if (process.env.NODE_ENV !== 'production') {
324-
dataDef.set = function (newData: Object) {
324+
dataDef.set = function () {
325325
warn(
326326
'Avoid replacing instance root $data. ' +
327327
'Use nested data properties instead.',

src/core/observer/index.js

+6-5
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,11 @@ export class Observer {
4545
this.vmCount = 0
4646
def(value, '__ob__', this)
4747
if (Array.isArray(value)) {
48-
const augment = hasProto
49-
? protoAugment
50-
: copyAugment
51-
augment(value, arrayMethods, arrayKeys)
48+
if (hasProto) {
49+
protoAugment(value, arrayMethods)
50+
} else {
51+
copyAugment(value, arrayMethods, arrayKeys)
52+
}
5253
this.observeArray(value)
5354
} else {
5455
this.walk(value)
@@ -83,7 +84,7 @@ export class Observer {
8384
* Augment an target Object or Array by intercepting
8485
* the prototype chain using __proto__
8586
*/
86-
function protoAugment (target, src: Object, keys: any) {
87+
function protoAugment (target, src: Object) {
8788
/* eslint-disable no-proto */
8889
target.__proto__ = src
8990
/* eslint-enable no-proto */

src/platforms/weex/compiler/directives/model.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ import { genComponentModel, genAssignmentCode } from 'compiler/directives/model'
55

66
export default function model (
77
el: ASTElement,
8-
dir: ASTDirective,
9-
_warn: Function
8+
dir: ASTDirective
109
): ?boolean {
1110
if (el.tag === 'input' || el.tag === 'textarea') {
1211
genDefaultModel(el, dir.value, dir.modifiers)

src/platforms/weex/compiler/modules/append.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { makeMap } from 'shared/util'
66
// must be sent to the native together.
77
const isUnitaryTag = makeMap('cell,header,cell-slot,recycle-list', true)
88

9-
function preTransformNode (el: ASTElement, options: CompilerOptions) {
9+
function preTransformNode (el: ASTElement) {
1010
if (isUnitaryTag(el.tag) && !el.attrsList.some(item => item.name === 'append')) {
1111
el.attrsMap.append = 'tree'
1212
el.attrsList.push({ name: 'append', value: 'tree' })

src/platforms/weex/compiler/modules/props.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ function normalizeKeyName (str: string): string {
1313
return normalize(str)
1414
}
1515

16-
function transformNode (el: ASTElement, options: CompilerOptions) {
16+
function transformNode (el: ASTElement) {
1717
if (Array.isArray(el.attrsList)) {
1818
el.attrsList.forEach(attr => {
1919
if (attr.name && attr.name.match(/\-/)) {

src/platforms/weex/compiler/modules/recycle-list/component-root.js

+1-4
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@
33
import { addAttr } from 'compiler/helpers'
44

55
// mark component root nodes as
6-
export function postTransformComponentRoot (
7-
el: ASTElement,
8-
options: WeexCompilerOptions
9-
) {
6+
export function postTransformComponentRoot (el: ASTElement) {
107
if (!el.parent) {
118
// component root
129
addAttr(el, '@isComponentRoot', 'true')

src/platforms/weex/compiler/modules/recycle-list/index.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ function preTransformNode (el: ASTElement, options: WeexCompilerOptions) {
2323
currentRecycleList = el
2424
}
2525
if (shouldCompile(el, options)) {
26-
preTransformVBind(el, options)
26+
preTransformVBind(el)
2727
preTransformVIf(el, options) // also v-else-if and v-else
2828
preTransformVFor(el, options)
29-
preTransformVOnce(el, options)
29+
preTransformVOnce(el)
3030
}
3131
}
3232

@@ -41,12 +41,12 @@ function postTransformNode (el: ASTElement, options: WeexCompilerOptions) {
4141
// mark child component in parent template
4242
postTransformComponent(el, options)
4343
// mark root in child component template
44-
postTransformComponentRoot(el, options)
44+
postTransformComponentRoot(el)
4545
// <text>: transform children text into value attr
4646
if (el.tag === 'text') {
47-
postTransformText(el, options)
47+
postTransformText(el)
4848
}
49-
postTransformVOn(el, options)
49+
postTransformVOn(el)
5050
}
5151
if (el === currentRecycleList) {
5252
currentRecycleList = null

src/platforms/weex/compiler/modules/recycle-list/text.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ function genText (node: ASTNode) {
1313
return JSON.stringify(value)
1414
}
1515

16-
export function postTransformText (el: ASTElement, options: WeexCompilerOptions) {
16+
export function postTransformText (el: ASTElement) {
1717
// weex <text> can only contain text, so the parser
1818
// always generates a single child.
1919
if (el.children.length) {

src/platforms/weex/compiler/modules/recycle-list/v-bind.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ function parseAttrName (name: string): string {
99
return camelize(name.replace(bindRE, ''))
1010
}
1111

12-
export function preTransformVBind (el: ASTElement, options: WeexCompilerOptions) {
12+
export function preTransformVBind (el: ASTElement) {
1313
for (const attr in el.attrsMap) {
1414
if (bindRE.test(attr)) {
1515
const name: string = parseAttrName(attr)

src/platforms/weex/compiler/modules/recycle-list/v-on.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ function parseHandlerParams (handler: ASTElementHandler) {
99
}
1010
}
1111

12-
export function postTransformVOn (el: ASTElement, options: WeexCompilerOptions) {
12+
export function postTransformVOn (el: ASTElement) {
1313
const events: ASTElementHandlers | void = el.events
1414
if (!events) {
1515
return

src/platforms/weex/compiler/modules/recycle-list/v-once.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ function containVOnce (el: ASTElement): boolean {
1111
return false
1212
}
1313

14-
export function preTransformVOnce (el: ASTElement, options: WeexCompilerOptions) {
14+
export function preTransformVOnce (el: ASTElement) {
1515
if (containVOnce(el)) {
1616
getAndRemoveAttr(el, 'v-once', true)
1717
addRawAttr(el, '[[once]]', true)

src/platforms/weex/runtime/modules/transition.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ function enter (_, vnode) {
7575
const stylesheet = vnode.context.$options.style || {}
7676
const startState = stylesheet[startClass]
7777
const transitionProperties = (stylesheet['@TRANSITION'] && stylesheet['@TRANSITION'][activeClass]) || {}
78-
const endState = getEnterTargetState(el, stylesheet, startClass, toClass, activeClass, vnode.context)
78+
const endState = getEnterTargetState(el, stylesheet, startClass, toClass, activeClass)
7979
const needAnimation = Object.keys(endState).length > 0
8080

8181
const cb = el._enterCb = once(() => {
@@ -229,7 +229,7 @@ function leave (vnode, rm) {
229229
}
230230

231231
// determine the target animation style for an entering transition.
232-
function getEnterTargetState (el, stylesheet, startClass, endClass, activeClass, vm) {
232+
function getEnterTargetState (el, stylesheet, startClass, endClass, activeClass) {
233233
const targetState = {}
234234
const startState = stylesheet[startClass]
235235
const endState = stylesheet[endClass]

src/platforms/weex/util/element.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ export const isUnaryTag = makeMap(
3333
true
3434
)
3535

36-
export function mustUseProp (tag: string, type: ?string, name: string): boolean {
36+
export function mustUseProp (): boolean {
3737
return false
3838
}
3939

40-
export function getTagNamespace (tag?: string): string | void { }
40+
export function getTagNamespace (): void { }
4141

42-
export function isUnknownElement (tag?: string): boolean {
42+
export function isUnknownElement (): boolean {
4343
return false
4444
}
4545

src/server/render-context.js

+1
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ export class RenderContext {
7070
if (isUndef(lastState)) {
7171
return this.done()
7272
}
73+
/* eslint-disable no-case-declarations */
7374
switch (lastState.type) {
7475
case 'Element':
7576
case 'Fragment':

src/sfc/parser.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export function parseComponent (
8080
}
8181
}
8282

83-
function end (tag: string, start: number, end: number) {
83+
function end (tag: string, start: number) {
8484
if (depth === 1 && currentBlock) {
8585
currentBlock.end = start
8686
let text = deindent(content.slice(currentBlock.start, currentBlock.end))

src/shared/util.js

+4
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,8 @@ export function toObject (arr: Array<any>): Object {
240240
return res
241241
}
242242

243+
/* eslint-disable no-unused-vars */
244+
243245
/**
244246
* Perform no operation.
245247
* Stubbing args to make Flow happy without leaving useless transpiled code
@@ -252,6 +254,8 @@ export function noop (a?: any, b?: any, c?: any) {}
252254
*/
253255
export const no = (a?: any, b?: any, c?: any) => false
254256

257+
/* eslint-enable no-unused-vars */
258+
255259
/**
256260
* Return the same value.
257261
*/
File renamed without changes.
File renamed without changes.

test/ssr/ssr-basic-renderer.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ describe('SSR: basicRenderer', () => {
6161
created () {
6262
ssrContext = this.$ssrContext
6363
}
64-
}), (err, result) => {
64+
}), (err) => {
6565
expect(err).toBeNull()
6666
expect(ssrContext).toBeUndefined()
6767
done()

test/ssr/ssr-string.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1102,7 +1102,7 @@ describe('SSR: renderToString', () => {
11021102
it('should catch template compilation error', done => {
11031103
renderToString(new Vue({
11041104
template: `<div></div><div></div>`
1105-
}), (err, res) => {
1105+
}), (err) => {
11061106
expect(err.toString()).toContain('Component template should contain exactly one root element')
11071107
done()
11081108
})

test/unit/.eslintrc test/unit/.eslintrc.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
},
1010
"plugins": ["jasmine"],
1111
"rules": {
12-
"jasmine/no-focused-tests": 2
12+
"jasmine/no-focused-tests": 2,
13+
"no-unused-vars": 0
1314
}
1415
}

test/unit/features/error-handling.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const components = createErrorTestComponents()
55
describe('Error handling', () => {
66
// hooks that prevents the component from rendering, but should not
77
// break parent component
8-
;[
8+
[
99
['data', 'data()'],
1010
['render', 'render'],
1111
['beforeCreate', 'beforeCreate hook'],

test/unit/modules/compiler/compiler-options.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ describe('compile options', () => {
8181
computed: {
8282
valid () {
8383
let ret = true
84-
for (let i = 0; i > this.validators.length; i++) {
84+
for (let i = 0; i < this.validators.length; i++) {
8585
const { name } = this.validators[i]
8686
if (!this.result[name]) {
8787
ret = false

0 commit comments

Comments
 (0)