-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from hammerframework/pp-add-eslint-config
Add ESLint shared configuration
- Loading branch information
Showing
3 changed files
with
115 additions
and
1 deletion.
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
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,96 @@ | ||
// | ||
// Hammer's ESLint configuration is a mixture between ESLint's recommended | ||
// rules [^1], React's recommended rules [^2], and a bit of our own stylistic | ||
// flair: | ||
// - no semicolons | ||
// - comma dangle when multiline | ||
// - single quotes | ||
// - always use parenthesis around arrow functions | ||
// - enforced import sorting | ||
// | ||
// [^1] https://eslint.org/docs/rules/ | ||
// [^2] https://www.npmjs.com/package/eslint-plugin-react#list-of-supported-rules | ||
|
||
module.exports = { | ||
parser: 'babel-eslint', | ||
extends: [ | ||
'eslint-config-prettier', | ||
'eslint:recommended', | ||
'plugin:react/recommended', | ||
], | ||
plugins: ['prettier', 'import', 'jsx-a11y', 'react', 'react-hooks'], | ||
settings: { | ||
react: { | ||
version: 'detect', | ||
}, | ||
'import/resolver': { | ||
'babel-module': {}, | ||
}, | ||
}, | ||
env: { | ||
browser: true, | ||
commonjs: true, | ||
es6: true, | ||
jest: true, | ||
node: true, | ||
}, | ||
globals: { | ||
gql: 'readonly', | ||
React: 'readonly', | ||
__HAMMER__: 'readyonly', | ||
}, | ||
rules: { | ||
// Rules already covered by Prettier: | ||
// We disable rules related to code formatting that are aleady covered | ||
// by prettier: | ||
// | ||
// semi: ['error', 'never'], | ||
// 'comma-dangle': ['error', 'always-multiline'], | ||
// quotes: [ | ||
// 'error', | ||
// 'single', | ||
// { avoidEscape: true, allowTemplateLiterals: true }, | ||
// ], | ||
// 'arrow-parens': ['error', 'always'], | ||
// 'object-curly-spacing': ['error', 'always'], | ||
|
||
// Code formatting rules **NOT** covered by prettier | ||
'space-before-function-paren': ['error', 'always'], | ||
'prefer-object-spread': 'warn', | ||
'prefer-spread': 'warn', | ||
'no-unused-expressions': [ | ||
'error', | ||
{ allowShortCircuit: true, allowTernary: true }, | ||
], | ||
'no-useless-escape': 'off', | ||
camelcase: ['warn', { properties: 'never' }], | ||
'no-new': 'warn', | ||
'new-cap': ['error', { newIsCap: true, capIsNew: false }], | ||
'no-unused-vars': ['error', { argsIgnorePattern: '^_' }], | ||
'import/order': [ | ||
'error', | ||
{ | ||
groups: [ | ||
'builtin', | ||
'external', | ||
'internal', | ||
'parent', | ||
'sibling', | ||
'index', | ||
], | ||
'newlines-between': 'always', | ||
}, | ||
], | ||
// React rules | ||
'react/prop-types': [ | ||
'error', | ||
{ | ||
skipUndeclared: true, | ||
ignore: ['style', 'children', 'className', 'theme'], | ||
}, | ||
], | ||
'react/display-name': 'off', | ||
'react-hooks/rules-of-hooks': 'error', | ||
'react-hooks/exhaustive-deps': 'warn', | ||
}, | ||
} |
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,18 @@ | ||
{ | ||
"name": "@hammerframework/eslint-config-hammer", | ||
"version": "0.0.1-alpha.8", | ||
"main": "index.js", | ||
"license": "MIT", | ||
"dependencies": { | ||
"babel-eslint": "^10.0.3", | ||
"eslint": "5.16.0", | ||
"eslint-config-prettier": "^6.2.0", | ||
"eslint-import-resolver-babel-module": "^5.1.0", | ||
"eslint-plugin-import": "^2.18.2", | ||
"eslint-plugin-jsx-a11y": "^6.2.3", | ||
"eslint-plugin-prettier": "^3.1.0", | ||
"eslint-plugin-react": "^7.14.3", | ||
"eslint-plugin-react-hooks": "^2.0.1", | ||
"prettier": "^1.18.2" | ||
} | ||
} |