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

Configure Feed

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

at 7da65efc08780b82bb426bcef751e1feaeefb556 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 'src/platform/polyfills.ts', 27 'src/third-party/**', 28 'ios/**', 29 'android/**', 30 'coverage/**', 31 '*.lock', 32 '.husky/**', 33 'patches/**', 34 '*.html', 35 'bskyweb/**', 36 'bskyembed/**', 37 'src/locale/locales/_build/**', 38 'src/locale/locales/**/*.js', 39 '*.e2e.ts', 40 '*.e2e.tsx', 41 'eslint.config.mjs', 42 ], 43 }, 44 45 /** 46 * Base configurations 47 */ 48 js.configs.recommended, 49 tseslint.configs.recommendedTypeChecked, 50 reactHooks.configs.flat.recommended, 51 // @ts-expect-error https://github.com/un-ts/eslint-plugin-import-x/issues/439 52 importX.flatConfigs.recommended, 53 importX.flatConfigs.typescript, 54 importX.flatConfigs['react-native'], 55 56 /** 57 * Main configuration for all JS/TS/JSX/TSX files 58 */ 59 { 60 files: ['**/*.{js,jsx,ts,tsx}'], 61 plugins: { 62 react, 63 'react-native': reactNative, 64 'react-native-a11y': reactNativeA11y, 65 'simple-import-sort': simpleImportSort, 66 lingui, 67 'react-compiler': reactCompiler, 68 'bsky-internal': bskyInternal, 69 }, 70 languageOptions: { 71 ecmaVersion: 'latest', 72 sourceType: 'module', 73 globals: { 74 ...globals.browser, 75 ...globals.node, 76 }, 77 parserOptions: { 78 parser: tsParser, 79 projectService: true, 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-typed-gates': 'error', 123 'bsky-internal/use-prefixed-imports': '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)