Skip to content

Commit 11f9792

Browse files
Add initial configs for js, vue and react
0 parents  commit 11f9792

File tree

10 files changed

+1733
-0
lines changed

10 files changed

+1733
-0
lines changed

.editorconfig

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
root = true
2+
3+
[*]
4+
end_of_line = lf
5+
insert_final_newline = true
6+
indent_style = space
7+
indent_size = 4
8+
trim_trailing_whitespace = true
9+
charset = utf-8
10+
11+
[{*.json}]
12+
indent_style = space
13+
indent_size = 2

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.DS_Store
2+
.vscode/
3+
.idea
4+
node_modules/
5+
npm-debug.log
6+
yarn-error.log
7+
yarn.output

.npmignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.DS_Store
2+
.vscode/
3+
.idea
4+
npm-debug.log
5+
yarn-error.log
6+
yarn.output
7+
.editorconfig

LICENSE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) Firework Web <[email protected]>
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

README.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# @fireworkweb/eslint-config
2+
3+
Eslint rule configs for Javascript and Vue.js projects.
4+
5+
## Installation
6+
7+
```bash
8+
# With yarn
9+
yarn add -D @fireworkweb/eslint-config
10+
11+
# With npm
12+
npm install --dev @fireworkweb/eslint-config
13+
```
14+
15+
## Usage
16+
17+
Currently there are two configs available: `js` for pure javascript projects, `vue` for Vue.js projects and `react` for React projects. The `vue` and `react` configs already includes the `js` config.
18+
19+
After installing, create a `.eslintrc.js` file and add this to your config (add only one):
20+
21+
```js
22+
module.exports = {
23+
extends: [
24+
// for javascript project
25+
'@fireworkweb/eslint-config/js',
26+
// for vue project
27+
'@fireworkweb/eslint-config/vue',
28+
// for react project
29+
'@fireworkweb/eslint-config/react',
30+
],
31+
};
32+
```
33+
34+
### Custom Rules
35+
36+
You can customize any rules ([js](https://eslint.org/docs/rules/), [vue](https://eslint.vuejs.org/rules/)), [react](https://github.com/yannickcr/eslint-plugin-react#list-of-supported-rules)) as this example:
37+
38+
```js
39+
module.exports = {
40+
extends: [
41+
'@fireworkweb/eslint-config/js',
42+
],
43+
rules: {
44+
'no-console': 'off',
45+
},
46+
};
47+
```
48+
49+
You can also (and probably will) add any specific global variable:
50+
51+
```js
52+
// for vue project
53+
module.exports = {
54+
extends: [
55+
'@fireworkweb/eslint-config/vue',
56+
],
57+
globals: {
58+
Vue: true, // if you set window.Vue
59+
_: true, // lodash/underscore
60+
Nova: true, // Laravel Nova
61+
},
62+
};
63+
```
64+
65+
## License
66+
67+
[MIT](LICENSE.md).

js.js

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
module.exports = {
2+
extends: [
3+
'eslint:recommended',
4+
'plugin:promise/recommended',
5+
],
6+
parser: 'babel-eslint',
7+
parserOptions: {
8+
parser: 'babel-eslint',
9+
ecmaVersion: 2017,
10+
sourceType: 'module',
11+
allowImportExportEverywhere: true,
12+
},
13+
env: {
14+
amd: true,
15+
node: true,
16+
},
17+
ignorePatterns: [
18+
'**/public/**/*',
19+
'**/dist/**/*',
20+
'**/node_modules/**/*',
21+
'**/vendor/**/*',
22+
],
23+
rules: {
24+
'indent': ['error', 4, { 'SwitchCase': 1, 'MemberExpression': 1 }],
25+
'no-trailing-spaces': 'error',
26+
'no-console': process.env.NODE_ENV === 'production' ? [
27+
'error',
28+
{ 'allow': ['warn', 'error'] },
29+
] : 'off',
30+
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
31+
'no-fallthrough': 'off',
32+
'no-case-declarations': 'off',
33+
'space-before-function-paren': 'error',
34+
'spaced-comment': 'error',
35+
'arrow-spacing': 'error',
36+
'key-spacing': [2, {'beforeColon': false, 'afterColon': true}],
37+
'keyword-spacing': 'error',
38+
'semi': ['error', 'always'],
39+
'dot-location': ['error', 'property'],
40+
'dot-notation': 'error',
41+
'no-alert': 'off',
42+
'eqeqeq': ['error', 'always'],
43+
'no-floating-decimal': 'error',
44+
'no-global-assign': 'error',
45+
'no-multi-spaces': 'error',
46+
'no-useless-return': 'error',
47+
'no-undef-init': 'warn',
48+
'no-use-before-define': ['error', { 'functions': false }],
49+
'array-bracket-newline': ['error', 'consistent'],
50+
'brace-style': ['error', '1tbs'],
51+
'comma-dangle': ['error', 'always-multiline'],
52+
'comma-spacing': 'error',
53+
'comma-style': 'error',
54+
'eol-last': 'error',
55+
'func-call-spacing': 'error',
56+
'quotes': ['error', 'single', { 'allowTemplateLiterals': true }],
57+
'quote-props': ['error', 'as-needed'],
58+
'linebreak-style': 'warn',
59+
'lines-around-comment': 'warn',
60+
'max-depth': ['error', 3],
61+
'max-statements-per-line': 'error',
62+
'newline-per-chained-call': 'error',
63+
'no-lonely-if': 'error',
64+
'no-mixed-operators': 'warn',
65+
'no-multiple-empty-lines': ['error', { 'max': 1, 'maxEOF': 0, 'maxBOF': 0 }],
66+
'no-tabs': 'warn',
67+
'space-before-blocks': 'error',
68+
'space-infix-ops': 'error',
69+
'space-unary-ops': [2, {
70+
'words': true,
71+
'nonwords': true,
72+
'overrides': {
73+
'-': false,
74+
'++': false,
75+
'--': false,
76+
},
77+
}],
78+
'space-in-parens': 'error',
79+
'switch-colon-spacing': 'error',
80+
'arrow-body-style': 'error',
81+
'no-duplicate-imports': 'warn',
82+
'no-useless-computed-key': 'warn',
83+
'no-var': 'error',
84+
'arrow-parens': ['error', 'as-needed'],
85+
'curly': 'error',
86+
'object-curly-spacing': ['error', 'always'],
87+
'require-atomic-updates': 'off',
88+
'no-prototype-builtins': 'off',
89+
'object-shorthand': ['error', 'always'],
90+
'promise/prefer-await-to-then': 'error',
91+
},
92+
};

package.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"name": "@fireworkweb/eslint-config",
3+
"version": "1.0.0",
4+
"description": "Custom eslint config for Firework projects",
5+
"homepage": "https://github.com/fireworkweb/eslint-config#readme",
6+
"bugs": "https://github.com/fireworkweb/eslint-config/issues",
7+
"author": "Firework Web <[email protected]>",
8+
"license": "MIT",
9+
"main": "js.js",
10+
"keywords": [
11+
"eslint",
12+
"eslint-plugin",
13+
"eslint-config",
14+
"javascript",
15+
"vue",
16+
"vuejs",
17+
"rules"
18+
],
19+
"peerDependencies": {
20+
"eslint": "^5.0.0 || ^6.0.0"
21+
},
22+
"dependencies": {
23+
"babel-eslint": "^10.1.0",
24+
"eslint": "^6.8.0",
25+
"eslint-plugin-promise": "^4.2.1",
26+
"eslint-plugin-react": "^7.19.0",
27+
"eslint-plugin-vue": "^6.2.2",
28+
"vue-eslint-parser": "^7.0.0"
29+
}
30+
}

react.js

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
module.exports = {
2+
extends: [
3+
'./js',
4+
'plugin:react/recommended',
5+
],
6+
env: {
7+
amd: true,
8+
browser: true,
9+
node: true,
10+
},
11+
rules: {
12+
'jsx-quotes': ['error', 'prefer-single'],
13+
'object-curly-spacing': 'off',
14+
'react/prop-types': 0,
15+
'react/jsx-max-props-per-line': ['error', {'maximum': 1, 'when': 'always' }],
16+
'react/jsx-first-prop-new-line': ['error', 'multiline-multiprop'],
17+
'react/jsx-closing-bracket-location': ['error', 'tag-aligned'],
18+
'react/jsx-closing-tag-location': 'error',
19+
'react/jsx-curly-spacing': ['error', 'never', { allowMultiline: true }],
20+
'react/sort-comp': ['error', {
21+
order: [
22+
'static-variables',
23+
'static-methods',
24+
'instance-variables',
25+
'lifecycle',
26+
'/^on.+$/',
27+
'getters',
28+
'setters',
29+
'/^(get|set)(?!(InitialState$|DefaultProps$|ChildContext$)).+$/',
30+
'instance-methods',
31+
'everything-else',
32+
'rendering',
33+
],
34+
groups: {
35+
lifecycle: [
36+
'displayName',
37+
'propTypes',
38+
'contextTypes',
39+
'childContextTypes',
40+
'mixins',
41+
'statics',
42+
'defaultProps',
43+
'constructor',
44+
'getDefaultProps',
45+
'getInitialState',
46+
'state',
47+
'getChildContext',
48+
'getDerivedStateFromProps',
49+
'componentWillMount',
50+
'UNSAFE_componentWillMount',
51+
'componentDidMount',
52+
'componentWillReceiveProps',
53+
'UNSAFE_componentWillReceiveProps',
54+
'shouldComponentUpdate',
55+
'componentWillUpdate',
56+
'UNSAFE_componentWillUpdate',
57+
'getSnapshotBeforeUpdate',
58+
'componentDidUpdate',
59+
'componentDidCatch',
60+
'componentWillUnmount',
61+
],
62+
rendering: [
63+
'/^render.+$/',
64+
'render',
65+
],
66+
},
67+
}],
68+
'react/jsx-no-duplicate-props': ['error', { ignoreCase: true }],
69+
'react/jsx-pascal-case': ['error', {
70+
allowAllCaps: true,
71+
ignore: [],
72+
}],
73+
'react/no-danger': 'warn',
74+
'react/prefer-es6-class': ['error', 'always'],
75+
'react/prefer-stateless-function': ['error', { ignorePureComponents: true }],
76+
'react/react-in-jsx-scope': 'error',
77+
'react/require-render-return': 'error',
78+
'react/self-closing-comp': 'error',
79+
'react/jsx-wrap-multilines': ['error', {
80+
declaration: 'parens-new-line',
81+
assignment: 'parens-new-line',
82+
return: 'parens-new-line',
83+
arrow: 'parens-new-line',
84+
condition: 'parens-new-line',
85+
logical: 'parens-new-line',
86+
prop: 'parens-new-line',
87+
}],
88+
'react/no-danger-with-children': 'error',
89+
'react/no-unused-prop-types': ['error', {
90+
customValidators: [
91+
],
92+
skipShapeProps: true,
93+
}],
94+
'react/destructuring-assignment': ['error', 'always'],
95+
'react/no-redundant-should-component-update': 'error',
96+
'react/no-unused-state': 'error',
97+
'react/no-typos': 'error',
98+
'react/jsx-tag-spacing': ['error', {
99+
closingSlash: 'never',
100+
beforeSelfClosing: 'always',
101+
afterOpening: 'never',
102+
beforeClosing: 'never',
103+
}],
104+
'react/boolean-prop-naming': ['off', {
105+
propTypeNames: ['bool', 'mutuallyExclusiveTrueProps'],
106+
rule: '^(is|has)[A-Z]([A-Za-z0-9]?)+',
107+
message: '',
108+
}],
109+
'react/jsx-curly-brace-presence': ['error', { props: 'never', children: 'never' }],
110+
'react/no-access-state-in-setstate': 'error',
111+
'react/jsx-props-no-multi-spaces': 'error',
112+
'react/jsx-curly-newline': ['error', {
113+
multiline: 'consistent',
114+
singleline: 'consistent',
115+
}],
116+
'react/jsx-props-no-spreading': ['warn', {
117+
html: 'enforce',
118+
custom: 'enforce',
119+
exceptions: [],
120+
}],
121+
},
122+
};

0 commit comments

Comments
 (0)