Skip to content

Commit

Permalink
feat: tweaks, add scoped eslint-config
Browse files Browse the repository at this point in the history
Signed-off-by: Charlike Mike Reagent <opensource@tunnckocore.com>
  • Loading branch information
tunnckoCore committed Jun 13, 2019
1 parent 5fd5b11 commit 27f12c0
Show file tree
Hide file tree
Showing 12 changed files with 426 additions and 44 deletions.
4 changes: 2 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
'use strict'
'use strict';

module.exports = require('@tunnckocore/config/eslint')
module.exports = require('@tunnckocore/config/eslint');
2 changes: 1 addition & 1 deletion @tunnckocore/config/eslint.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
'use strict';

module.exports = require('eslint-config-tunnckocore');
module.exports = require('@tunnckocore/eslint-config');
6 changes: 3 additions & 3 deletions @tunnckocore/config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
"name": "@tunnckocore/config",
"description": "All the configs for all the tools, in one place - plus their dependencies and peerDeps",
"author": "Charlike Mike Reagent <opensource@tunnckocore.com>",
"homepage": "https://github.com/tunnckocorehq/config",
"homepage": "https://github.com/tunnckocorehq/opensource",
"license": "Apache-2.0",
"scripts": {
"start": "NODE_ENV=configSelf scripts",
"start": "scripts",
"extends": "./scripts.js"
},
"files": [
Expand All @@ -28,9 +28,9 @@
],
"dependencies": {
"@tunnckocore/scripts-config": "0.1.0",
"@tunnckocore/eslint-config": "^3.0.0",
"docks": "^0.7.0",
"eslint": "^5.16.0",
"eslint-config-tunnckocore": "^3.0.0",
"gitcommit": "^1.0.14",
"prettier": "^1.18.2"
},
Expand Down
70 changes: 70 additions & 0 deletions @tunnckocore/eslint-config/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
{
"version": "3.0.0",
"name": "@tunnckocore/eslint-config",
"description": "Shareable ESLint config based on Jest, React, Babel, TypeScript, Unicorns, Promises, Nodes, and AirBnB & Prettier",
"author": "Charlike Mike Reagent <opensource@tunnckocore.com>",
"homepage": "https://github.com/tunnckocorehq/opensource",
"license": "Apache-2.0",
"module": "src/index.js",
"main": "src/index.js",
"scripts": {
"start": "scripts",
"extends": "@tunnckocore/scripts-config"
},
"publishConfig": {
"access": "public",
"tag": "latest"
},
"repository": {
"type": "git",
"url": "https://github.com/tunnckoCoreHQ/opensource.git",
"directory": "@tunnckocore/eslint-config"
},
"@pika/pack": {
"pipeline": [
[
"@pika/plugin-standard-pkg"
],
[
"@pika/plugin-build-node"
],
[
"@pika/plugin-build-web"
]
]
},
"keywords": [
"tunnckocorehq",
"eslint",
"airbnb",
"airbnb-config",
"airbnb-react",
"react",
"es2015",
"es2018",
"typescript",
"unicorns",
"prettier",
"prettier-config",
"eslint-config",
"example"
],
"dependencies": {
"babel-eslint": "^10.0.1",
"eslint-config-airbnb": "^17.1.0",
"eslint-config-prettier": "^4.3.0",
"eslint-plugin-import": "^2.17.3",
"eslint-plugin-jest": "^22.6.4",
"eslint-plugin-jsx-a11y": "^6.2.1",
"eslint-plugin-markdown": "^1.0.0",
"eslint-plugin-node": "^9.1.0",
"eslint-plugin-prettier": "^3.1.0",
"eslint-plugin-promise": "^4.1.1",
"eslint-plugin-react": "^7.13.0",
"eslint-plugin-react-hooks": "^1.6.0",
"eslint-plugin-unicorn": "^9.1.0"
},
"devDependencies": {
"@tunnckocore/scripts": "^1.2.5"
}
}
278 changes: 278 additions & 0 deletions @tunnckocore/eslint-config/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,278 @@
export default {
settings: {
'import/resolver': {
node: {
extensions: [
'.mjs',
'.ts',
'.d.ts',
'.tsx',
'.js',
'.jsx',
'.md',
'.mdx',
'.json',
],
},
},
},
extends: [
'airbnb',
'plugin:jest/recommended',
'prettier',
'prettier/@typescript-eslint',
'prettier/babel',
'prettier/flowtype',
'prettier/react',
'prettier/standard',
'prettier/unicorn',
'prettier/vue',
],
env: {
browser: true,
jest: true,
},
plugins: [
'markdown',
'react-hooks',
'jest',
'node',
'promise',
'unicorn',
'prettier',
],
// @TODO: move to typescript-eslint???
parser: 'babel-eslint',
rules: {
'jest/expect-expect': 'error',
'jest/lowercase-name': 'error',
'jest/prefer-to-be-null': 'error',
'jest/prefer-to-contain': 'error',
'jest/prefer-strict-equal': 'error',
'jest/prefer-to-have-length': 'error',
'jest/prefer-to-be-undefined': 'error',
'jest/require-tothrow-message': 'warn',

'react-hooks/rules-of-hooks': 'error',

'react/jsx-filename-extension': [
'error',
{
extensions: ['.mjs', '.ts', '.tsx', '.js', '.jsx', '.json'],
},
],

// It is pretty common to name it `err`,
// and there is almost no reason to be any other.
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/master/docs/rules/catch-error-name.md
'unicorn/catch-error-name': ['error', { name: 'err' }],

// Enforce explicitly comparing the length property of a value.
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/master/docs/rules/explicit-length-check.md
'unicorn/explicit-length-check': 'error',

// Pretty useful rule, but it depends.
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/master/docs/rules/filename-case.md
'unicorn/filename-case': 'off',

// Enforce specifying rules to disable in `eslint-disable` comments.
// Be explicit and don't just disable everything. If you want to disable
// everything because of more errors, reconsider your style or disable that rule temporary.
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/master/docs/rules/no-abusive-eslint-disable.md
'unicorn/no-abusive-eslint-disable': 'error',

// Disallow `process.exit`, also related to `node/process-exit-as-throw` rule.
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/master/docs/rules/no-process-exit.md
'unicorn/no-process-exit': 'error',

// Require new when throwing an error. (fixable)
// Don't throw strigs or some other weird things.
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/master/docs/rules/throw-new-error.md
'unicorn/throw-new-error': 'error',

// Enforce lowercase identifier and uppercase value for number literals. (fixable)
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/master/docs/rules/number-literal-case.md
'unicorn/number-literal-case': 'error',

// Require escape sequences to use uppercase values. (fixable)
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/master/docs/rules/escape-case.md
'unicorn/escape-case': 'error',

// Require `Array.isArray()` instead of `instanceof Array`. (fixable)
// If you need such thing in rare cases, just disable that rule for that
// specific case and be explicit.
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/master/docs/rules/no-array-instanceof.md
'unicorn/no-array-instanceof': 'error',

// Enforce the use of Buffer.from() and Buffer.alloc() instead of the deprecated ones.
// Also related to the `node/no-deprecated-api` rule.
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/master/docs/rules/no-new-buffer.md
'unicorn/no-new-buffer': 'error',

// Enforce the use of unicode escapes instead of hexadecimal escapes. (fixable)
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/master/docs/rules/no-hex-escape.md
'unicorn/no-hex-escape': 'error',

// Enforce proper Error subclassing. (fixable)
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/master/docs/rules/custom-error-definition.md
'unicorn/custom-error-definition': 'error',

// Prefer `String#startsWith` & `String#endsWith` over more complex alternatives.
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/master/docs/rules/prefer-starts-ends-with.md
'unicorn/prefer-starts-ends-with': 'error',

// Enforce throwing TypeError in type checking conditions. (fixable)
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/master/docs/rules/prefer-type-error.md
'unicorn/prefer-type-error': 'error',

// Prevents passing a function reference directly to iterator methods. (fixable)
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/master/docs/rules/no-fn-reference-in-iterator.md
'unicorn/no-fn-reference-in-iterator': 'off',

// Enforce importing index files with `.` instead of `./index`. (fixable)
// But we should be explicit. We know it is working without that,
// but at least it is good for newcomers.
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/master/docs/rules/import-index.md
'unicorn/import-index': 'off',

// Enforce the use of new for all builtins, except String, Number and Boolean. (fixable)
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/master/docs/rules/new-for-builtins.md
'unicorn/new-for-builtins': 'error',

// Enforce the use of regex shorthands to improve readability. (fixable)
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/master/docs/rules/regex-shorthand.md
'unicorn/regex-shorthand': 'error',

// Prefer the spread operator over `Array.from()`. (fixable)
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/master/docs/rules/prefer-spread.md
'unicorn/prefer-spread': 'error',

// Enforce passing a message value when throwing a built-in error.
// 'Be explicit' is our motto. Makes errors more useful.
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/master/docs/rules/error-message.md
'unicorn/error-message': 'error',

// Disallow unsafe regular expressions.
// Don't allow potential catastrophic crashes,
// slow behaving and downtimes. You still can disable that
// and do whatever you want, but that will be explicit and visible.
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/master/docs/rules/no-unsafe-regex.md
'unicorn/no-unsafe-regex': 'error',

// Prefer `addEventListener` over `on`-functions in DOM APIs. (fixable)
// https://github.com/sindresorhus/eslint-plugin-unicorn/blob/master/docs/rules/prefer-add-event-listener.md
'unicorn/prefer-add-event-listener': 'error',

'promise/catch-or-return': 'off',
'promise/no-return-wrap': 'error',
'promise/param-names': 'error',
'promise/always-return': 'off',
'promise/no-native': 'off',
'promise/no-nesting': 'off',
'promise/no-promise-in-callback': 'off',
'promise/no-callback-in-promise': 'off',
'promise/avoid-new': 'off',
'promise/no-new-statics': 'error',
'promise/no-return-in-finally': 'error',
'promise/valid-params': 'error',
'promise/prefer-await-to-then': 'off',
'promise/prefer-await-to-callbacks': 'off',

// Enforce throwing instead of `process.exit`.
// https://github.com/mysticatea/eslint-plugin-node/blob/master/docs/rules/process-exit-as-throw.md
'node/process-exit-as-throw': 'error',

// Ensure we don't import something that is ignored.
// https://github.com/mysticatea/eslint-plugin-node/blob/master/docs/rules/process-exit-as-throw.md
'node/no-unpublished-import': 'off',

// Ensure we have the defined bin file.
// https://github.com/mysticatea/eslint-plugin-node/blob/master/docs/rules/process-exit-as-throw.md
'node/no-unpublished-bin': 'error',

// Don't use deprecated APIs
// https://github.com/mysticatea/eslint-plugin-node/blob/master/docs/rules/no-deprecated-api.md
'node/no-deprecated-api': 'error',

'prettier/prettier': ['error'],

strict: 'off',

// Enforce using named functions when regular function is used,
// otherwise use arrow functions
'func-names': ['error', 'always'],

// Always use parens (for consistency).
// https://eslint.org/docs/rules/arrow-parens
'arrow-parens': ['error', 'always', { requireForBlockBody: true }],

'prefer-arrow-callback': [
'error',
{ allowNamedFunctions: true, allowUnboundThis: true },
],

// http://eslint.org/docs/rules/max-params
'max-params': ['error', { max: 5 }],

// http://eslint.org/docs/rules/max-statements
'max-statements': ['error', { max: 25 }],

// http://eslint.org/docs/rules/max-statements-per-line
'max-statements-per-line': ['error', { max: 1 }],

// http://eslint.org/docs/rules/max-nested-callbacks
'max-nested-callbacks': ['error', { max: 5 }],

// http://eslint.org/docs/rules/max-depth
'max-depth': ['error', { max: 5 }],

// enforces no braces where they can be omitted
// https://eslint.org/docs/rules/arrow-body-style
// Never enable for object literal.
'arrow-body-style': [
'error',
'as-needed',
{
requireReturnForObjectLiteral: false,
},
],

// Allow functions to be use before define because:
// 1) they are hoisted,
// 2) because ensure read flow is from top to bottom
// 3) logically order of the code.
'no-use-before-define': [
'error',
{
functions: false,
classes: true,
variables: true,
},
],

// Same as AirBnB, but adds `opts`, `options`, `x` and `err` to exclusions!
// disallow reassignment of function parameters
// disallow parameter object manipulation except for specific exclusions
// rule: https://eslint.org/docs/rules/no-param-reassign.html
'no-param-reassign': [
'error',
{
props: true,
ignorePropertyModificationsFor: [
'opts', // useful to ensure the params is always obect
'options', // and when using Object.assign for shallow copy
'x', // allow violating the rule in specific cases, instead of disabling it
'acc', // for reduce accumulators
'e', // for e.returnvalue
'err', // for adding to the Error instance
'ctx', // for Koa routing
'req', // for Express requests
'request', // for Express requests
'res', // for Express responses
'response', // for Express responses
'$scope', // for Angular 1 scopes
],
},
],
},
};
2 changes: 1 addition & 1 deletion @tunnckocore/execa/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "@tunnckocore/execa",
"description": "Thin layer on top of `execa` that allows executing multiple commands in parallel or in sequence",
"author": "Charlike Mike Reagent <opensource@tunnckocore.com>",
"homepage": "https://github.com/tunnckocorehq/execa",
"homepage": "https://github.com/tunnckocorehq/opensource",
"license": "Apache-2.0",
"module": "src/index.js",
"main": "src/index.js",
Expand Down
Loading

0 comments on commit 27f12c0

Please sign in to comment.