Skip to content

Commit

Permalink
Update config
Browse files Browse the repository at this point in the history
  • Loading branch information
simonguo committed Jul 3, 2017
1 parent c0d6629 commit f042082
Show file tree
Hide file tree
Showing 9 changed files with 6,390 additions and 147 deletions.
6 changes: 5 additions & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
{
"presets": ["stage-0", "react", "es2015"]
"presets": [
"stage-0",
"react",
"es2015"
]
}
6 changes: 1 addition & 5 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ root = true
charset = utf-8
end_of_line = lf
indent_style = space
indent_size = 4
indent_size = 2
trim_trailing_whitespace = true
insert_final_newline = true

[package.json]
indent_style = space
indent_size = 2
57 changes: 0 additions & 57 deletions .eslintrc

This file was deleted.

60 changes: 60 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
'use strict';

const OFF = 0;
const WARNING = 1;
const ERROR = 2;

module.exports = {
'extends': 'airbnb',
'env': {
'browser': true,
'es6': true,
'mocha': true
},
'parser': 'babel-eslint',
'plugins': [
'react',
'babel'
],
'parserOptions': {
'ecmaVersion': 6,
'sourceType': 'module',
'ecmaFeatures': {
'jsx': true,
'experimentalObjectRestSpread': true
}
},
'rules': {
'indent': [ERROR, 2, { 'SwitchCase': 1 }], //规定代码的缩进方式:2个空格
'camelcase': ERROR, //强制驼峰法命名
'curly': ERROR, //必须使用 if(){} 中的{}
'eqeqeq': ERROR, //必须使用全等
'brace-style': [ERROR, '1tbs'], //大括号风格
'quotes': [ERROR, 'single'], //引号类型
'semi': [ERROR, 'always'], //语句强制分号结尾
'space-infix-ops': ERROR, //中缀操作符周围要不要有空格
'no-param-reassign': OFF, //不允许对函数的形参进行赋值
'prefer-spread': ERROR, //首选展开运算
'comma-dangle': OFF, //不允许或强制在对象字面量或者数组属性的结尾使用逗号
'padded-blocks': OFF, //规定代码块前后是否要加空行
'prefer-const': OFF,
'no-multi-spaces': ERROR,
'no-var': OFF,
'one-var': OFF,
/**
* https://github.com/airbnb/javascript/tree/master/react
*/
'react/prefer-es6-class': [WARNING, 'always'], //使用 class extends React.Component
'react/jsx-pascal-case': ERROR, //骆驼式命名
'react/jsx-closing-bracket-location': ERROR, //JSX语法缩进/格式
'react/jsx-curly-spacing': ERROR, //JSX {} 引用括号里两边加空格
'react/jsx-boolean-value': [ERROR, 'always'], //如果属性值为 true, 可以直接省略
'jsx-quotes': [ERROR, 'prefer-double'], //JSX属性值总是使用双引号(")
'react/no-string-refs': ERROR, //Refs里使用回调函数
'react/jsx-wrap-multilines': ERROR, //多行的JSX标签写在 ()里
'react/self-closing-comp': ERROR, //没有子元素的标签来说总是自己关闭标签
'react/jsx-no-bind': ERROR, //当在 render() 里使用事件处理方法时,提前在构造函数里把 this 绑定上去
'react/no-is-mounted': ERROR, //不要再使用 isMounted
'jsx-a11y/href-no-hash': OFF
}
};
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,3 @@ docs/assets

# custom
.idea

78 changes: 39 additions & 39 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,46 +1,46 @@
var webpackConfig = {
output: {
pathinfo: true
},
module: {
loaders: [{
test: /\.js$/,
loaders: [
'babel?babelrc'
],
exclude: /node_modules/
}]
},
devtool: 'eval'
output: {
pathinfo: true
},
module: {
rules: [{
test: /\.jsx?$/,
use: [
'babel-loader'
],
exclude: /node_modules/
}]
},
devtool: 'eval'
};

module.exports = function (config) {
const { env } = process;
config.set({
basePath: '',
files: ['test/index.js'],
frameworks: [
'mocha',
'sinon-chai'
],
colors: true,
reporters: ['mocha'],
const { env } = process;
config.set({
basePath: '',
files: ['test/index.js'],
frameworks: [
'mocha',
'sinon-chai'
],
colors: true,
reporters: ['mocha'],

logLevel: config.LOG_INFO,
preprocessors: {
'test/index.js': ['webpack'],
},
webpack: webpackConfig,
webpackMiddleware: {
noInfo: true
},
browsers: env.BROWSER ? env.BROWSER.split(',') : ['Chrome'],
customLaunchers: {
ChromeCi: {
base: 'Chrome',
flags: ['--no-sandbox'],
},
}
});
logLevel: config.LOG_INFO,
preprocessors: {
'test/index.js': ['webpack'],
},
webpack: webpackConfig,
webpackMiddleware: {
noInfo: true
},
browsers: env.BROWSER ? env.BROWSER.split(',') : ['Chrome'],
customLaunchers: {
ChromeCi: {
base: 'Chrome',
flags: ['--no-sandbox'],
},
}
});
};

