xyzdata / redux-simple-tutorial

Redux 莞式教程。本教程深入浅出,配套入门、进阶源码解读以及文档注释丰满的 Demo 等一条龙服务
0 stars 1 forks source link

ESlint inline #4

Open xgqfrms-GitHub opened 7 years ago

xgqfrms-GitHub commented 7 years ago

ESlint

ESlint inline


/* eslint-disable no-underscore-dangle */

console.log(`enable all`);

/* eslint-enable */

/* eslint-disable no-console */

console.log(`only enable no-console`);

/* eslint-enable no-console*/
xgqfrms-GitHub commented 7 years ago

.eslintrc


{
    "parser": "babel-eslint",
    "parserOptions": {
        "ecmaVersion": 6,
        "sourceType": "module",
        "ecmaFeatures": {
            "jsx": true,
            "modules": true,
            "experimentalObjectRestSpread": true
        }
    },
    "plugins": [
        "react"
    ],
    "extends": ["eslint:recommended", "plugin:react/recommended"],
    "rules": {
        "comma-dangle": 0,
        "react/jsx-uses-vars": 1,
        "react/display-name": 1,
        "react/prop-types": 1,
        "no-unused-vars": "warn",
        "no-console": 1,
        "no-unexpected-multiline": "warn"
    },
    "settings": {
        "react": {
            "pragma": "React",
            "version": "15.6.1"
        }
    }
}
xgqfrms-GitHub commented 7 years ago

/* eslint-disable no-console */
/* eslint-disable react/prop-types */

console.log(`enable all`);

/* eslint-enable */
xgqfrms-GitHub commented 7 years ago

Object.keys()

https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Object/keys

Object.keys(obj) / Object.keys(arr)


let abc = {a: "a", b: "b", c: "c"};
console.log(Object.keys(abc));
// (3) ["a", "b", "c"]

let xyz = {x: "xxx", y: "yyy", z: "zzz"};
console.log(Object.keys(xyz));
// (3) ["x", "y", "z"]

// array like object with random key ordering
let anObj = { 100: 'a', 2: 'b', 7: 'c' };
console.log(Object.keys(anObj)); 
// ['2', '7', '100']

// 类数组 对象, 随机 key 排序 
let anObj = { 100: 'a', 2: 'b', 7: 'c' }; 

console.log(Object.keys(anObj)); 
// ['2', '7', '100']

/* getFoo 是个不可枚举的属性 */ 

let my_obj = Object.create(
    {}, 
    {
        getFoo: {
            value: function() {return this.foo;}
        }
    }
);

my_obj.foo = 1;

console.log(Object.keys(my_obj)); 
// ["foo"]

console.log(my_obj);
// {foo: 1, getFoo: ƒ}
xgqfrms-GitHub commented 7 years ago

react & e.preventDefault(); & e.stopPropagation();

https://gist.github.com/xgqfrms-gildata/77f802a3a7744c85cf117d3666c85e9d

xgqfrms-GitHub commented 7 years ago

https://github.com/xgqfrms-gildata/redux-simple-tutorial/issues/5

Array.some() 实现的是非贪心算法(Regex: Regular Expression),只要找到一个 true 就立即返回,不再向后面搜索了!