Skip to content

Commit

Permalink
Merge pull request #6 from hammerframework/pp-add-eslint-config
Browse files Browse the repository at this point in the history
Add ESLint shared configuration
  • Loading branch information
peterp authored Sep 14, 2019
2 parents 71c08da + dd56a82 commit 9ece3cb
Show file tree
Hide file tree
Showing 3 changed files with 115 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"packages": ["packages/*"],
"version": "0.0.0-alpha.5",
"version": "0.0.1-alpha.8.1",
"npmClient": "yarn",
"useWorkspaces": true,
"command": {
Expand Down
96 changes: 96 additions & 0 deletions packages/eslint-config-hammer/index.js
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',
},
}
18 changes: 18 additions & 0 deletions packages/eslint-config-hammer/package.json
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"
}
}

0 comments on commit 9ece3cb

Please sign in to comment.