Skip to content

Commit

Permalink
Merge 889be20 into 519e3ab
Browse files Browse the repository at this point in the history
  • Loading branch information
AVykhrystyuk committed May 17, 2019
2 parents 519e3ab + 889be20 commit cfaab0c
Show file tree
Hide file tree
Showing 6 changed files with 120 additions and 130 deletions.
97 changes: 97 additions & 0 deletions packages/code-style/.flowtype.eslintrc.js
@@ -0,0 +1,97 @@
module.exports = {
extends: [
'airbnb-base',
'plugin:flowtype/recommended'
],

plugins: [
'flowtype'
],

rules: {
/* es6 related */
// require parens in arrow function arguments
// https://eslint.org/docs/rules/arrow-parens
'arrow-parens': ['error', 'as-needed', {
requireForBlockBody: false,
}],

/* styles related */
// prettier takes care of it
// https://eslint.org/docs/rules/object-curly-newline
'object-curly-newline': ['off', {
ObjectExpression: { minProperties: 4, multiline: true, consistent: true },
ObjectPattern: { minProperties: 4, multiline: true, consistent: true },
ImportDeclaration: { minProperties: 4, multiline: true, consistent: true },
ExportDeclaration: { minProperties: 4, multiline: true, consistent: true },
}],

// disallow dangling underscores in identifiers
// https://eslint.org/docs/rules/no-underscore-dangle
'no-underscore-dangle': ['error', {
allow: [],
allowAfterThis: true,
allowAfterSuper: false,
enforceInMethodNames: false,
}],

// specify the maximum length of a line in your program
// https://eslint.org/docs/rules/max-len
'max-len': ['error', {
code: 120,
tabWidth: 4,
ignoreUrls: true,
ignoreComments: false,
ignoreRegExpLiterals: true,
ignoreStrings: true,
ignoreTemplateLiterals: true,
}],

// require trailing commas in multiline object literals
// https://eslint.org/docs/rules/comma-dangle
'comma-dangle': ['error', {
arrays: 'only-multiline',
objects: 'only-multiline',
imports: 'only-multiline',
exports: 'never',
functions: 'never',
}],

// disallow certain syntax forms
// https://eslint.org/docs/rules/no-restricted-syntax
'no-restricted-syntax': [
'error',
{
selector: 'ForInStatement',
message: 'for..in loops iterate over the entire prototype chain, which is virtually never what you want. Use Object.{keys,values,entries}, and iterate over the resulting array.',
},
/*
{
selector: 'ForOfStatement',
message: 'iterators/generators require regenerator-runtime, which is too heavyweight for this guide to allow them. Separately, loops should be avoided in favor of array iterations.',
},
*/
{
selector: 'LabeledStatement',
message: 'Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand.',
},
{
selector: 'WithStatement',
message: '`with` is disallowed in strict mode because it makes code impossible to predict and optimize.',
},
],

// enforces new line after each method call in the chain to make it
// more readable and easy to maintain
// https://eslint.org/docs/rules/newline-per-chained-call
'newline-per-chained-call': ['error', { ignoreChainWithDepth: 2 }],

// require or disallow an empty line between class members
// https://eslint.org/docs/rules/lines-between-class-members
'lines-between-class-members': ['error', 'always', { exceptAfterSingleLine: true }],

// disallow use of unary operators, ++ and --
// https://eslint.org/docs/rules/no-plusplus
'no-plusplus': ["error", { "allowForLoopAfterthoughts": true }],
},
};
19 changes: 19 additions & 0 deletions packages/code-style/package.json
@@ -0,0 +1,19 @@
{
"name": "@magpie/code-style",
"version": "1.0.0",
"repository": "https://github.com/AVykhrystyuk/magpie/tree/master/packages/code-style",
"author": "Alexey Vykhrystyuk <AVykhrystyuk@gmail.com>",
"license": "ISC",
"devDependencies": {
"eslint-config-airbnb-base": "^13.1.0",
"eslint-plugin-flowtype": "^3.8.2",
"eslint-plugin-import": "^2.17.2"
},
"peerDependencies": {
"eslint": "^4.19.1 || ^5.3.0",
"eslint-plugin-import": "^2.14.0"
},
"engines": {
"node": ">= 4"
}
}
69 changes: 1 addition & 68 deletions packages/shared/.eslintrc.js
Expand Up @@ -5,22 +5,10 @@ module.exports = {
},

extends: [
'airbnb-base',
'plugin:flowtype/recommended'
],

plugins: [
'flowtype'
require.resolve('@magpie/code-style/.flowtype.eslintrc.js')
],

rules: {
/* es6 related */
// require parens in arrow function arguments
// https://eslint.org/docs/rules/arrow-parens
'arrow-parens': ['error', 'as-needed', {
requireForBlockBody: false,
}],

/* styles related */
// disallow dangling underscores in identifiers
// https://eslint.org/docs/rules/no-underscore-dangle
Expand All @@ -30,60 +18,5 @@ module.exports = {
allowAfterSuper: false,
enforceInMethodNames: false,
}],

