Skip to content

Commit

Permalink
Refactor js rules in order to make them reusable
Browse files Browse the repository at this point in the history
  • Loading branch information
rix1 committed Aug 29, 2018
1 parent 1edc708 commit 3289b59
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 113 deletions.
23 changes: 4 additions & 19 deletions javascript/index.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,7 @@
const jsRules = require('./rules');

module.exports = {
extends: ['airbnb', 'plugin:import/errors', 'plugin:import/warnings'],
extends: ['airbnb-base', 'plugin:import/errors', 'plugin:import/warnings'],
parser: 'babel-eslint',
rules: {
'no-underscore-dangle': ['off'],
'no-plusplus': ['error', { allowForLoopAfterthoughts: true }],
'import/prefer-default-export': ['off'],
'import/order': [
'error',
{
groups: [
'builtin',
'external',
'internal',
'parent',
'sibling',
'index'
]
}
]
}
rules: jsRules
};
17 changes: 17 additions & 0 deletions javascript/rules.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* Plain JS-projects uses airbnb-base and React-projects uses airbnb.
*
* To avoid duplicating these rules they are imported from here.
*/

module.exports = {
'no-underscore-dangle': ['off'],
'no-plusplus': ['error', { allowForLoopAfterthoughts: true }],
'import/prefer-default-export': ['off'],
'import/order': [
'error',
{
groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index']
}
]
};
8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
"version": "1.0.0",
"description": "A set of eslint-configs for Otovo projects",
"main": "index.js",
"engines": {
"node": "^9.10"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
Expand All @@ -17,13 +20,16 @@
},
"homepage": "https://github.com/otovo/otovo-js#readme",
"peerDependencies": {
"babel-eslint": "^9.0.0",
"eslint": "^4.19",
"eslint-config-airbnb": "^16.1",
"eslint-config-airbnb-base": "^13.1.0",
"eslint-config-prettier": "^2.9",
"eslint-plugin-flowtype": "^2.46",
"eslint-plugin-import": "^2.10",
"eslint-plugin-jsx-a11y": "^6.0",
"eslint-plugin-prettier": "^2.2",
"eslint-plugin-react": "^7.7"
"eslint-plugin-react": "^7.7",
"prettier": "^1.14.2"
}
}
5 changes: 5 additions & 0 deletions react-recommended/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
extends: ['../javascript', '../react', '../flowtype', '../prettier'].map(
require.resolve
)
};
12 changes: 9 additions & 3 deletions react/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
const jsRules = require('../javascript/rules');

module.exports = {
extends: ['plugin:react/recommended', 'plugin:jsx-a11y/recommended'],
extends: [
'airbnb',
'plugin:react/recommended',
'plugin:jsx-a11y/recommended'
],
parser: 'babel-eslint',
// "plugins": [
// "react", added both with Airbnb config and plugin:react/recommended
// ],
rules: {
rules: Object.assign({}, jsRules, {
// Because Flow can infer default props based on which props are listed in `defaultProps` we disable forbudDefaultForRequired
'react/require-default-props': [
2,
Expand Down Expand Up @@ -39,5 +45,5 @@ module.exports = {
}
],
'react/no-did-mount-set-state': ['off']
}
})
};
90 changes: 0 additions & 90 deletions v2/index.js

This file was deleted.

4 changes: 4 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1


0 comments on commit 3289b59

Please sign in to comment.