about summary refs log tree commit diff
path: root/.eslintrc.js
diff options
context:
space:
mode:
Diffstat (limited to '.eslintrc.js')
-rw-r--r--.eslintrc.js48
1 files changed, 47 insertions, 1 deletions
diff --git a/.eslintrc.js b/.eslintrc.js
index 18802cdf1..6165517f7 100644
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -7,10 +7,52 @@ module.exports = {
     'prettier',
   ],
   parser: '@typescript-eslint/parser',
-  plugins: ['@typescript-eslint', 'detox', 'react', 'lingui'],
+  plugins: [
+    '@typescript-eslint',
+    'detox',
+    'react',
+    'lingui',
+    'simple-import-sort',
+  ],
   rules: {
     'react/no-unescaped-entities': 0,
     'react-native/no-inline-styles': 0,
+    'simple-import-sort/imports': [
+      'warn',
+      {
+        groups: [
+          // Side effect imports.
+          ['^\\u0000'],
+          // Node.js builtins prefixed with `node:`.
+          ['^node:'],
+          // Packages.
+          // Things that start with a letter (or digit or underscore), or `@` followed by a letter.
+          // React/React Native priortized, followed by expo
+          // Followed by all packages excluding unprefixed relative ones
+          [
+            '^(react\\/(.*)$)|^(react$)|^(react-native(.*)$)',
+            '^(expo(.*)$)|^(expo$)',
+            '^(?!(?:alf|components|lib|locale|logger|platform|screens|state|view)(?:$|\\/))@?\\w',
+          ],
+          // Relative imports.
+          // Ideally, anything that starts with a dot or #
+          // due to unprefixed relative imports being used, we whitelist the relative paths we use
+          // (?:$|\\/) matches end of string or /
+          [
+            '^(?:#\\/)?(?:lib|state|logger|platform|locale)(?:$|\\/)',
+            '^(?:#\\/)?view(?:$|\\/)',
+            '^(?:#\\/)?screens(?:$|\\/)',
+            '^(?:#\\/)?alf(?:$|\\/)',
+            '^(?:#\\/)?components(?:$|\\/)',
+            '^#\\/',
+            '^\\.',
+          ],
+          // anything else - hopefully we don't have any of these
+          ['^'],
+        ],
+      },
+    ],
+    'simple-import-sort/exports': 'warn',
   },
   ignorePatterns: [
     '**/__mocks__/*.ts',
@@ -31,4 +73,8 @@ module.exports = {
   settings: {
     componentWrapperFunctions: ['observer'],
   },
+  parserOptions: {
+    sourceType: 'module',
+    ecmaVersion: 'latest',
+  },
 }