Skip to content

Commit 6789c6a

Browse files
LeeeeeeMdiydyq
authored andcommitted
update package.json && eslint (#15)
1 parent b5fc8a7 commit 6789c6a

File tree

13 files changed

+82
-289
lines changed

13 files changed

+82
-289
lines changed

.eslintrc

+6-126
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"extends": ["standard", "prettier"],
23
"parserOptions": {
34
"ecmaVersion": 6,
45
"sourceType": "module"
@@ -9,134 +10,13 @@
910
"node": true,
1011
"mocha": true
1112
},
12-
1313
"globals": {
14-
"document": false,
15-
"navigator": false,
16-
"window": false,
17-
"location": false,
18-
"callNative": false,
19-
"callJS": false,
20-
"ENV_PLATFORM": false,
21-
"ENV_PHASE": false
14+
"ENV_PLATFORM": false
2215
},
23-
2416
"rules": {
25-
"accessor-pairs": 2,
26-
"arrow-spacing": [2, { "before": true, "after": true }],
27-
"block-spacing": [2, "always"],
28-
"brace-style": [0, "stroustrup", { "allowSingleLine": true }],
29-
"camelcase": [2, { "properties": "never" }],
30-
"comma-dangle": [2, "never"],
31-
"comma-spacing": [2, { "before": false, "after": true }],
32-
"comma-style": [2, "last"],
33-
"constructor-super": 2,
34-
"curly": [2, "multi-line"],
35-
"dot-location": [2, "property"],
36-
"eol-last": 2,
37-
"eqeqeq": [2, "allow-null"],
38-
"generator-star-spacing": [2, { "before": true, "after": true }],
39-
"handle-callback-err": [2, "^(err|error)$" ],
40-
"indent": [2, 2, { "SwitchCase": 1 }],
41-
"key-spacing": [2, { "beforeColon": false, "afterColon": true }],
42-
"keyword-spacing": [2, { "before": true, "after": true }],
43-
"new-cap": [2, { "newIsCap": true, "capIsNew": false }],
44-
"new-parens": 2,
45-
"no-array-constructor": 2,
46-
"no-caller": 2,
47-
"no-class-assign": 2,
48-
"no-cond-assign": 2,
49-
"no-const-assign": 2,
50-
"no-control-regex": 2,
51-
"no-debugger": 2,
52-
"no-delete-var": 2,
53-
"no-dupe-args": 2,
54-
"no-dupe-class-members": 2,
55-
"no-dupe-keys": 2,
56-
"no-duplicate-case": 2,
57-
"no-empty-character-class": 2,
58-
"no-empty-pattern": 2,
59-
"no-eval": 2,
60-
"no-ex-assign": 2,
61-
"no-extend-native": 2,
62-
"no-extra-bind": 2,
63-
"no-extra-boolean-cast": 2,
64-
"no-extra-parens": [2, "functions"],
65-
"no-fallthrough": 2,
66-
"no-floating-decimal": 2,
67-
"no-func-assign": 2,
68-
"no-implied-eval": 2,
69-
"no-inner-declarations": [2, "functions"],
70-
"no-invalid-regexp": 2,
71-
"no-irregular-whitespace": 2,
72-
"no-iterator": 2,
73-
"no-label-var": 2,
74-
"no-labels": [2, { "allowLoop": false, "allowSwitch": false }],
75-
"no-lone-blocks": 2,
76-
"no-mixed-spaces-and-tabs": 2,
77-
"no-multi-spaces": 2,
78-
"no-multi-str": 2,
79-
"no-multiple-empty-lines": [2, { "max": 1 }],
80-
"no-native-reassign": 2,
81-
"no-negated-in-lhs": 2,
82-
"no-new-object": 2,
83-
"no-new-require": 2,
84-
"no-new-symbol": 2,
85-
"no-new-wrappers": 2,
86-
"no-obj-calls": 2,
87-
"no-octal": 2,
88-
"no-octal-escape": 2,
89-
"no-path-concat": 2,
90-
"no-proto": 2,
91-
"no-redeclare": 2,
92-
"no-regex-spaces": 2,
93-
"no-return-assign": [2, "except-parens"],
94-
"no-self-assign": 2,
95-
"no-self-compare": 2,
96-
"no-sequences": 2,
97-
"no-shadow-restricted-names": 2,
98-
"no-spaced-func": 2,
99-
"no-sparse-arrays": 2,
100-
"no-this-before-super": 2,
101-
"no-throw-literal": 2,
102-
"no-trailing-spaces": 2,
103-
"no-undef": 2,
104-
"no-undef-init": 2,
105-
"no-unexpected-multiline": 2,
106-
"no-unmodified-loop-condition": 2,
107-
"no-unneeded-ternary": [2, { "defaultAssignment": false }],
108-
"no-unreachable": 2,
109-
"no-unsafe-finally": 2,
110-
"no-unused-vars": [2, { "vars": "all", "args": "none" }],
111-
"no-useless-call": 2,
112-
"no-useless-computed-key": 2,
113-
"no-useless-constructor": 2,
114-
"no-useless-escape": 2,
115-
"no-whitespace-before-property": 2,
116-
"no-with": 2,
117-
"one-var": [2, { "initialized": "never" }],
118-
"padded-blocks": [2, "never"],
119-
"quotes": [2, "single", {"avoidEscape": true, "allowTemplateLiterals": true}],
120-
"semi": [2, "never"],
121-
"semi-spacing": [2, { "before": false, "after": true }],
122-
"space-before-blocks": [2, "always"],
123-
"space-before-function-paren": [0, "always"],
124-
"space-in-parens": [2, "never"],
125-
"space-infix-ops": 2,
126-
"space-unary-ops": [2, { "words": true, "nonwords": false }],
127-
"spaced-comment": [2, "always", { "markers": ["global", "globals", "eslint", "eslint-disable", "*package", "!", ","] }],
128-
"template-curly-spacing": [2, "never"],
129-
"use-isnan": 2,
130-
"valid-typeof": 2,
131-
"wrap-iife": [2, "any"],
132-
"yield-star-spacing": [2, "both"],
133-
"yoda": [2, "never"],
134-
135-
"no-var": 2,
136-
"prefer-const": 2,
137-
"object-curly-spacing": [2, "always", {
138-
"objectsInObjects": false
139-
}],
140-
"array-bracket-spacing": [2, "never"]
17+
"no-new-func": 0,
18+
"standard/computed-property-even-spacing": 0,
19+
"standard/no-callback-literal": 0,
20+
"promise/param-names": 0
14121
}
14222
}

