From b8611e3b4f16636c90840bf103655712ad80b4ff Mon Sep 17 00:00:00 2001 From: Tobiah Date: Mon, 28 Mar 2022 22:37:16 -0500 Subject: [PATCH] feat(style): add prettier configs feat(esm): add separate config for esm --- .eslintrc.js | 47 +++++++++++++++++------------ esm.js | 73 ++++++++++++++++++++++++++++++++++++++++++++++ package.json | 4 ++- prettier.config.js | 12 ++++++++ 4 files changed, 116 insertions(+), 20 deletions(-) create mode 100644 esm.js create mode 100644 prettier.config.js diff --git a/.eslintrc.js b/.eslintrc.js index 3f9276f..52f36ed 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -22,10 +22,7 @@ module.exports = { }, }, ], - strict: [ - 'error', - 'safe', - ], + strict: ['error', 'safe'], 'linebreak-style': ['error', 'unix'], 'no-await-in-loop': 'off', 'func-names': 0, @@ -46,30 +43,42 @@ module.exports = { 'max-classes-per-file': 'off', 'consistent-return': 'off', 'class-methods-use-this': 'off', - 'max-len': ['error', { - code: 120, - tabWidth: 2, - comments: 120, - ignoreTemplateLiterals: true, - ignoreStrings: true, - }], + 'max-len': [ + 'error', + { + code: 120, + tabWidth: 2, + comments: 120, + ignoreTemplateLiterals: true, + ignoreStrings: true, + }, + ], 'import/no-unresolved': 0, 'no-null/no-null': 2, + quotes: [ + 2, + 'single', + { + avoidEscape: true, + allowTemplateLiterals: true, + }, + ], + 'prettier/prettier': [ + 'error', + {}, + { + usePrettierrc: true, + }, + ], }, - extends: [ - 'prettier', - 'airbnb-base', - ], + extends: ['airbnb-base', 'plugin:prettier/recommended'], plugins: ['no-null'], parser: '@babel/eslint-parser', parserOptions: { sourceType: 'script', ecmaVersion: 6, babelOptions: { - plugins: [ - '@babel/plugin-proposal-class-properties', - '@babel/plugin-proposal-private-methods', - ], + plugins: ['@babel/plugin-proposal-class-properties', '@babel/plugin-proposal-private-methods'], }, }, }; diff --git a/esm.js b/esm.js new file mode 100644 index 0000000..b8ad9d6 --- /dev/null +++ b/esm.js @@ -0,0 +1,73 @@ +'use strict'; + +module.exports = { + globals: {}, + rules: { + 'valid-jsdoc': [ + 'error', + { + requireReturn: false, + requireReturnDescription: false, + preferType: { + String: 'string', + Number: 'number', + Boolean: 'boolean', + Function: 'function', + object: 'Object', + date: 'Date', + error: 'Error', + }, + prefer: { + return: 'returns', + }, + }, + ], + strict: ['error', 'safe'], + 'linebreak-style': ['error', 'unix'], + 'no-await-in-loop': 'off', + 'func-names': 0, + 'global-require': 0, + 'no-param-reassign': 'off', + 'no-continue': 'off', + 'lines-between-class-members': 'off', + 'no-fallthrough': 'off', + 'no-case-declarations': 'off', + 'default-case': 'off', + 'max-classes-per-file': 'off', + 'consistent-return': 'off', + 'class-methods-use-this': 'off', + 'max-len': [ + 'error', + { + code: 120, + tabWidth: 2, + comments: 120, + ignoreTemplateLiterals: true, + ignoreStrings: true, + }, + ], + 'import/no-unresolved': 0, + 'no-null/no-null': 2, + 'import/extensions': 0, + 'prettier/prettier': [ + 'error', + {}, + { + usePrettierrc: true, + }, + ], + }, + extends: ['airbnb-base', 'plugin:prettier/recommended'], + plugins: ['no-null'], + parser: '@babel/eslint-parser', + parserOptions: { + sourceType: 'module', + ecmaVersion: 6, + ecmaFeatures: { + modules: true, + }, + babelOptions: { + plugins: ['@babel/plugin-proposal-class-properties', '@babel/plugin-proposal-private-methods'], + }, + }, +}; diff --git a/package.json b/package.json index 51bdd03..651ad26 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,9 @@ }, "homepage": "https://github.com/wfcd/eslint-config#readme", "exports": { - ".": "./index.js" + ".": "./index.js", + "./esm": "./esm.js", + "./prettier": "./prettier.config.js" }, "peerDependencies": { "@babel/core": "^7", diff --git a/prettier.config.js b/prettier.config.js new file mode 100644 index 0000000..904d7d8 --- /dev/null +++ b/prettier.config.js @@ -0,0 +1,12 @@ +'use strict'; + +module.exports = { + trailingComma: 'es5', + tabWidth: 2, + semi: true, + singleQuote: true, + quoteProps: 'as-needed', + bracketSpacing: true, + arrowParens: 'always', + printWidth: 120, +};