@medplum/eslint-config 4.5.1 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,15 +1,37 @@
1
- module.exports = {
2
- parser: '@typescript-eslint/parser',
3
- plugins: ['@typescript-eslint', 'header', 'react-refresh', 'no-only-tests'],
1
+ // SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import eslint from '@eslint/js';
5
+ import headerPlugin from 'eslint-plugin-header';
6
+ import importPlugin from 'eslint-plugin-import';
7
+ import jsdoc from 'eslint-plugin-jsdoc';
8
+ import noOnlyTestsPlugin from 'eslint-plugin-no-only-tests';
9
+ import reactHooks from 'eslint-plugin-react-hooks';
10
+ import reactRefresh from 'eslint-plugin-react-refresh';
11
+ import tseslint from 'typescript-eslint';
12
+
13
+ // Workaround for eslint-plugin-header ESLint 9 compatibility issue.
14
+ // See: https://github.com/Stuk/eslint-plugin-header/issues/57#issuecomment-2378485611
15
+ headerPlugin.rules.header.meta.schema = false;
16
+
17
+ /**
18
+ * Core config applies to all source files.
19
+ * TypeScript-specific rules are in the tsConfig below.
20
+ * @type {import("@eslint/config-helpers").ConfigWithExtends}
21
+ */
22
+ export const coreConfig = {
4
23
  extends: [
5
- 'eslint:recommended',
6
- 'plugin:import/recommended',
7
- 'plugin:@typescript-eslint/recommended',
8
- 'plugin:@typescript-eslint/strict',
9
- 'plugin:jsdoc/recommended-typescript-error',
10
- 'plugin:react-hooks/recommended',
24
+ eslint.configs.recommended,
25
+ importPlugin.flatConfigs.recommended,
26
+ jsdoc.configs['flat/recommended-typescript-error'],
11
27
  ],
12
- reportUnusedDisableDirectives: true,
28
+ languageOptions: {
29
+ ecmaVersion: 'latest',
30
+ sourceType: 'module',
31
+ },
32
+ plugins: {
33
+ header: headerPlugin,
34
+ },
13
35
  rules: {
14
36
  // ESLint - Possible Problems
15
37
  'array-callback-return': 'error',
@@ -66,6 +88,64 @@ module.exports = {
66
88
  'prefer-spread': 'error',
67
89
  radix: 'error',
68
90
 
91
+ 'no-unused-vars': [
92
+ 'error',
93
+ {
94
+ argsIgnorePattern: '^_',
95
+ caughtErrorsIgnorePattern: '^_',
96
+ },
97
+ ],
98
+
99
+ // JSDoc
100
+ 'jsdoc/check-tag-names': [
101
+ 'error',
102
+ {
103
+ definedTags: ['category', 'experimental', 'ts-ignore'],
104
+ },
105
+ ],
106
+ 'jsdoc/require-hyphen-before-param-description': ['error', 'always'],
107
+ 'jsdoc/require-jsdoc': 'off',
108
+ 'jsdoc/tag-lines': 'off',
109
+ 'jsdoc/require-yields-type': 'off',
110
+ 'jsdoc/require-throws-type': 'off',
111
+
112
+ // Header
113
+ 'header/header': [
114
+ 'error',
115
+ 'line',
116
+ [
117
+ ' SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors',
118
+ ' SPDX-License-Identifier: Apache-2.0',
119
+ ],
120
+ ],
121
+ },
122
+ };
123
+
124
+ /**
125
+ * TypeScript config applies to all TypeScript source files.
126
+ * These are TypeScript-specific rules that don't apply to JavaScript files.
127
+ * This improves accuracy and performance.
128
+ * @type {import("@eslint/config-helpers").ConfigWithExtends}
129
+ */
130
+ export const tsConfig = {
131
+ files: ['**/*.ts', '**/*.tsx'],
132
+ extends: [
133
+ tseslint.configs.recommended,
134
+ {
135
+ languageOptions: {
136
+ parserOptions: {
137
+ projectService: true,
138
+ },
139
+ },
140
+ },
141
+ tseslint.configs.strict,
142
+ reactHooks.configs.flat.recommended,
143
+ reactRefresh.configs.recommended,
144
+ ],
145
+ plugins: {
146
+ 'no-only-tests': noOnlyTestsPlugin,
147
+ },
148
+ rules: {
69
149
  // TypeScript+ESLint
70
150
  '@typescript-eslint/array-type': 'error',
71
151
  '@typescript-eslint/consistent-generic-constructors': 'error',
@@ -127,6 +207,13 @@ module.exports = {
127
207
  },
128
208
  ],
129
209
 
210
+ // New strict `@typescript-eslint` rules
211
+ // Need to drop all use of `any` first
212
+ '@typescript-eslint/no-unsafe-assignment': 'off',
213
+ '@typescript-eslint/no-unsafe-member-access': 'off',
214
+ '@typescript-eslint/no-unsafe-return': 'off',
215
+ '@typescript-eslint/no-unsafe-argument': 'off',
216
+
130
217
  // imports rules for isolatedModules and verbatimModuleSyntax
131
218
  'no-duplicate-imports': 'off', // Disable base rule
132
219
  'import/consistent-type-specifier-style': ['error', 'prefer-top-level'],
@@ -163,48 +250,40 @@ module.exports = {
163
250
  '@typescript-eslint/no-dynamic-delete': 'off',
164
251
  '@typescript-eslint/no-empty-object-type': 'off',
165
252
 
166
- // JSDoc
167
- 'jsdoc/check-tag-names': [
168
- 'error',
169
- {
170
- definedTags: ['category', 'experimental', 'ts-ignore'],
171
- },
172
- ],
173
- 'jsdoc/require-hyphen-before-param-description': ['error', 'always'],
174
- 'jsdoc/require-jsdoc': 'off',
175
- 'jsdoc/tag-lines': 'off',
176
- 'jsdoc/require-yields-type': 'off',
177
- 'jsdoc/require-throws-type': 'off',
178
-
179
- // Header
180
- 'header/header': [
181
- 'error',
182
- 'line',
183
- [
184
- ' SPDX-FileCopyrightText: Copyright Orangebot, Inc. and Medplum contributors',
185
- ' SPDX-License-Identifier: Apache-2.0',
186
- ],
187
- ],
188
-
189
253
  // No Only Tests
190
254
  'no-only-tests/no-only-tests': ['error', { fix: true }],
191
255
  },
192
- ignorePatterns: [
193
- 'coverage',
194
- '**/node_modules/',
195
- '**/dist/',
196
- 'packages/docs/build/',
197
- 'packages/docs/markdown-to-mdx.cjs',
198
- 'packages/docs/docusaurus.config.js',
199
- 'packages/docs/sidebars.js',
200
- 'packages/eslint-config/index.cjs',
201
- 'packages/expo-medplum-polyfills/build',
202
- 'babel.config.js',
203
- 'babel.config.cjs',
204
- 'jest.sequencer.js',
205
- 'package-lock.json',
206
- 'postcss.config.cjs',
207
- 'rollup.config.mjs',
208
- 'webpack.config.js',
209
- ],
210
256
  };
257
+
258
+ /** @type {import("@eslint/config-helpers").ConfigWithExtendsArray} */
259
+ export const medplumEslintConfig = [
260
+ {
261
+ ignores: [
262
+ '.turbo',
263
+ 'coverage',
264
+ 'dist',
265
+ 'node_modules',
266
+ 'packages/docs/build/',
267
+ 'packages/docs/markdown-to-mdx.cjs',
268
+ 'packages/docs/docusaurus.config.js',
269
+ 'packages/docs/sidebars.js',
270
+ 'packages/eslint-config/index.cjs',
271
+ 'packages/expo-medplum-polyfills/build',
272
+ 'packages/generator/output/',
273
+ 'packages/react/.storybook/',
274
+ 'package-lock.json',
275
+ '**/.turbo',
276
+ '**/coverage/',
277
+ '**/dist/',
278
+ '**/node_modules/',
279
+ '**/babel.config.*',
280
+ '**/jest.sequencer.*',
281
+ '**/postcss.config.*',
282
+ '**/rollup.config.*',
283
+ '**/webpack.config.*',
284
+ '**/*.png.ts',
285
+ ],
286
+ },
287
+ coreConfig,
288
+ tsConfig,
289
+ ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@medplum/eslint-config",
3
- "version": "4.5.1",
3
+ "version": "5.0.0",
4
4
  "description": "Shared ESLint configuration for Medplum projects",
5
5
  "keywords": [
6
6
  "eslint",
@@ -17,30 +17,29 @@
17
17
  },
18
18
  "license": "Apache-2.0",
19
19
  "author": "Medplum <hello@medplum.com>",
20
- "main": "index.cjs",
20
+ "type": "module",
21
+ "main": "index.mjs",
21
22
  "devDependencies": {
22
- "@typescript-eslint/eslint-plugin": "8.46.0",
23
- "@typescript-eslint/parser": "8.46.0",
24
- "eslint": "8.57.1",
25
- "eslint-plugin-jsdoc": "60.8.3",
23
+ "eslint": "9.38.0",
26
24
  "eslint-plugin-header": "3.1.1",
27
25
  "eslint-plugin-import": "2.32.0",
26
+ "eslint-plugin-jsdoc": "61.1.11",
28
27
  "eslint-plugin-no-only-tests": "3.3.0",
29
- "eslint-plugin-react-hooks": "7.0.0",
30
- "eslint-plugin-react-refresh": "0.4.23"
28
+ "eslint-plugin-react-hooks": "7.0.1",
29
+ "eslint-plugin-react-refresh": "0.4.24",
30
+ "typescript-eslint": "8.46.2"
31
31
  },
32
32
  "peerDependencies": {
33
- "@typescript-eslint/eslint-plugin": "^8",
34
- "@typescript-eslint/parser": "^8",
35
- "eslint": "^8",
36
- "eslint-plugin-jsdoc": "^50",
33
+ "eslint": "^9",
37
34
  "eslint-plugin-header": "^3",
38
35
  "eslint-plugin-import": "^2",
39
- "eslint-plugin-no-only-tests": "^3.3.0",
40
- "eslint-plugin-react-hooks": "^4",
41
- "eslint-plugin-react-refresh": "^0"
36
+ "eslint-plugin-jsdoc": "^61",
37
+ "eslint-plugin-no-only-tests": "^3",
38
+ "eslint-plugin-react-hooks": "^7",
39
+ "eslint-plugin-react-refresh": "^0",
40
+ "typescript-eslint": "^8"
42
41
  },
43
42
  "engines": {
44
- "node": "^20.19.0 || >=22.12.0"
43
+ "node": "^22.18.0 || >=24.2.0"
45
44
  }
46
45
  }