-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add initial configs for js, vue and react
- Loading branch information
0 parents
commit 11f9792
Showing
10 changed files
with
1,733 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
root = true | ||
|
||
[*] | ||
end_of_line = lf | ||
insert_final_newline = true | ||
indent_style = space | ||
indent_size = 4 | ||
trim_trailing_whitespace = true | ||
charset = utf-8 | ||
|
||
[{*.json}] | ||
indent_style = space | ||
indent_size = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.DS_Store | ||
.vscode/ | ||
.idea | ||
node_modules/ | ||
npm-debug.log | ||
yarn-error.log | ||
yarn.output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.DS_Store | ||
.vscode/ | ||
.idea | ||
npm-debug.log | ||
yarn-error.log | ||
yarn.output | ||
.editorconfig |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) Firework Web <[email protected]> | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# @fireworkweb/eslint-config | ||
|
||
Eslint rule configs for Javascript and Vue.js projects. | ||
|
||
## Installation | ||
|
||
```bash | ||
# With yarn | ||
yarn add -D @fireworkweb/eslint-config | ||
|
||
# With npm | ||
npm install --dev @fireworkweb/eslint-config | ||
``` | ||
|
||
## Usage | ||
|
||
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. | ||
|
||
After installing, create a `.eslintrc.js` file and add this to your config (add only one): | ||
|
||
```js | ||
module.exports = { | ||
extends: [ | ||
// for javascript project | ||
'@fireworkweb/eslint-config/js', | ||
// for vue project | ||
'@fireworkweb/eslint-config/vue', | ||
// for react project | ||
'@fireworkweb/eslint-config/react', | ||
], | ||
}; | ||
``` | ||
|
||
### Custom Rules | ||
|
||
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: | ||
|
||
```js | ||
module.exports = { | ||
extends: [ | ||
'@fireworkweb/eslint-config/js', | ||
], | ||
rules: { | ||
'no-console': 'off', | ||
}, | ||
}; | ||
``` | ||
|
||
You can also (and probably will) add any specific global variable: | ||
|
||
```js | ||
// for vue project | ||
module.exports = { | ||
extends: [ | ||
'@fireworkweb/eslint-config/vue', | ||
], | ||
globals: { | ||
Vue: true, // if you set window.Vue | ||
_: true, // lodash/underscore | ||
Nova: true, // Laravel Nova | ||
}, | ||
}; | ||
``` | ||
|
||
## License | ||
|
||
[MIT](LICENSE.md). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
module.exports = { | ||
extends: [ | ||
'eslint:recommended', | ||
'plugin:promise/recommended', | ||
], | ||
parser: 'babel-eslint', | ||
parserOptions: { | ||
parser: 'babel-eslint', | ||
ecmaVersion: 2017, | ||
sourceType: 'module', | ||
allowImportExportEverywhere: true, | ||
}, | ||
env: { | ||
amd: true, | ||
node: true, | ||
}, | ||
ignorePatterns: [ | ||
'**/public/**/*', | ||
'**/dist/**/*', | ||
'**/node_modules/**/*', | ||
'**/vendor/**/*', | ||
], | ||
rules: { | ||
'indent': ['error', 4, { 'SwitchCase': 1, 'MemberExpression': 1 }], | ||
'no-trailing-spaces': 'error', | ||
'no-console': process.env.NODE_ENV === 'production' ? [ | ||
'error', | ||
{ 'allow': ['warn', 'error'] }, | ||
] : 'off', | ||
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off', | ||
'no-fallthrough': 'off', | ||
'no-case-declarations': 'off', | ||
'space-before-function-paren': 'error', | ||
'spaced-comment': 'error', | ||
'arrow-spacing': 'error', | ||
'key-spacing': [2, {'beforeColon': false, 'afterColon': true}], | ||
'keyword-spacing': 'error', | ||
'semi': ['error', 'always'], | ||
'dot-location': ['error', 'property'], | ||
'dot-notation': 'error', | ||
'no-alert': 'off', | ||
'eqeqeq': ['error', 'always'], | ||
'no-floating-decimal': 'error', | ||
'no-global-assign': 'error', | ||
'no-multi-spaces': 'error', | ||
'no-useless-return': 'error', | ||
'no-undef-init': 'warn', | ||
'no-use-before-define': ['error', { 'functions': false }], | ||
'array-bracket-newline': ['error', 'consistent'], | ||
'brace-style': ['error', '1tbs'], | ||
'comma-dangle': ['error', 'always-multiline'], | ||
'comma-spacing': 'error', | ||
'comma-style': 'error', | ||
'eol-last': 'error', | ||
'func-call-spacing': 'error', | ||
'quotes': ['error', 'single', { 'allowTemplateLiterals': true }], | ||
'quote-props': ['error', 'as-needed'], | ||
'linebreak-style': 'warn', | ||
'lines-around-comment': 'warn', | ||
'max-depth': ['error', 3], | ||
'max-statements-per-line': 'error', | ||
'newline-per-chained-call': 'error', | ||
'no-lonely-if': 'error', | ||
'no-mixed-operators': 'warn', | ||
'no-multiple-empty-lines': ['error', { 'max': 1, 'maxEOF': 0, 'maxBOF': 0 }], | ||
'no-tabs': 'warn', | ||
'space-before-blocks': 'error', | ||
'space-infix-ops': 'error', | ||
'space-unary-ops': [2, { | ||
'words': true, | ||
'nonwords': true, | ||
'overrides': { | ||
'-': false, | ||
'++': false, | ||
'--': false, | ||
}, | ||
}], | ||
'space-in-parens': 'error', | ||
'switch-colon-spacing': 'error', | ||
'arrow-body-style': 'error', | ||
'no-duplicate-imports': 'warn', | ||
'no-useless-computed-key': 'warn', | ||
'no-var': 'error', | ||
'arrow-parens': ['error', 'as-needed'], | ||
'curly': 'error', | ||
'object-curly-spacing': ['error', 'always'], | ||
'require-atomic-updates': 'off', | ||
'no-prototype-builtins': 'off', | ||
'object-shorthand': ['error', 'always'], | ||
'promise/prefer-await-to-then': 'error', | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"name": "@fireworkweb/eslint-config", | ||
"version": "1.0.0", | ||
"description": "Custom eslint config for Firework projects", | ||
"homepage": "https://github.com/fireworkweb/eslint-config#readme", | ||
"bugs": "https://github.com/fireworkweb/eslint-config/issues", | ||
"author": "Firework Web <[email protected]>", | ||
"license": "MIT", | ||
"main": "js.js", | ||
"keywords": [ | ||
"eslint", | ||
"eslint-plugin", | ||
"eslint-config", | ||
"javascript", | ||
"vue", | ||
"vuejs", | ||
"rules" | ||
], | ||
"peerDependencies": { | ||
"eslint": "^5.0.0 || ^6.0.0" | ||
}, | ||
"dependencies": { | ||
"babel-eslint": "^10.1.0", | ||
"eslint": "^6.8.0", | ||
"eslint-plugin-promise": "^4.2.1", | ||
"eslint-plugin-react": "^7.19.0", | ||
"eslint-plugin-vue": "^6.2.2", | ||
"vue-eslint-parser": "^7.0.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
module.exports = { | ||
extends: [ | ||
'./js', | ||
'plugin:react/recommended', | ||
], | ||
env: { | ||
amd: true, | ||
browser: true, | ||
node: true, | ||
}, | ||
rules: { | ||
'jsx-quotes': ['error', 'prefer-single'], | ||
'object-curly-spacing': 'off', | ||
'react/prop-types': 0, | ||
'react/jsx-max-props-per-line': ['error', {'maximum': 1, 'when': 'always' }], | ||
'react/jsx-first-prop-new-line': ['error', 'multiline-multiprop'], | ||
'react/jsx-closing-bracket-location': ['error', 'tag-aligned'], | ||
'react/jsx-closing-tag-location': 'error', | ||
'react/jsx-curly-spacing': ['error', 'never', { allowMultiline: true }], | ||
'react/sort-comp': ['error', { | ||
order: [ | ||
'static-variables', | ||
'static-methods', | ||
'instance-variables', | ||
'lifecycle', | ||
'/^on.+$/', | ||
'getters', | ||
'setters', | ||
'/^(get|set)(?!(InitialState$|DefaultProps$|ChildContext$)).+$/', | ||
'instance-methods', | ||
'everything-else', | ||
'rendering', | ||
], | ||
groups: { | ||
lifecycle: [ | ||
'displayName', | ||
'propTypes', | ||
'contextTypes', | ||
'childContextTypes', | ||
'mixins', | ||
'statics', | ||
'defaultProps', | ||
'constructor', | ||
'getDefaultProps', | ||
'getInitialState', | ||
'state', | ||
'getChildContext', | ||
'getDerivedStateFromProps', | ||
'componentWillMount', | ||
'UNSAFE_componentWillMount', | ||
'componentDidMount', | ||
'componentWillReceiveProps', | ||
'UNSAFE_componentWillReceiveProps', | ||
'shouldComponentUpdate', | ||
'componentWillUpdate', | ||
'UNSAFE_componentWillUpdate', | ||
'getSnapshotBeforeUpdate', | ||
'componentDidUpdate', | ||
'componentDidCatch', | ||
'componentWillUnmount', | ||
], | ||
rendering: [ | ||
'/^render.+$/', | ||
'render', | ||
], | ||
}, | ||
}], | ||
'react/jsx-no-duplicate-props': ['error', { ignoreCase: true }], | ||
'react/jsx-pascal-case': ['error', { | ||
allowAllCaps: true, | ||
ignore: [], | ||
}], | ||
'react/no-danger': 'warn', | ||
'react/prefer-es6-class': ['error', 'always'], | ||
'react/prefer-stateless-function': ['error', { ignorePureComponents: true }], | ||
'react/react-in-jsx-scope': 'error', | ||
'react/require-render-return': 'error', | ||
'react/self-closing-comp': 'error', | ||
'react/jsx-wrap-multilines': ['error', { | ||
declaration: 'parens-new-line', | ||
assignment: 'parens-new-line', | ||
return: 'parens-new-line', | ||
arrow: 'parens-new-line', | ||
condition: 'parens-new-line', | ||
logical: 'parens-new-line', | ||
prop: 'parens-new-line', | ||
}], | ||
'react/no-danger-with-children': 'error', | ||
'react/no-unused-prop-types': ['error', { | ||
customValidators: [ | ||
], | ||
skipShapeProps: true, | ||
}], | ||
'react/destructuring-assignment': ['error', 'always'], | ||
'react/no-redundant-should-component-update': 'error', | ||
'react/no-unused-state': 'error', | ||
'react/no-typos': 'error', | ||
'react/jsx-tag-spacing': ['error', { | ||
closingSlash: 'never', | ||
beforeSelfClosing: 'always', | ||
afterOpening: 'never', | ||
beforeClosing: 'never', | ||
}], | ||
'react/boolean-prop-naming': ['off', { | ||
propTypeNames: ['bool', 'mutuallyExclusiveTrueProps'], | ||
rule: '^(is|has)[A-Z]([A-Za-z0-9]?)+', | ||
message: '', | ||
}], | ||
'react/jsx-curly-brace-presence': ['error', { props: 'never', children: 'never' }], | ||
'react/no-access-state-in-setstate': 'error', | ||
'react/jsx-props-no-multi-spaces': 'error', | ||
'react/jsx-curly-newline': ['error', { | ||
multiline: 'consistent', | ||
singleline: 'consistent', | ||
}], | ||
'react/jsx-props-no-spreading': ['warn', { | ||
html: 'enforce', | ||
custom: 'enforce', | ||
exceptions: [], | ||
}], | ||
}, | ||
}; |
Oops, something went wrong.