.npmignore

+8-1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,11 @@ babel.config.js
99
dist/debug
1010
dist/release/output
1111

12-
**/*.js.map
12+
**/*.js.map
13+
*.md
14+
*.pdf
15+
16+
.gitignore
17+
.eslintrc
18+
.eslintignore
19+
.prettierignore

.prettierignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
dist/**
2+
/test/build/**
3+
/src/dsls/vue/vm/factory.js
4+
/src/dsls/vue/vm/factory-with-compiler.js

config/rollup.config.js

+14-16
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,21 @@
55
import path from 'path'
66
import fs from 'fs'
77

8-
import json from 'rollup-plugin-json' // 通过import引入json文件
9-
import eslint from 'rollup-plugin-eslint' // 代码风格检查
10-
import nodeResolve from 'rollup-plugin-node-resolve' // 解析npm包
11-
import commonjs from 'rollup-plugin-commonjs' // commonJS转换为ES6
12-
import buble from 'rollup-plugin-buble' // 转化相应的v8版本的ES6语法特性
8+
import json from 'rollup-plugin-json' // 通过import引入json文件
9+
import { eslint } from 'rollup-plugin-eslint' // 代码风格检查
10+
import nodeResolve from 'rollup-plugin-node-resolve' // 解析npm包
11+
import commonjs from 'rollup-plugin-commonjs' // commonJS转换为ES6
12+
import buble from 'rollup-plugin-buble' // 转化相应的v8版本的ES6语法特性
1313
import replace from 'rollup-plugin-replace' // Likely with DefinePlugin
1414
import { terser } from 'rollup-plugin-terser' // terser用来混淆ES6代码
1515
import alias from 'rollup-plugin-alias'
1616

1717
const pkg = require('../package.json')
1818
const version = pkg.version
19-
const date = new Date().toISOString().split('T')[0].replace(/-/g, '')
19+
const date = new Date()
20+
.toISOString()
21+
.split('T')[0]
22+
.replace(/-/g, '')
2023

2124
// 配置环境
2225
const nodeConf = parse()
@@ -62,25 +65,20 @@ const rollConf = {
6265
}
6366
}),
6467
replace({
65-
exclude: [
66-
'node_modules/**',
67-
'package.json'
68-
],
68+
exclude: ['node_modules/**', 'package.json'],
6969
values: rollInject
7070
})
7171
]
7272
}
7373

7474
if (nodeConf.NODE_PHASE === 'dv') {
75-
}
76-
else {
75+
} else {
7776
// Uglify
7877
rollConf.plugins.push(terser())
7978
}
8079

8180
if (nodeConf.NODE_PLATFORM === 'h5') {
82-
}
83-
else {
81+
} else {
8482
}
8583

8684
const confList = nodeConf.list.map(item => {
@@ -93,7 +91,7 @@ export default confList
9391
/**
9492
* 解析NODE环境的参数
9593
*/
96-
function parse (config) {
94+
function parse(config) {
9795
config = config || {}
9896
// 平台:na
9997
config.NODE_PLATFORM = process.env.NODE_PLATFORM
@@ -126,7 +124,7 @@ function parse (config) {
126124
* @param {string} env debug/release
127125
* @param {string} moduleSrc module文件夹位置
128126
*/
129-
function collectExportList (env, dslsSrc) {
127+
function collectExportList(env, dslsSrc) {
130128
const list = []
131129

132130
fs.readdirSync(dslsSrc).forEach(dir => {

dist/release/output/infras-ext.js

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

dist/release/output/infras.js

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

dist/release/output/styling.js

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

package.json

+32-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
{
22
"name": "quickapp-dsls",
3-
"version": "0.0.8",
3+
"version": "0.1.3",
44
"description": "dsls-for-quickapp",
55
"scripts": {
6+
"prettier": "prettier \"**/*.{md,js,json}\" --write",
67
"build": "npm run native && npm run native:release",
7-
"clear": "rm -rf dist/*",
8+
"clear": "rm -rf dist/debug && rm -rf dist/release/dsls",
89
"native": "npm run na:dv",
910
"native:release": "npm run na:ol",
1011
"na": "npm run na:dv -- -w",
@@ -20,26 +21,53 @@
2021
},
2122
"keywords": [],
2223
"main": "dist/release/dsls/vue.js",
24+
"husky": {
25+
"hooks": {
26+
"pre-commit": "lint-staged"
27+
}
28+
},
29+
"lint-staged": {
30+
"*.{js,json,css,md}": [
31+
"prettier --write",
32+
"git add"
33+
]
34+
},
35+
"prettier": {
36+
"tabWidth": 2,
37+
"printWidth": 100,
38+
"semi": false,
39+
"trailingComma": "none",
40+
"singleQuote": true
41+
},
2342
"devDependencies": {
2443
"@babel/cli": "^7.2.3",
2544
"app-module-path": "^2.2.0",
2645
"chai": "^3.5.0",
2746
"cross-env": "^3.2.4",
2847
"crypto-js": "^3.1.9-1",
2948
"css-loader": "^0.28.11",
30-
"eslint": "^3.12.1",
49+
"eslint": "^5.15.0",
50+
"eslint-config-prettier": "^4.1.0",
51+
"eslint-config-standard": "^12.0.0",
52+
"eslint-plugin-import": "^2.16.0",
53+
"eslint-plugin-node": "^8.0.1",
54+
"eslint-plugin-promise": "^4.0.1",
55+
"eslint-plugin-standard": "^4.0.0",
3156
"hap-toolkit": "^0.2.0",
57+
"husky": "^1.3.1",
3258
"json-loader": "0.5.4",
59+
"lint-staged": "^8.1.4",
3360
"loader-utils": "~0.2.14",
3461
"mini-css-extract-plugin": "^0.4.5",
3562
"mocha": "^5.2.0",
63+
"prettier": "^1.16.4",
3664
"reify": "^0.3.8",
3765
"rollup": "^0.68.0",
3866
"rollup-plugin-alias": "^1.4.0",
3967
"rollup-plugin-babel": "^2.7.1",
4068
"rollup-plugin-buble": "^0.19.6",
4169
"rollup-plugin-commonjs": "^5.0.5",
42-
"rollup-plugin-eslint": "^3.0.0",
70+
"rollup-plugin-eslint": "^5.0.0",
4371
"rollup-plugin-json": "^2.0.2",
4472
"rollup-plugin-node-resolve": "^2.0.0",
4573
"rollup-plugin-postcss": "^0.2.0",

src/dsls/vue/page/interface.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ import { updatePageActions } from './misc'
1616
* 初始化页面
1717
* @param {object} page page实例
1818
* @param {string} code 页面代码字符串
19-
* @param {object} data app传入的数据
19+
* @param {object} query app传入的数据
2020
* @param {object} globals 全局变量
2121
* @return {object}
2222
*/
23-
function initPage(page, code, data, globals) {
23+
function initPage(page, code, query, globals) {
2424
const instanceId = page.id
2525

2626
// 对原有streamer实例方法进行拦截
@@ -44,7 +44,7 @@ function initPage(page, code, data, globals) {
4444
})
4545

4646
// instance实例上挂载Vue实例
47-
const Vue = (instance.Vue = createVueModuleInstance(instanceId, { page: page }, data))
47+
const Vue = (instance.Vue = createVueModuleInstance(instanceId, { page: page }, query))
4848

4949
// 实例代码执行需要的全局参数
5050
const instanceVars = Object.assign(

test/config/config/webpack.config.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ function postHook(webpackConf, defaults, options) {
5454
if (stats.isFile() && jsReg.test(subFile)) {
5555
// 正则紧接上文
5656
const key = `test/build/dsls/${subFile.replace(
57-
/(.*)(test(\/|\\)suite(\/|\\)dsls(\/|\\))(.*)(\b(app|index)\b\.vue$)/,
58-
(...args) => args[6]
57+
/(.*)(test[\\/]suite[\\/]dsls[\\/])(.*)(\b(app|index)\b\.vue$)/,
58+
($0, $1, $2, $3) => $3
5959
)}${type}`
6060
webpackConf.entry[key] = `${subFile}?vueType=${type === 'app' ? 'app' : 'page'}`
6161
console.log('### App Loader ### 添加 entry: ', key)

0 commit comments

Comments
 (0)