From b9246819d0251c1e352b8f0576befedd4cac2ab5 Mon Sep 17 00:00:00 2001 From: saseungmin Date: Tue, 11 Jul 2023 22:40:38 +0900 Subject: [PATCH] =?UTF-8?q?feat(@nft-team/eslint-config):=20eslint=20confi?= =?UTF-8?q?g=20import=20=EC=A0=95=EB=A0=AC=20=EC=97=85=EB=8D=B0=EC=9D=B4?= =?UTF-8?q?=ED=8A=B8=20=EB=B0=8F=20=EB=AC=B8=EC=84=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/eslint/README.md | 28 +++++++++++++++++++++++++++- packages/eslint/index.js | 19 ++++++++++++++----- 2 files changed, 41 insertions(+), 6 deletions(-) diff --git a/packages/eslint/README.md b/packages/eslint/README.md index 8c558eeb..9829765e 100644 --- a/packages/eslint/README.md +++ b/packages/eslint/README.md @@ -1,4 +1,4 @@ -# 🚧 WIP 🚧 @nft-team/eslint-config +# @nft-team/eslint-config @@ -38,6 +38,32 @@ module.exports = { [View more extensions..](https://github.com/mbti-nf-team/frontend-libraries/blob/main/packages/eslint/index.js) +### 👉 Sort default imports +This is the default value for the `groups` option: + +```js +[ + // Side effect imports. + ['^\\u0000'], + // Node.js builtins. You could also generate this regex if you use a `.js` config. + // For example: `^(${require("module").builtinModules.join("|")})(/|$)` + // OR Node.js builtins prefixed with `node:`. + ['^(assert|buffer|child_process|cluster|console|constants|crypto|dgram|dns|domain|events|fs|http|https|module|net|os|path|punycode|querystring|readline|repl|stream|string_decoder|sys|timers|tls|tty|url|util|vm|zlib|freelist|v8|process|async_hooks|http2|perf_hooks)(/.*|$)', '^node:'], + // Packages. `react` related packages + ['^react'], + // Packages. Things that start with a letter (or digit or underscore), or `@` followed by a letter. + ['^@?\\w'], + // Parent imports. Put `..` last. + ['^\\.\\.(?!/?$)', '^\\.\\./?$'], + // Other relative imports. Put same-folder imports and `.` last. + ['^\\./(?=.*/)(?!/?$)', '^\\.(?!/?$)', '^\\./?$'], + // Svg file imports. + ['^.+\\.svg$'], + // Style imports. + ['^.+\\.s?css$'], +] +``` + ## 🐛 Bug reporting [Issues](https://github.com/mbti-nf-team/frontend-libraries/issues) diff --git a/packages/eslint/index.js b/packages/eslint/index.js index 5ef0e891..01061a85 100644 --- a/packages/eslint/index.js +++ b/packages/eslint/index.js @@ -1,4 +1,8 @@ module.exports = { + env: { + es6: true, + browser: true, + }, extends: [ 'airbnb', 'eslint:recommended', @@ -6,12 +10,19 @@ module.exports = { 'plugin:react-hooks/recommended', 'plugin:jsx-a11y/recommended', 'plugin:react/jsx-runtime', - 'plugin:@next/next/recommended', ], plugins: [ 'simple-import-sort', 'unused-imports', ], + ignorePatterns: [ + 'node_modules/', + '.pnp.cjs', + '.pnp.loader.cjs', + 'public/', + '.yarn/', + 'dist/', + ], parserOptions: { ecmaFeatures: { jsx: true, @@ -41,12 +52,10 @@ module.exports = { rules: { 'simple-import-sort/imports': ['error', { groups: [ - ['^(assert|buffer|child_process|cluster|console|constants|crypto|dgram|dns|domain|events|fs|http|https|module|net|os|path|punycode|querystring|readline|repl|stream|string_decoder|sys|timers|tls|tty|url|util|vm|zlib|freelist|v8|process|async_hooks|http2|perf_hooks)(/.*|$)'], + ['^\\u0000'], + ['^(assert|buffer|child_process|cluster|console|constants|crypto|dgram|dns|domain|events|fs|http|https|module|net|os|path|punycode|querystring|readline|repl|stream|string_decoder|sys|timers|tls|tty|url|util|vm|zlib|freelist|v8|process|async_hooks|http2|perf_hooks)(/.*|$)', '^node:'], ['^react'], - ['^next'], ['^@?\\w'], - ['^(@|@company|@ui|components|utils|config|vendored-lib)(/.*|$)'], - ['^\\u0000'], ['^\\.\\.(?!/?$)', '^\\.\\./?$'], ['^\\./(?=.*/)(?!/?$)', '^\\.(?!/?$)', '^\\./?$'], ['^.+\\.svg$'],