// specify the maximum length of a line in your program
// https://eslint.org/docs/rules/max-len
'max-len': ['error', {
code: 120,
tabWidth: 4,
ignoreUrls: true,
ignoreComments: false,
ignoreRegExpLiterals: true,
ignoreStrings: true,
ignoreTemplateLiterals: true,
}],

// require trailing commas in multiline object literals
// https://eslint.org/docs/rules/comma-dangle
'comma-dangle': ['error', {
arrays: 'only-multiline',
objects: 'only-multiline',
imports: 'only-multiline',
exports: 'never',
functions: 'never',
}],

// disallow certain syntax forms
// https://eslint.org/docs/rules/no-restricted-syntax
'no-restricted-syntax': [
'error',
{
selector: 'ForInStatement',
message: 'for..in loops iterate over the entire prototype chain, which is virtually never what you want. Use Object.{keys,values,entries}, and iterate over the resulting array.',
},
/*
{
selector: 'ForOfStatement',
message: 'iterators/generators require regenerator-runtime, which is too heavyweight for this guide to allow them. Separately, loops should be avoided in favor of array iterations.',
},
*/
{
selector: 'LabeledStatement',
message: 'Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand.',
},
{
selector: 'WithStatement',
message: '`with` is disallowed in strict mode because it makes code impossible to predict and optimize.',
},
],

// enforces new line after each method call in the chain to make it
// more readable and easy to maintain
// https://eslint.org/docs/rules/newline-per-chained-call
'newline-per-chained-call': ['error', { ignoreChainWithDepth: 2 }],

// require or disallow an empty line between class members
// https://eslint.org/docs/rules/lines-between-class-members
'lines-between-class-members': ['error', 'always', { exceptAfterSingleLine: true }],
},
};
1 change: 1 addition & 0 deletions packages/shared/package.json
Expand Up @@ -27,6 +27,7 @@
"author": "Alexey Vykhrystyuk <AVykhrystyuk@gmail.com>",
"license": "ISC",
"devDependencies": {
"@magpie/code-style": "^1.0.0",
"@babel/core": "^7.4.4",
"@babel/plugin-proposal-class-properties": "^7.4.4",
"@babel/plugin-proposal-object-rest-spread": "^7.4.4",
Expand Down
63 changes: 1 addition & 62 deletions packages/timepad/.eslintrc.js
Expand Up @@ -4,67 +4,6 @@ module.exports = {
},

extends: [
'airbnb-base',
'plugin:flowtype/recommended'
require.resolve('@magpie/code-style/.flowtype.eslintrc.js')
],

plugins: [
'flowtype'
],

rules: {
/* es6 related */
// https://eslint.org/docs/rules/arrow-parens
'arrow-parens': ['error', 'as-needed', {
requireForBlockBody: false,
}],

/* styles related */
// prettier takes care of it
// https://eslint.org/docs/rules/object-curly-newline
'object-curly-newline': ['off', {
ObjectExpression: { minProperties: 4, multiline: true, consistent: true },
ObjectPattern: { minProperties: 4, multiline: true, consistent: true },
ImportDeclaration: { minProperties: 4, multiline: true, consistent: true },
ExportDeclaration: { minProperties: 4, multiline: true, consistent: true },
}],

// https://eslint.org/docs/rules/no-underscore-dangle
'no-underscore-dangle': ['error', {
allow: [],
allowAfterThis: true,
allowAfterSuper: false,
enforceInMethodNames: false,
}],

// https://eslint.org/docs/rules/max-len
'max-len': ['error', {
code: 120,
tabWidth: 4,
ignoreUrls: true,
ignoreComments: false,
ignoreRegExpLiterals: true,
ignoreStrings: true,
ignoreTemplateLiterals: true,
}],

// https://eslint.org/docs/rules/comma-dangle
'comma-dangle': ['error', {
arrays: 'only-multiline',
objects: 'only-multiline',
imports: 'only-multiline',
exports: 'never',
functions: 'never',
}],

// https://eslint.org/docs/rules/newline-per-chained-call
'newline-per-chained-call': ['error', { ignoreChainWithDepth: 2 }],

// https://eslint.org/docs/rules/lines-between-class-members
'lines-between-class-members': ['error', 'always', { exceptAfterSingleLine: true }],

// disallow use of unary operators, ++ and --
// https://eslint.org/docs/rules/no-plusplus
'no-plusplus': ["error", { "allowForLoopAfterthoughts": true }],
}
};
1 change: 1 addition & 0 deletions packages/timepad/package.json
Expand Up @@ -35,6 +35,7 @@
"xlsx": "^0.12.9"
},
"devDependencies": {
"@magpie/code-style": "^1.0.0",
"@babel/core": "^7.4.4",
"@babel/plugin-proposal-class-properties": "^7.4.4",
"@babel/plugin-proposal-decorators": "^7.4.4",
Expand Down

0 comments on commit cfaab0c

Please sign in to comment.