@cronos-labs/ui 0.8.1 → 0.9.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,6 +1,23 @@
1
1
  export interface ReactEslintConfigOptions {
2
2
  ignores?: string[];
3
+ /**
4
+ * Globs, relative to `tsconfigRootDir`, for files that belong to no
5
+ * tsconfig but should still be linted — config files at the repo root, and
6
+ * build scripts under `scripts/`. typescript-eslint reads this from inside
7
+ * `projectService`, so passing it as a sibling silently does nothing.
8
+ */
3
9
  allowDefaultProject?: string[];
10
+ /**
11
+ * Globs for plain Node files — build scripts, codegen — that should be
12
+ * linted but are not part of the React app: Node globals instead of
13
+ * browser, and no type-aware rules, since they have no types to check and
14
+ * every value reads as `any`. Defaults to none, so a consumer opts in.
15
+ *
16
+ * These are folded into `allowDefaultProject`, which typescript-eslint
17
+ * refuses to match with `**` — use a single-level glob such as
18
+ * `scripts/*.mjs`.
19
+ */
20
+ nodeScripts?: string[];
4
21
  tsconfigRootDir: string;
5
22
  }
6
23
  export declare const createReactEslintConfig: (options: ReactEslintConfigOptions) => import("typescript-eslint").FlatConfig.ConfigArray;
@@ -4,28 +4,57 @@ import tseslint from 'typescript-eslint';
4
4
  import reactHooks from 'eslint-plugin-react-hooks';
5
5
  import reactRefresh from 'eslint-plugin-react-refresh';
6
6
  import eslintConfigPrettier from 'eslint-config-prettier';
7
- export const createReactEslintConfig = (options) => tseslint.config({
8
- ignores: options.ignores ?? ['dist', 'coverage', 'node_modules', 'eslint.config.mjs'],
9
- }, js.configs.recommended, ...tseslint.configs.recommendedTypeChecked, ...tseslint.configs.stylisticTypeChecked, {
10
- languageOptions: {
11
- ecmaVersion: 2023,
12
- globals: {
13
- ...globals.browser,
7
+ export const createReactEslintConfig = (options) => {
8
+ // Node scripts are outside every tsconfig by definition, so they need to be
9
+ // in the default-project allowlist as well as having type-aware rules off.
10
+ // Folding that in here means a consumer names them once.
11
+ const allowDefaultProject = [
12
+ ...(options.allowDefaultProject ?? ['*.{js,mjs,cjs,ts}']),
13
+ ...(options.nodeScripts ?? []),
14
+ ];
15
+ return tseslint.config({
16
+ ignores: options.ignores ?? ['dist', 'coverage', 'node_modules', 'eslint.config.mjs'],
17
+ }, js.configs.recommended, ...tseslint.configs.recommendedTypeChecked, ...tseslint.configs.stylisticTypeChecked, {
18
+ languageOptions: {
19
+ ecmaVersion: 2023,
20
+ globals: {
21
+ ...globals.browser,
22
+ },
23
+ parserOptions: {
24
+ // `allowDefaultProject` is an option *of* the project service, not a
25
+ // sibling of it. Passing `projectService: true` alongside it left
26
+ // the allowlist unread, so any file outside a tsconfig was simply
27
+ // skipped rather than linted.
28
+ projectService: {
29
+ allowDefaultProject,
30
+ },
31
+ tsconfigRootDir: options.tsconfigRootDir,
32
+ },
14
33
  },
15
- parserOptions: {
16
- projectService: true,
17
- allowDefaultProject: options.allowDefaultProject ?? ['*.{js,mjs,cjs,ts}'],
18
- tsconfigRootDir: options.tsconfigRootDir,
34
+ plugins: {
35
+ 'react-hooks': reactHooks,
36
+ 'react-refresh': reactRefresh,
19
37
  },
20
- },
21
- plugins: {
22
- 'react-hooks': reactHooks,
23
- 'react-refresh': reactRefresh,
24
- },
25
- rules: {
26
- ...reactHooks.configs.recommended.rules,
27
- 'react-refresh/only-export-components': ['warn', { allowConstantExport: true }],
28
- '@typescript-eslint/no-explicit-any': 'error',
29
- '@typescript-eslint/consistent-type-imports': ['error', { prefer: 'type-imports' }],
30
- },
31
- }, eslintConfigPrettier);
38
+ rules: {
39
+ ...reactHooks.configs.recommended.rules,
40
+ 'react-refresh/only-export-components': ['warn', { allowConstantExport: true }],
41
+ '@typescript-eslint/no-explicit-any': 'error',
42
+ '@typescript-eslint/consistent-type-imports': ['error', { prefer: 'type-imports' }],
43
+ },
44
+ },
45
+ // Plain Node files, opted into by the consumer. Type-aware rules are
46
+ // switched off for them with typescript-eslint's own
47
+ // `disableTypeChecked`: a .mjs build script has no types, so every value
48
+ // reads as `any` and the unsafe-* rules fire on correct code.
49
+ ...(options.nodeScripts?.length
50
+ ? [
51
+ {
52
+ files: options.nodeScripts,
53
+ ...tseslint.configs.disableTypeChecked,
54
+ languageOptions: {
55
+ globals: { ...globals.node },
56
+ },
57
+ },
58
+ ]
59
+ : []), eslintConfigPrettier);
60
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cronos-labs/ui",
3
- "version": "0.8.1",
3
+ "version": "0.9.0",
4
4
  "packageManager": "npm@11.19.0",
5
5
  "description": "Shared Header, Footer, Seo, locale and theme primitives for Cronos web properties.",
6
6
  "license": "UNLICENSED",