Bluesky app fork with some witchin' additions 馃挮
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at main 272 lines 8.5 kB view raw
1// @ts-check 2import js from '@eslint/js' 3import tseslint from 'typescript-eslint' 4import { defineConfig } from 'eslint/config'; 5import react from 'eslint-plugin-react' 6import reactHooks from 'eslint-plugin-react-hooks' 7// @ts-expect-error no types 8import reactNative from 'eslint-plugin-react-native' 9// @ts-expect-error no types 10import reactNativeA11y from 'eslint-plugin-react-native-a11y' 11import simpleImportSort from 'eslint-plugin-simple-import-sort' 12import importX from 'eslint-plugin-import-x' 13import lingui from 'eslint-plugin-lingui' 14import reactCompiler from 'eslint-plugin-react-compiler' 15import bskyInternal from 'eslint-plugin-bsky-internal' 16import globals from 'globals' 17import tsParser from '@typescript-eslint/parser' 18 19export default defineConfig( 20 /** 21 * Global ignores 22 */ 23 { 24 ignores: [ 25 '**/__mocks__/*.ts', 26 'ios/**', 27 'android/**', 28 'coverage/**', 29 '*.lock', 30 '.husky/**', 31 'patches/**', 32 '*.html', 33 'bskyweb/**', 34 'bskyembed/**', 35 'src/locale/locales/_build/**', 36 'src/locale/locales/**/*.js', 37 '*.e2e.ts', 38 '*.e2e.tsx', 39 'eslint.config.mjs', 40 '.jscodeshift/**', 41 ], 42 }, 43 44 /** 45 * Base configurations 46 */ 47 js.configs.recommended, 48 tseslint.configs.recommendedTypeChecked, 49 reactHooks.configs.flat.recommended, 50 // @ts-expect-error https://github.com/un-ts/eslint-plugin-import-x/issues/439 51 importX.flatConfigs.recommended, 52 importX.flatConfigs.typescript, 53 importX.flatConfigs['react-native'], 54 55 /** 56 * Main configuration for all JS/TS/JSX/TSX files 57 */ 58 { 59 files: ['**/*.{js,jsx,ts,tsx}'], 60 plugins: { 61 react, 62 'react-native': reactNative, 63 'react-native-a11y': reactNativeA11y, 64 'simple-import-sort': simpleImportSort, 65 lingui, 66 'react-compiler': reactCompiler, 67 'bsky-internal': bskyInternal, 68 }, 69 languageOptions: { 70 ecmaVersion: 'latest', 71 sourceType: 'module', 72 globals: { 73 ...globals.browser, 74 ...globals.node, 75 }, 76 parserOptions: { 77 parser: tsParser, 78 projectService: true, 79 tsconfigRootDir: import.meta.dirname, 80 ecmaFeatures: { 81 jsx: true, 82 }, 83 }, 84 }, 85 settings: { 86 react: { 87 version: 'detect', 88 }, 89 componentWrapperFunctions: ['observer'], 90 }, 91 rules: { 92 /** 93 * Custom rules 94 */ 95 'bsky-internal/avoid-unwrapped-text': [ 96 'error', 97 { 98 impliedTextComponents: [ 99 'H1', 100 'H2', 101 'H3', 102 'H4', 103 'H5', 104 'H6', 105 'P', 106 'Admonition', 107 'Admonition.Admonition', 108 'Toast.Action', 109 'AgeAssuranceAdmonition', 110 'Span', 111 'StackedButton', 112 ], 113 impliedTextProps: [], 114 suggestedTextWrappers: { 115 Button: 'ButtonText', 116 'ToggleButton.Button': 'ToggleButton.ButtonText', 117 'SegmentedControl.Item': 'SegmentedControl.ItemText', 118 }, 119 }, 120 ], 121 'bsky-internal/use-exact-imports': 'error', 122 'bsky-internal/use-prefixed-imports': 'error', 123 'bsky-internal/lingui-msg-rule': 'error', 124 125 /** 126 * React & React Native 127 */ 128 ...react.configs.recommended.rules, 129 ...react.configs['jsx-runtime'].rules, 130 'react/no-unescaped-entities': 'off', 131 'react/prop-types': 'off', 132 'react-native/no-inline-styles': 'off', 133 ...reactNativeA11y.configs.all.rules, 134 'react-compiler/react-compiler': 'warn', 135 // TODO: Fix these and set to error 136 'react-hooks/set-state-in-effect': 'warn', 137 'react-hooks/purity': 'warn', 138 'react-hooks/refs': 'warn', 139 'react-hooks/immutability': 'warn', 140 141 /** 142 * Import sorting 143 */ 144 'simple-import-sort/imports': [ 145 'error', 146 { 147 groups: [ 148 // Side effect imports. 149 ['^\\u0000'], 150 // Node.js builtins prefixed with `node:`. 151 ['^node:'], 152 // Packages. 153 // Things that start with a letter (or digit or underscore), or `@` followed by a letter. 154 // React/React Native prioritized, followed by expo 155 // Followed by all packages excluding unprefixed relative ones 156 [ 157 '^(react\\/(.*)$)|^(react$)|^(react-native(.*)$)', 158 '^(expo(.*)$)|^(expo$)', 159 '^(?!(?:alf|components|lib|locale|logger|platform|screens|state|view)(?:$|\\/))@?\\w', 160 ], 161 // Relative imports. 162 // Ideally, anything that starts with a dot or # 163 // due to unprefixed relative imports being used, we whitelist the relative paths we use 164 // (?:$|\\/) matches end of string or / 165 [ 166 '^(?:#\\/)?(?:lib|state|logger|platform|locale)(?:$|\\/)', 167 '^(?:#\\/)?view(?:$|\\/)', 168 '^(?:#\\/)?screens(?:$|\\/)', 169 '^(?:#\\/)?alf(?:$|\\/)', 170 '^(?:#\\/)?components(?:$|\\/)', 171 '^#\\/', 172 '^\\.', 173 ], 174 // anything else - hopefully we don't have any of these 175 ['^'], 176 ], 177 }, 178 ], 179 'simple-import-sort/exports': 'error', 180 181 /** 182 * Import linting 183 */ 184 'import-x/consistent-type-specifier-style': ['warn', 'prefer-inline'], 185 'import-x/no-unresolved': ['error', { 186 /* 187 * The `postinstall` hook runs `compile-if-needed` locally, but not in 188 * CI. For CI-sake, ignore this. 189 */ 190 ignore: ['^#\/locale\/locales\/.+\/messages'], 191 }], 192 193 /** 194 * TypeScript-specific rules 195 */ 196 'no-unused-vars': 'off', // off, we use TS-specific rule below 197 '@typescript-eslint/no-unused-vars': [ 198 'error', 199 { 200 argsIgnorePattern: '^_', 201 varsIgnorePattern: '^_.+', 202 caughtErrors: 'none', 203 ignoreRestSiblings: true, 204 }, 205 ], 206 '@typescript-eslint/consistent-type-imports': [ 207 'warn', 208 {prefer: 'type-imports', fixStyle: 'inline-type-imports'}, 209 ], 210 '@typescript-eslint/no-require-imports': 'off', 211 '@typescript-eslint/no-unused-expressions': ['error', { 212 allowTernary: true, 213 }], 214 /** 215 * Maintain previous behavior - these are stricter in typescript-eslint 216 * v8 `warn` ones are probably worth fixing. `off` ones are a bit too 217 * nit-picky 218 */ 219 '@typescript-eslint/no-explicit-any': 'off', 220 '@typescript-eslint/ban-ts-comment': 'off', 221 '@typescript-eslint/no-empty-object-type': 'off', 222 '@typescript-eslint/no-unsafe-function-type': 'off', 223 '@typescript-eslint/no-unsafe-assignment': 'off', 224 '@typescript-eslint/unbound-method': 'off', 225 '@typescript-eslint/no-unsafe-argument': 'off', 226 '@typescript-eslint/no-unsafe-return': 'off', 227 '@typescript-eslint/no-unsafe-member-access': 'warn', 228 '@typescript-eslint/no-unsafe-call': 'warn', 229 '@typescript-eslint/no-floating-promises': 'warn', 230 '@typescript-eslint/no-misused-promises': 'warn', 231 '@typescript-eslint/require-await': 'warn', 232 '@typescript-eslint/no-unsafe-enum-comparison': 'warn', 233 '@typescript-eslint/no-unnecessary-type-assertion': 'warn', 234 '@typescript-eslint/no-redundant-type-constituents': 'warn', 235 '@typescript-eslint/no-duplicate-type-constituents': 'warn', 236 '@typescript-eslint/no-base-to-string': 'warn', 237 '@typescript-eslint/prefer-promise-reject-errors': 'warn', 238 '@typescript-eslint/await-thenable': 'warn', 239 240 /** 241 * Turn off rules that we haven't enforced thus far 242 */ 243 'no-empty-pattern': 'off', 244 'no-async-promise-executor': 'off', 245 'no-constant-binary-expression': 'warn', 246 'prefer-const': 'off', 247 'no-empty': 'off', 248 'no-unsafe-optional-chaining': 'off', 249 'no-prototype-builtins': 'off', 250 'no-var': 'off', 251 'prefer-rest-params': 'off', 252 'no-case-declarations': 'off', 253 'no-irregular-whitespace': 'off', 254 'no-useless-escape': 'off', 255 'no-sparse-arrays': 'off', 256 'no-fallthrough': 'off', 257 'no-control-regex': 'off', 258 }, 259 }, 260 261 /** 262 * Test files configuration 263 */ 264 { 265 files: ['**/__tests__/**/*.{js,jsx,ts,tsx}', '**/*.test.{js,jsx,ts,tsx}'], 266 languageOptions: { 267 globals: { 268 ...globals.jest, 269 } 270 }, 271 }, 272)