Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: airbnb/javascript
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: webcoding/javascript-style-guide
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Can’t automatically merge. Don’t worry, you can still create the pull request.

Commits on Nov 1, 2016

  1. update

    cloudyan committed Nov 1, 2016

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    331353e View commit details
  2. eslint 配置

    cloudyan committed Nov 1, 2016
    Copy the full SHA
    b014be2 View commit details
  3. update .eslintrc.js

    cloudyan committed Nov 1, 2016
    Copy the full SHA
    6c566bc View commit details

Commits on Feb 8, 2017

  1. copy es6 中文版

    cloudyan committed Feb 8, 2017
    Copy the full SHA
    46bc6da View commit details
  2. es6 中文版 v2

    cloudyan committed Feb 8, 2017
    Copy the full SHA
    3564705 View commit details
  3. Copy the full SHA
    f721e3c View commit details

Commits on Feb 9, 2017

  1. ES6 代码更新

    cloudyan committed Feb 9, 2017
    Copy the full SHA
    f4a6980 View commit details
  2. 更新

    cloudyan committed Feb 9, 2017
    Copy the full SHA
    7ff1c1f View commit details
  3. 参数写成多行时规则

    cloudyan committed Feb 9, 2017
    Copy the full SHA
    b006fb6 View commit details
  4. 新增用法示例

    cloudyan committed Feb 9, 2017
    Copy the full SHA
    6c76699 View commit details

Commits on Feb 10, 2017

  1. 新增代码调整 doc

    cloudyan committed Feb 10, 2017
    Copy the full SHA
    fe6f77d View commit details
  2. 新增代码调整 doc

    cloudyan committed Feb 10, 2017
    Copy the full SHA
    6556bdd View commit details
  3. 更新文档

    cloudyan committed Feb 10, 2017
    Copy the full SHA
    6506e57 View commit details
  4. 更新文档

    cloudyan committed Feb 10, 2017
    Copy the full SHA
    ac54e57 View commit details
  5. 更新.eslintrc

    cloudyan committed Feb 10, 2017
    Copy the full SHA
    6ad81f1 View commit details
  6. 更新

    cloudyan committed Feb 10, 2017
    Copy the full SHA
    bac8aa2 View commit details
  7. eslint 配置

    cloudyan committed Feb 10, 2017
    Copy the full SHA
    2ca8400 View commit details

Commits on Feb 11, 2017

  1. 更新

    cloudyan committed Feb 11, 2017
    Copy the full SHA
    e139c75 View commit details

Commits on Feb 15, 2017

  1. 文档部分调整

    cloudyan committed Feb 15, 2017
    Copy the full SHA
    834739e View commit details
  2. Copy the full SHA
    8e91e84 View commit details
  3. 更新

    cloudyan committed Feb 15, 2017
    Copy the full SHA
    fd910e0 View commit details
  4. 更新

    cloudyan committed Feb 15, 2017
    Copy the full SHA
    747b561 View commit details

Commits on Feb 16, 2017

  1. Copy the full SHA
    91ee7e5 View commit details
  2. 更新

    cloudyan committed Feb 16, 2017
    Copy the full SHA
    83e6ff6 View commit details
  3. 更新

    cloudyan committed Feb 16, 2017
    Copy the full SHA
    f01eb5a View commit details
  4. 更新

    cloudyan committed Feb 16, 2017
    Copy the full SHA
    d155314 View commit details

Commits on Feb 17, 2017

  1. 文档更新

    cloudyan committed Feb 17, 2017
    Copy the full SHA
    5be8d87 View commit details
  2. eslint 配置文档

    cloudyan committed Feb 17, 2017
    Copy the full SHA
    cb24799 View commit details
  3. 代码规范部分调整

    cloudyan committed Feb 17, 2017
    Copy the full SHA
    4120fcf View commit details
  4. Copy the full SHA
    40f9418 View commit details
  5. Copy the full SHA
    3be4054 View commit details
  6. 调整 react 中文规范

    cloudyan committed Feb 17, 2017
    Copy the full SHA
    95e3eed View commit details

Commits on Feb 20, 2017

  1. 更新

    cloudyan committed Feb 20, 2017
    Copy the full SHA
    c689a80 View commit details

Commits on Feb 22, 2017

  1. Update zh-cn.md

    cloudyan authored Feb 22, 2017
    Copy the full SHA
    b052726 View commit details
  2. Update zh-cn.md

    cloudyan authored Feb 22, 2017
    Copy the full SHA
    fa27381 View commit details