36 changes: 17 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rsuite",
"version": "1.0.11",
"version": "2.0.0",
"description": "A suite of react components",
"main": "lib/index.js",
"directories": {
Expand All @@ -9,13 +9,13 @@
"scripts": {
"build": "babel-node tools/build.js",
"tdd": "karma start",
"lint": "eslint src *.js",
"lint": "eslint src *.js*",
"test": "npm run lint && karma start --single-run"
},
"keywords": [
"react",
"suite",
"rsuite",
"component",
"react-component"
],
"author": "Simon Guo <[email protected]>",
Expand All @@ -30,8 +30,9 @@
],
"dependencies": {
"classnames": ">=2.0.0",
"dom-lib": "0.0.16",
"lodash": "^4.11.1"
"dom-lib": "^0.2.3",
"lodash": "^4.11.1",
"rsuite-utils": "^0.0.1"
},
"peerDependencies": {
"react": ">=0.14.0",
Expand All @@ -51,16 +52,15 @@
"colors": "^1.1.2",
"css-loader": "^0.23.1",
"es3ify-loader": "^0.2.0",
"eslint": "^1.10.3",
"eslint-config-airbnb": "^12.0.0",
"eslint-plugin-babel": "^3.2.0",
"eslint-plugin-import": "^2.0.1",
"eslint-plugin-jsx-a11y": "^2.2.3",
"eslint-plugin-react": "^5.0.1",
"eslint": "^3.19.0",
"eslint-config-airbnb": "^15.0.1",
"eslint-plugin-babel": "^4.1.1",
"eslint-plugin-import": "^2.6.1",
"eslint-plugin-jsx-a11y": "^6.0.2",
"eslint-plugin-react": "^7.1.0",
"extract-text-webpack-plugin": "^1.0.1",
"fs-promise": "^0.5.0",
"glob": "^7.0.3",
"highlight.js": "^9.4.0",
"html-loader": "^0.4.3",
"html-webpack-plugin": "^2.22.0",
"karma": "^1.1.1",
Expand All @@ -72,26 +72,24 @@
"karma-mocha-reporter": "^2.0.4",
"karma-sinon-chai": "^1.2.2",
"karma-sourcemap-loader": "^0.3.7",
"karma-webpack": "^1.7.0",
"karma-webpack": "2.0.3",
"less": "^2.7.1",
"less-loader": "^2.2.3",
"markdown-loader": "^0.1.7",
"marked": "^0.3.5",
"mocha": "^2.5.3",
"output-file-sync": "^1.1.1",
"postcss-loader": "^0.9.1",
"react": "^15.4.0",
"react-dom": "^15.4.0",
"react-hot-loader": "^1.3.0",
"react-router": "2.0.1",
"rimraf": "^2.5.2",
"rsuite-form": "0.1.6",
"rsuite-schema": "0.0.1-alpha.2",
"sinon": "^1.17.4",
"sinon-chai": "^2.8.0",
"style-loader": "^0.13.1",
"transform-loader": "^0.2.3",
"webpack": "^1.13.1",
"webpack-dev-server": "^1.14.1",
"react": "^15.4.0",
"react-dom": "^15.4.0"
"webpack": "^3.0.0",
"webpack-dev-server": "^2.3.0"
}
}
50 changes: 25 additions & 25 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,32 @@ const isPublish = process.env.NODE_ENV === 'publish';
const plugins = [];

if (isPublish) {
plugins.push(new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
}));
plugins.push(new webpack.BannerPlugin(`Last update: ${new Date().toString()}`));
plugins.push(new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
}));
plugins.push(new webpack.BannerPlugin(`Last update: ${new Date().toString()}`));
}

module.exports = {
entry: {
suite: path.join(__dirname, 'src')
},
output: {
path: path.join(__dirname, 'dist'),
filename: '[name].js',
library: 'Suite',
libraryTarget: 'umd'
},
plugins: plugins,
module: {
loaders: [{
test: /\.js$/,
loaders: [
'babel?babelrc'
],
exclude: /node_modules/
}]
}
entry: {
suite: path.join(__dirname, 'src')
},
output: {
path: path.join(__dirname, 'dist'),
filename: '[name].js',
library: 'RSuite',
libraryTarget: 'umd'
},
plugins: plugins,
module: {
rules: [{
test: /\.jsx?$/,
use: [
'babel-loader?babelrc'
],
exclude: /node_modules/
}]
}
};
Loading

0 comments on commit f042082

Please sign in to comment.