|
1 | 1 | import { resolve } from "node:path"; |
2 | 2 |
|
3 | | -import { getReactEslintConfig } from "@speakeasy-api/config"; |
| 3 | +import { getNodeESLintConfig } from "@speakeasy-api/docs-md-shared"; |
4 | 4 | import { getDirname } from "cross-dirname"; |
5 | | -import globals from "globals"; |
6 | 5 |
|
7 | 6 | const gitignorePath = resolve(getDirname(), "..", "..", ".gitignore"); |
8 | 7 |
|
9 | 8 | export default [ |
10 | | - ...getReactEslintConfig({ |
| 9 | + ...getNodeESLintConfig({ |
11 | 10 | gitignorePaths: gitignorePath, |
12 | 11 | rootDir: getDirname(), |
13 | 12 | entryPoints: { |
14 | 13 | "eslint.config.mjs": ["default"], |
15 | | - "src/react/index.ts": /.*/, |
16 | 14 | "src/compiler/compiler.ts": /.*/, |
17 | 15 | }, |
18 | | - ignores: ["src/compiler/data/wasm_exec.js", ".storybook/**/*"], |
| 16 | + ignores: ["src/compiler/data/wasm_exec.js"], |
19 | 17 | restrictedImports: [ |
20 | 18 | { |
21 | 19 | type: "third-party", |
22 | 20 | moduleSpecifier: "node:fs", |
23 | 21 | allowed: [/src\/compiler\/cli\//], |
24 | 22 | message: |
25 | | - "File system access is only allowed in the CLI wrapper because other code is used in web environments", |
26 | | - }, |
27 | | - { |
28 | | - type: "first-party", |
29 | | - filepath: /src\/compiler\//, |
30 | | - allowed: [/src\/compiler\//], |
31 | | - message: "Only compiler code is allowed to import compiler code", |
32 | | - }, |
33 | | - { |
34 | | - type: "third-party", |
35 | | - moduleSpecifier: /^node:/, |
36 | | - denied: [/src\/react\//], |
37 | | - message: |
38 | | - "React components run in an environment that doesn't have access to Node.js modules", |
39 | | - }, |
40 | | - { |
41 | | - type: "first-party", |
42 | | - filepath: /src\/react/, |
43 | | - allowed: [/src\/react\//], |
44 | | - message: "Only React code is allowed to import React code", |
45 | | - excludeTypeImports: true, |
46 | | - }, |
47 | | - { |
48 | | - type: "first-party", |
49 | | - filepath: /src\/react\/components\/([a-zA-Z0-9-_]+)\/.*\.tsx?$/, |
50 | | - allowed: [ |
51 | | - /src\/react\/components\/$1\/.*\.tsx?$/, |
52 | | - /src\/react\/index\.tsx?$/, |
53 | | - ], |
54 | | - excludeTypeImports: true, |
55 | | - message: |
56 | | - "Reminder: any time a top-level component imports another top-level component, it should be taken in as a runtime value that can be overridden. Use eslint-disable-next-line once there is an overridable property.", |
| 23 | + "File system access is only allowed in the CLI wrapper because other code needs to be isomorphic", |
57 | 24 | }, |
58 | 25 | ], |
59 | 26 | }), |
60 | | - // Since we're a mix of running in both Node.js and React, we override the |
61 | | - // globals set by the React config to include Node.js globals as well. |
62 | | - { |
63 | | - languageOptions: { |
64 | | - globals: { ...globals.browser, ...globals.node }, |
65 | | - }, |
66 | | - }, |
67 | | - // Disable unused exports rule for Storybook files |
68 | | - { |
69 | | - files: ["**/*.stories.{ts,tsx}", ".storybook/*.{ts,tsx}"], |
70 | | - rules: { |
71 | | - "fast-import/no-unused-exports": "off", |
72 | | - }, |
73 | | - }, |
74 | 27 | // Disallow console calls in compiler code (use logging.ts functions instead) |
75 | 28 | { |
76 | 29 | files: ["src/compiler/**/*.{ts,js,mts,mjs}"], |
|
0 commit comments