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