提交 ef7b8159 作者: 刘秋月

增加代码eslint规则

上级 aa6ef2e0
/build/
/config/
/dist/
/*.js
/test/unit/coverage/
// https://eslint.org/docs/user-guide/configuring
module.exports = {
root: true,
parserOptions: {
parser: 'babel-eslint'
},
env: {
browser: true,
},
extends: [
// https://github.com/vuejs/eslint-plugin-vue#priority-a-essential-error-prevention
// consider switching to `plugin:vue/strongly-recommended` or `plugin:vue/recommended` for stricter rules.
'plugin:vue/essential',
// https://github.com/standard/standard/blob/master/docs/RULES-en.md
'standard'
],
// required to lint *.vue files
plugins: [
'vue'
],
// add your custom rules here
rules: {
// allow async-await
'generator-star-spacing': 'off',
'semi': ["error", "always"],
"no-tabs":"off",
// allow debugger during development
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off'
}
}
......@@ -8,6 +8,17 @@ function resolve (dir) {
return path.join(__dirname, '..', dir)
}
const createLintingRule = () => ({
test: /\.(js|vue)$/,
loader: 'eslint-loader',
enforce: 'pre',
include: [resolve('src'), resolve('test')],
options: {
formatter: require('eslint-friendly-formatter'),
emitWarning: !config.dev.showEslintErrorsInOverlay
}
})
module.exports = {
context: path.resolve(__dirname, '../'),
entry: {
......@@ -33,6 +44,7 @@ module.exports = {
},
module: {
rules: [
...(config.dev.useEslint ? [createLintingRule()] : []),
{
test: /\.vue$/,
loader: 'vue-loader',
......
......@@ -20,6 +20,13 @@ module.exports = {
notifyOnErrors: true,
poll: false, // https://webpack.js.org/configuration/dev-server/#devserver-watchoptions-
// Use Eslint Loader?
// If true, your code will be linted during bundling and
// linting errors and warnings will be shown in the console.
useEslint: true,
// If true, eslint errors and warnings will also be shown in the error overlay
// in the browser.
showEslintErrorsInOverlay: false,
/**
* Source Maps
......
......@@ -20,6 +20,7 @@
"devDependencies": {
"autoprefixer": "^7.1.2",
"babel-core": "^6.22.1",
"babel-eslint": "^8.2.1",
"babel-helper-vue-jsx-merge-props": "^2.0.3",
"babel-loader": "^7.1.1",
"babel-plugin-istanbul": "^4.1.1",
......@@ -36,6 +37,15 @@
"cross-env": "^5.0.1",
"cross-spawn": "^5.0.1",
"css-loader": "^0.28.0",
"eslint": "^4.15.0",
"eslint-config-standard": "^10.2.1",
"eslint-friendly-formatter": "^3.0.0",
"eslint-loader": "^1.7.1",
"eslint-plugin-import": "^2.7.0",
"eslint-plugin-node": "^5.2.0",
"eslint-plugin-promise": "^3.4.0",
"eslint-plugin-standard": "^3.0.1",
"eslint-plugin-vue": "^4.0.0",
"extract-text-webpack-plugin": "^3.0.0",
"file-loader": "^1.1.4",
"friendly-errors-webpack-plugin": "^1.6.1",
......
......@@ -7,7 +7,7 @@
<script>
export default {
name: 'App'
}
};
</script>
<style lang="scss">
......
import Vue from "vue";
/**
* @author 张金龙
* @information 防止抖动类
* @date 2018-11-19 17:45
*/
export class PreventJitter {
constructor(){
this.timer = null;
}
start(dom,binding){
let $this = this;
dom.addEventListener("input",function(e){
let {timer} = $this;
clearTimeout(timer);
$this.timer = setTimeout(() => {
let {value} = this;
binding.value({value});
},500);
});
}
static singleton(){
let singleton = null;
if(!singleton){
singleton = new PreventJitter();
}
return singleton;
}
}
Vue.directive('jitter-change', {
inserted(el,binding) {
let dom = el.getElementsByTagName("input")[0] || el;
if(dom.nodeName !== "INPUT"){
throw new Error("The 'input' tag was not found");
}
let preventJitter = PreventJitter.singleton();
preventJitter.start(dom,binding);
}
})
\ No newline at end of file
......@@ -20,5 +20,5 @@ export default {
default: '这是个基础组件'
}
}
}
};
</script>
......@@ -19,5 +19,5 @@ export default {
defalut: '这里是业务组件'
}
}
}
};
</script>
// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import store from './store.js'
import Vue from 'vue';
import App from './App';
import router from './router';
import store from './store.js';
// 引入组件库
import element from 'element-ui'
import element from 'element-ui';
// 引入扫描文件
import scan from './scanfile.js'
import "@/assets/js/PreventJitter.js"
import scan from './scanfile.js';
// 引入样式
import './style/index.scss'
import './style/index.scss';
Vue.use(element)
Vue.use(scan)
Vue.config.productionTip = false
Vue.use(element);
Vue.use(scan);
Vue.config.productionTip = false;
/* eslint-disable no-new */
new Vue({
......@@ -25,4 +23,4 @@ new Vue({
store,
components: { App },
template: '<App/>'
})
});
import Vue from 'vue'
import Router from 'vue-router'
import Vue from 'vue';
import Router from 'vue-router';
// import HelloWorld from '@/components/HelloWorld'
import Index from '@/view/index'
import Index from '@/view/index';
Vue.use(Router)
Vue.use(Router);
export default new Router({
routes: [
......@@ -13,4 +13,4 @@ export default new Router({
component: Index
}
]
})
});
const components = []
const components = [];
const srcContext = require.context('@/components', true, /\.vue$/)
srcContext.keys().forEach(item => {
let src = srcContext(item)
const srcContext = require.context('@/components', true, /\.vue$/);
srcContext.keys().forEach((item) => {
const src = srcContext(item);
if (!src.default.name) {
src.default.name = item.split('/').pop().replace(/\.vue$/, '')
src.default.name = item.split('/').pop().replace(/\.vue$/, '');
}
components.push(src)
})
components.push(src);
});
const install = function (Vue) {
components.map(component => {
let name = component.default.name
Vue.component(name, component.default)
})
}
components.map((component) => {
const name = component.default.name;
Vue.component(name, component.default);
});
};
if (typeof window !== 'undefined' && window.Vue) {
install(window.Vue)
install(window.Vue);
}
module.exports = {
install
}
};
import Vue from 'vue'
import Vuex from 'vuex'
import Vue from 'vue';
import Vuex from 'vuex';
Vue.use(Vuex)
Vue.use(Vuex);
let model = { modules: {} }
let name = []
let model = { modules: {} };
let name = [];
// 扫描文件
const srcContext = require.context('@/store', true, /\.js$/)
const srcContext = require.context('@/store', true, /\.js$/);
srcContext.keys().forEach(item => {
if (item !== './index.js' && srcContext(item).default !== undefined) {
// 重新定义赋值model
name = item.split('/').pop().replace(/\.js$/, '')
model.modules[name] = srcContext(item).default
name = item.split('/').pop().replace(/\.js$/, '');
model.modules[name] = srcContext(item).default;
}
})
});
// 注册导出
export default new Vuex.Store(model)
export default new Vuex.Store(model);
......@@ -3,7 +3,7 @@
/**
* 数据操作
* @author author
* @author author
* @date 2019-05-17
*/
const modules = {
......@@ -19,6 +19,6 @@ const modules = {
actions: {
},
namespaced: true
}
};
export default modules
\ No newline at end of file
export default modules;
@import 'var';
#grace-page {
font-size: $--font-base-size;
display: flex;
border-bottom: none;
box-sizing: border-box;
height: 40px;
line-height: 40px;
background-color: $--color-white;
.num {
color: $--font-color-primary;
margin-right: 10px;
padding-left: 10px;
span:nth-of-type(1){
width:80px;
display: inline-block;
margin-right: 14px;
}
span:nth-of-type(2){
width:85px;
display: inline-block;
height: 20px;
line-height: 20px;
border-right: 1px solid #e1e1e1;
padding-right: 25px;
}
}
}
\ No newline at end of file
@import "./var.scss";
#grace-skid {
width: 500px;
position: fixed;
height: 100%;
right: 0;
top: 0;
z-index: 2000;
background-color: $--color-white;
.skid-head {
padding: 23px 16px;
box-shadow: 10px 0 32px -3px #eee;
text-align: center;
font-weight: bold;
margin-bottom: 30px;
.el-icon-arrow-right {
cursor: pointer;
position: absolute;
color: $--color-white;
left: 0;
top: 0;
width: 60px;
height: 60px;
background: #ffc43d;
border-radius: 0px 0px 90% 0px;
font-size: 26px;
&:hover {
background-color: #ffc94e;
}
&:active {
background-color: #ffbe1c;
}
&::before {
position: absolute;
left: 10px;
top: 10px;
}
}
span {
font-size: 16px;
color: #464646;
}
}
}
\ No newline at end of file
@import "var";
#grace-table {
.el-table {
font-size: 12px;
border-left: none;
color: $--table-font-color;
// 表头样式
.table_header {
height: 40px;
}
.el-table__header{
position: relative;
z-index: 110;
tr{
th{
background-color:$--color-primary;
color: $--color-white;
font-weight: 900;
// 表头全选按钮
.el-checkbox__input.is-indeterminate .el-checkbox__inner{
border-color: $--color-white;
}
.el-checkbox__input.is-checked .el-checkbox__inner{
border-color: $--color-white;
}
}
// 去掉最后一个单元格右边线
th:nth-last-of-type(2){
border-right: none !important
}
}
}
// 表格高度
.el-table__body {
tr {
height: 30px;
padding: 0;
td {
padding: 1px 0px;
}
// checkbox选中样式
.el-checkbox__input.is-checked .el-checkbox__inner{
background-color: $--table-checkbox-color;
border-color: $--table-checkbox-color;
}
// checkbox划过样式
.el-checkbox__inner {
&:hover {
border-color: $--table-checkbox-color;
}
}
}
}
}
// 划上高亮颜色修改
.el-table--enable-row-hover .el-table__body tr:hover > td{
background: inherit;
}
.el-table--enable-row-hover .el-table__body tr:hover{
box-shadow: 0px 0px 15px 0px rgba(4, 0, 0, 0.15);
background-color: none !important;
transform: scale(1);
}
}
\ No newline at end of file
@import "./var.scss";
#details {
.el-form {
// label样式
.el-form-item__label {
color: #5b5b5b;
text-align-last: left;
font-size: 12px;
}
.el-form-item--mini.el-form-item{
margin-left: 20px;
}
// 输入框的样式大小
.el-input .el-input__inner{
width: 280px;
}
}
}
\ No newline at end of file
#search {
padding:25px 20px 0px;
.el-form-item--mini.el-form-item{
margin-bottom: 15px;
}
/* 每条信息的label文字样式 */
.el-form-item__label{
// position: relative;
color: #5b5b5b;
font-family: 'MicrosoftYaHei';
text-align-last: justify;
font-size: 14px;
}
/* 输入框的样式大小 */
.el-input,.el-input__inner{
width: 200px;
}
// 第一行表单
.first_line{
display: flex;
justify-content: space-between;
flex-wrap: wrap
}
}
\ No newline at end of file
......@@ -12,6 +12,8 @@
* @date 2019-05-17
*/
export default {
}
mounted () {
console.log('测试:', this);
}
};
</script>
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论