Skip to content

Commit

Permalink
Merge pull request #14 from AfterShip/4.x
Browse files Browse the repository at this point in the history
4.x release PR
  • Loading branch information
hans-lizihan authored Jun 28, 2017
2 parents 52f1b96 + 98dc3a8 commit 11d44a1
Show file tree
Hide file tree
Showing 34 changed files with 5,671 additions and 556 deletions.
1 change: 1 addition & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ root = true
[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = tab
insert_final_newline = true
trim_trailing_whitespace = true
Expand Down
3 changes: 0 additions & 3 deletions .eslintrc

This file was deleted.

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

module.exports = require('./index');
7 changes: 0 additions & 7 deletions .publishignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,3 @@
.eslintrc
.publishignore
.travis.yml
grunt
grunt-config
grunt-tasks
gulpfile.js
Gruntfile.js
log
test
26 changes: 26 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
language: node_js
node_js:
- "6"
- "8"
sudo: false

notifications:
email:
- [email protected]
env:
- CACHE_DIR=cache CXX=g++-4.8
cache:
apt: true
directories:
- $CACHE_DIR
install:
- npm install
script:
- npm run lint

addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- g++-4.8
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2015 AfterShip
Copyright (c) 2017 AfterShip

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
Expand Down
49 changes: 37 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# eslint-config-aftership

!! NOTE this is for node <= v4 only, if your have a legacy project to maintain, or dont want to bother upgrade to the latest version, please see [v3 branch](https://github.com/AfterShip/eslint-config-aftership/tree/3.x), if you are upgrading to v4, please see [upgrade guide](https://github.com/AfterShip/eslint-config-aftership/blob/4.x/upgrade_guides/v3tov4.md), see all changes in [v4 shiplist](https://github.com/AfterShip/eslint-config-aftership/issues/13)

[![Build Status](https://travis-ci.org/AfterShip/eslint-config-aftership.svg?branch=master)](https://travis-ci.org/AfterShip/eslint-config-aftership)
[![Dependency Status](https://gemnasium.com/AfterShip/eslint-config-aftership.svg)](https://gemnasium.com/AfterShip/eslint-config-aftership)

[![node](https://img.shields.io/node/v/eslint-config-aftership.svg)]()
Expand All @@ -9,15 +12,15 @@

AfterShip ESLint config (modified from eslint-config-airbnb)

following [Airbnb JavaScript Style Guide](https://github.com/airbnb/javascript) commit [a3495e07f484513db203e5d5654e47b221c19f4a](https://github.com/airbnb/javascript/blob/a3495e07f484513db203e5d5654e47b221c19f4a/README.md)
following [Airbnb JavaScript Style Guide](https://github.com/airbnb/javascript) commit [2666db559dc0ef41887a1138cff4f59b3879892a](https://github.com/airbnb/javascript/tree/2666db559dc0ef41887a1138cff4f59b3879892a)

## Rules that cannot be checked by ESLint
## Rules that cannot be checked by ESLint (Backend only)
* Use `snake_case` for files and folders
* Use `camelCase` when naming `functions`
* Use `UpperCamelCase` when naming `class variables`
* Use `PascalCase` when naming `class variables`
* Use `snake_case` when naming `variables`

`let name = 'John';`, `let email_address = '[email protected]';`
`const name = 'John';`, `const email_address = '[email protected]';`

* Use `UPPERCASE` when naming `constant variables` but no need for `required module`

Expand All @@ -41,7 +44,7 @@ following [Airbnb JavaScript Style Guide](https://github.com/airbnb/javascript)

}

example_function1() {
exampleFunction1() {

}

Expand All @@ -66,11 +69,13 @@ Z for removing rules/options (more loose)

## Installation

as we support frontend and backend project at the same time, some framework specific plugins are declared in `optionalDependencies`, so you have install then at the project level.

### on your repository:
- **If you are `AfterShip` member, `grunt-init-node` already installed it for you**

- If you are not or you want to install in the existing repository:
1. `npm install --save-dev eslint-config-aftership`
1. `npm install --save-dev eslint-config-aftership eslint eslint-plugin-import`

2. Keep the `^` in the `package.json` for `eslint-config-aftership`, if the project is still in development. Replace the `^` with `~` if you want to prevent new rules which may brother you in travis.

Expand All @@ -82,19 +87,39 @@ Z for removing rules/options (more loose)
}
```

If your repo is using node version `<= 0.10`, `aftership/legacy` will assume you are using ES5 instead of ES6 up
If your repo is a **React** project using webpack.js, you should extends `aftership/react`, and install additional packages

```sh
npm install eslint-plugin-html eslint-plugin-react eslint-plugin-jsx-a11y babel-eslint eslint-import-resolver-webpack
```

```json
{
"extends": "aftership/legacy"
"extends": "aftership/react",
"settings": {
"import/resolver": {
"webpack": {
"config": "webpack.config.js"
}
}
}
```

If your repo is a front-end project using babel.js, you should extends `aftership/react` instead`
If your repo is a **Vue** project using webpack, you should extends `aftership/vue`, and install additional packages

```sh
npm install eslint-plugin-html [email protected] babel-eslint [email protected] eslint-import-resolver-webpack
```

```json
{
"extends": "aftership/react"
"extends": "aftership/vue",
"settings": {
"import/resolver": {
"webpack": {
"config": "webpack.config.js"
}
}
}
```

Expand All @@ -104,7 +129,7 @@ Z for removing rules/options (more loose)
```json
{
"scripts": {
"lint": "eslint --ext .jsx,.js ."
"lint": "eslint --ext .{jsx|vue},.js ."
}
}
```
Expand Down Expand Up @@ -179,6 +204,6 @@ Z for removing rules/options (more loose)
- NA

## License
Copyright (c) 2015 AfterShip
Copyright (c) 2017 AfterShip

Licensed under the MIT license.
21 changes: 21 additions & 0 deletions frontend.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
'use strict';

module.exports = {
extends: [
'./index',
'./rules/frontend'
].map(require.resolve),
parser: 'babel-eslint',
parserOptions: {
sourceType: 'module',
ecmaVersion: 2017,
ecmaFeatures: {
experimentalObjectRestSpread: true
}
},
rules: {
// this two doesn't work in vue
'import/no-named-as-default': 'off',
'import/no-named-as-default-member': 'off'
}
};
34 changes: 16 additions & 18 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
'use strict';

const extendConfig = require('./lib/extend_config');

module.exports = extendConfig({
module.exports = {
extends: [
'eslint-config-airbnb/base',
'eslint-config-aftership/rules/main'
],
'./rules/best-practices',
'./rules/errors',
'./rules/es6',
'./rules/strict',
'./rules/imports',
'./rules/node',
'./rules/style',
'./rules/variables'
].map(require.resolve),
env: {
mocha: true
},
parserOptions: {
ecmaFeatures: {
// if you want to use jsx, extends "aftership/react"
jsx: false
},
ecmaVersion: 2017,
// we use require() instead of `import ... from ...`
sourceType: 'script'
},
rules: {
/*++++++++++++++
+ Strict Mode +
++++++++++++++*/
// http://eslint.org/docs/rules/strict
strict: [2, 'global']
}
});
rules: {}
};
25 changes: 0 additions & 25 deletions legacy.js

This file was deleted.

59 changes: 0 additions & 59 deletions lib/extend_config.js

This file was deleted.

1 change: 0 additions & 1 deletion node_modules/eslint-config-aftership

This file was deleted.

Loading

0 comments on commit 11d44a1

Please sign in to comment.