Showing with 18,602 additions and 1 deletion.
  1. +103 −0 .eslintrc.js
  2. +6 −0 README.md
  3. +8 −0 docs/.eslintignore
  4. +2,111 −0 docs/clean-code-javascript.md
  5. +170 −0 docs/config-eslint.md
  6. +45 −0 docs/es5.eslintrc.js
  7. +93 −0 docs/es5.test.js
  8. +1,743 −0 docs/es5_zh-cn_v1.md
  9. +1,331 −0 docs/es5_zh-cn_v2.md
  10. +1,767 −0 docs/es5_zh-cn_v3.md
  11. +107 −0 docs/es6.test.js
  12. +2,157 −0 docs/es6_zh-cn_v1.md
  13. +3,303 −0 docs/es6_zh-cn_v2.md
  14. +3,607 −0 docs/es6_zh-cn_v3.md
  15. +75 −0 docs/js-in-html.html
  16. +135 −0 docs/rules.md
  17. +13 −0 docs/test.vue
  18. +869 −0 linters/.eslintrc.js
  19. +63 −0 linters/.eslintrc.simple.js
  20. +231 −0 linters/.eslintrc_backup
  21. +2 −0 linters/README.md
  22. +5 −1 package.json
  23. +658 −0 react/zh-cn.md
103 changes: 103 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@

// JS 书写规范
// http://eslint.org
// http://standardjs.com/rules.html
// - 规范文档参看[javascript-style-guide](https://github.com/webcoding/javascript-style-guide/blob/master/docs)
// - 具体配置及注意事项参看 [config-eslint.md](https://github.com/webcoding/javascript-style-guide/blob/master/docs/config-eslint.md)

// NOTE: 兼容性设定,放置在项目根目录,此文件同时支持 ES5、ES6 便于切换(切换注释即可,待修订)

module.exports = {
root: true,
parser: 'babel-eslint',
installedESLint: true,
parserOptions: {
ecmaVersion: 8,
sourceType: 'module',
"ecmaFeatures": {
"jsx": true,
// lambda表达式
"arrowFunctions": true,
// 块级作用域,允许使用let const
"blockBindings": true,
// class
"classes": true,
// http://es6.ruanyifeng.com/#docs/function#函数参数的默认值
"defaultParams": true,
// 解构赋值
"destructuring": true,
// http://es6.ruanyifeng.com/#docs/object#对象的扩展运算符
"experimentalObjectRestSpread": true,
// http://es6.ruanyifeng.com/#docs/iterator#for---of循环
"forOf": true,
// http://es6.ruanyifeng.com/#docs/generator
"generators": true,
// 允许使用模块,模块内默认严格模式
"modules": true,
// 允许字面量定义对象时,用表达式做属性名
// http://es6.ruanyifeng.com/#docs/object#属性名表达式
"objectLiteralComputedProperties": true,
// 允许对象字面量方法名简写
/*var o = {
method() {
return "Hello!";
}
};
等同于
var o = {
method: function() {
return "Hello!";
}
};
*/
"objectLiteralShorthandMethods": true,
/*
对象字面量属性名简写
var foo = "bar";
var baz = {foo};
baz // {foo: "bar"}
// 等同于
var baz = {foo: foo};
*/
"objectLiteralShorthandProperties": true,
// http://es6.ruanyifeng.com/#docs/function#rest参数
"restParams": true,
// http://es6.ruanyifeng.com/#docs/function#扩展运算符
"spread": true,
"superInFunctions": true,
// http://es6.ruanyifeng.com/#docs/string#模板字符串
"templateStrings": true,
"unicodeCodePointEscapes": true,
},
},
globals: {
Vue: false,
},

plugins: [
// 处理 html 文件内 js 代码规范等
'html',
],

// ES5 推荐规范
// extends: 'webcoding/configurations/airbnb/es5',
// ES6 推荐规范
extends: 'airbnb',
// extends: 'webcoding/configurations/airbnb/es6',

// add your custom rules here
rules: {
// 行尾分号,默认配置always,要求在行末加上分号,standard 配置强制不带
semi: ['error', 'never'],
// 多行模式必须带逗号,单行模式不能带逗号
'comma-dangle': ['error', 'always-multiline'],
'max-len': ['error', {'code': 160}],
// 禁止使用 console debugger
// 'no-console': 1,
// 禁止使用 debugger
// 'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0,
},
}
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Airbnb JavaScript Style Guide() {

- [ES6 中文版](https://github.com/webcoding/javascript-style-guide/blob/master/docs/es6_zh-cn_v3.md)
- [ES5 中文版](https://github.com/webcoding/javascript-style-guide/blob/master/docs/es5_zh-cn_v3.md)
- [eslint 配置注意事项](https://github.com/webcoding/javascript-style-guide/blob/master/docs/config-eslint.md)

目前代码规范只整理了写法建议,还有一些实现层面需要保持的原则,如:单一职责原则 (SRP)、开放封装原则(OCP)、里氏替换原则(LSP)、接口隔离原则(ISP)、依赖倒置原则(DIP) 等等,还有很多这样的实现案例及原则,正在整理中...

*A mostly reasonable approach to JavaScript*

[![Downloads](https://img.shields.io/npm/dm/eslint-config-airbnb.svg)](https://www.npmjs.com/package/eslint-config-airbnb)
8 changes: 8 additions & 0 deletions docs/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# /node_modules/* and /bower_components/* ignored by default

# Ignore built files except build/index.js
build/*
!build/build-test.js

**/vendor/*.js
dist/
Loading