@heyq02/rslint-config 0.0.1 → 0.0.3-beta.1

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.
package/README.md CHANGED
@@ -1,8 +1,12 @@
1
1
  # @heyq02/rslint-config
2
2
 
3
- [![npm version][npm-version-src]][npm-version-href]
4
- [![npm downloads][npm-downloads-src]][npm-downloads-href]
5
- [![Unit Test][unit-test-src]][unit-test-href]
3
+ <!-- automd:badges license -->
4
+
5
+ [![npm version](https://img.shields.io/npm/v/@heyq02/rslint-config)](https://npmjs.com/package/@heyq02/rslint-config)
6
+ [![npm downloads](https://img.shields.io/npm/dm/@heyq02/rslint-config)](https://npm.chart.dev/@heyq02/rslint-config)
7
+ [![license](https://img.shields.io/github/license/heyq02/rslint-config)](https://github.com/heyq02/rslint-config/blob/main/LICENSE)
8
+
9
+ <!-- /automd -->
6
10
 
7
11
  Opinionated [Rslint](https://rslint.rs/) flat-config preset, structured like [`@sxzz/eslint-config`](https://github.com/sxzz/eslint-config) and built on `@rslint/core` native presets.
8
12
 
@@ -11,6 +15,8 @@ Opinionated [Rslint](https://rslint.rs/) flat-config preset, structured like [`@
11
15
  - One-line config via `heyq02()`
12
16
  - JavaScript + TypeScript presets (`recommended` / `strict` / type-checked / stylistic)
13
17
  - Built-in Unicorn, import, Node, and Promise rules
18
+ - Import sorting via `import/order` with an [Oxfmt `sortImports`](https://oxc.rs/docs/guide/usage/formatter/sorting.html)-shaped API
19
+ - Community plugins (Rslint-compatible): unused-imports, regexp, de-morgan, eslint-comments
14
20
  - Optional React, React Hooks, JSX a11y, Jest, and Rstest (auto-detected)
15
21
  - Ignores common build artifacts (`dist`, `coverage`, lockfiles, …)
16
22
  - Special-case overrides for CLIs, tests, config files, and components
@@ -27,7 +33,7 @@ pnpm add -D @heyq02/rslint-config @rslint/core
27
33
 
28
34
  ```ts
29
35
  // rslint.config.ts
30
- import { heyq02 } from "@heyq02/rslint-config";
36
+ import { heyq02 } from '@heyq02/rslint-config';
31
37
 
32
38
  export default heyq02({
33
39
  // Features auto-detect installed packages when omitted
@@ -44,7 +50,7 @@ export default heyq02(
44
50
  { typescript: true },
45
51
  {
46
52
  rules: {
47
- "no-console": "off",
53
+ 'no-console': 'off',
48
54
  },
49
55
  },
50
56
  );
@@ -52,24 +58,72 @@ export default heyq02(
52
58
 
53
59
  ### Options
54
60
 
55
- | Option | Default | Description |
56
- | ------------ | ------------------- | ----------------------------------------------------------------------- |
57
- | `typescript` | auto (`typescript`) | `true` / `false` / `{ typeChecked, strict, stylistic, projectService }` |
58
- | `javascript` | `true` | JavaScript recommended + opinionated rules |
59
- | `unicorn` | `true` | Unicorn recommended + overrides |
60
- | `imports` | `true` | Import recommended + no-default-export, etc. |
61
- | `node` | `true` (`module`) | `true` / `'module'` / `'script'` / `'mixed'` |
62
- | `promise` | `true` | Promise recommended (relaxed for async/await) |
63
- | `react` | auto (`react`) | React + React Hooks (+ jsx-a11y) |
64
- | `jsxA11y` | with react | JSX accessibility rules |
65
- | `jest` | auto (`jest`) | Jest recommended + style |
66
- | `rstest` | auto (`rstest`) | Rstest recommended |
67
- | `ignores` | `[]` | Extra global ignore patterns |
61
+ | Option | Default | Description |
62
+ | ---------------- | ------------------- | --------------------------------------------------------------------------------------------- |
63
+ | `typescript` | auto (`typescript`) | `true` / `false` / `{ typeChecked, strict, stylistic, projectService }` |
64
+ | `javascript` | `true` | JavaScript recommended + opinionated rules |
65
+ | `unicorn` | `true` | Unicorn recommended + overrides |
66
+ | `imports` | `true` | Import recommended + no-default-export, etc. |
67
+ | `sortImports` | `true` | `true` / `false` / Oxfmt-like `{ groups, newlinesBetween, customGroups, … }` → `import/order` |
68
+ | `node` | `true` (`module`) | `true` / `'module'` / `'script'` / `'mixed'` |
69
+ | `promise` | `true` | Promise recommended (relaxed for async/await) |
70
+ | `react` | auto (`react`) | React + React Hooks (+ jsx-a11y) |
71
+ | `jsxA11y` | with react | JSX accessibility rules |
72
+ | `jest` | auto (`jest`) | Jest recommended + style |
73
+ | `rstest` | auto (`rstest`) | Rstest recommended |
74
+ | `unusedImports` | `true` | `eslint-plugin-unused-imports` (autofix unused imports) |
75
+ | `regexp` | `true` | `eslint-plugin-regexp` |
76
+ | `deMorgan` | `true` | `eslint-plugin-de-morgan` |
77
+ | `eslintComments` | `true` | `@eslint-community/eslint-plugin-eslint-comments` |
78
+ | `ignores` | `[]` | Extra global ignore patterns |
79
+
80
+ ### Sort imports
81
+
82
+ Enabled by default (when `imports` is on). Options mirror Oxfmt [`sortImports`](https://oxc.rs/docs/guide/usage/formatter/sorting.html) where Rslint can enforce them via [`import/order`](https://rslint.rs/rules/import/order):
83
+
84
+ ```ts
85
+ export default heyq02({
86
+ sortImports: {
87
+ groups: [
88
+ 'type',
89
+ ['builtin', 'external'],
90
+ 'internal',
91
+ ['parent', 'sibling', 'index'],
92
+ 'unknown',
93
+ ],
94
+ newlinesBetween: true,
95
+ internalPattern: ['~/', '@/', '#'],
96
+ customGroups: [
97
+ {
98
+ groupName: 'react-libs',
99
+ elementNamePattern: ['react', 'react-**'],
100
+ group: 'external',
101
+ position: 'before',
102
+ },
103
+ ],
104
+ order: 'asc',
105
+ ignoreCase: true,
106
+ named: true,
107
+ },
108
+ });
109
+ ```
110
+
111
+ | Oxfmt option | This package | Notes |
112
+ | ------------------------------------------- | ----------------- | --------------------------------------------------------------------------------------------------- |
113
+ | `groups` | `groups` | Uses `import/order` names (`builtin`, `type`, …), not perfectionist selectors (`value-builtin`) |
114
+ | `newlinesBetween` | `newlinesBetween` | `boolean` → `always` / `never`; per-group `{ newlinesBetween }` markers unsupported |
115
+ | `customGroups` | `customGroups` | Mapped to `pathGroups` (`group` + `position` required conceptually; defaults `external` / `before`) |
116
+ | `internalPattern` | `internalPattern` | Glob-like prefixes → `import/internal-regex` |
117
+ | `order` / `ignoreCase` | same | → `alphabetize` |
118
+ | `sortSideEffects` | `sortSideEffects` | → `warnOnUnassignedImports` |
119
+ | `partitionByComment` / `partitionByNewline` | — | Not supported by `import/order` |
120
+
121
+ If Oxfmt already sorts imports, set `sortImports: false` to avoid fighting the formatter.
68
122
 
69
123
  ### Presets
70
124
 
71
125
  ```ts
72
- import { presetJavaScript, presetBasic, presetAll } from "@heyq02/rslint-config";
126
+ import { presetJavaScript, presetBasic, presetAll } from '@heyq02/rslint-config';
73
127
 
74
128
  export default presetBasic();
75
129
  ```
@@ -77,21 +131,32 @@ export default presetBasic();
77
131
  ## Development
78
132
 
79
133
  ```bash
80
- vp install
81
- vp pack
82
- vp check
83
- pnpm release # bumpp → tag v* → GitHub Release + npm publish
134
+ pnpm install
135
+ pnpm run build
136
+ pnpm run lint
137
+ pnpm run typecheck
138
+ pnpm run format # automd + vp fmt (Oxfmt via Vite+)
139
+ pnpm run check # format:check + rslint + tsc
140
+ pnpm release # bumpp → tag v* → GitHub Release + npm publish
84
141
  ```
85
142
 
86
143
  ## License
87
144
 
88
- [MIT](./LICENSE) © Ari
145
+ <!-- automd:contributors license=MIT author="heyq02" -->
146
+
147
+ Published under the [MIT](https://github.com/heyq02/rslint-config/blob/main/LICENSE) license.
148
+ Made by [@heyq02](https://github.com/heyq02) and [community](https://github.com/heyq02/rslint-config/graphs/contributors) 💛
149
+ <br><br>
150
+ <a href="https://github.com/heyq02/rslint-config/graphs/contributors">
151
+ <img src="https://contrib.rocks/image?repo=heyq02/rslint-config" />
152
+ </a>
153
+
154
+ <!-- /automd -->
155
+
156
+ <!-- automd:with-automd -->
157
+
158
+ ---
89
159
 
90
- <!-- Badges -->
160
+ _🤖 auto updated with [automd](https://automd.unjs.io)_
91
161
 
92
- [npm-version-src]: https://img.shields.io/npm/v/@heyq02/rslint-config.svg
93
- [npm-version-href]: https://npmjs.com/package/@heyq02/rslint-config
94
- [npm-downloads-src]: https://img.shields.io/npm/dm/@heyq02/rslint-config
95
- [npm-downloads-href]: https://www.npmcharts.com/compare/@heyq02/rslint-config?interval=30
96
- [unit-test-src]: https://github.com/heyq02/rslint-config/actions/workflows/unit-test.yml/badge.svg
97
- [unit-test-href]: https://github.com/heyq02/rslint-config/actions/workflows/unit-test.yml
162
+ <!-- /automd -->
@@ -0,0 +1,5 @@
1
+ import type { TypedFlatConfig } from '../types.js';
2
+ /**
3
+ * De Morgan rewrites via `eslint-plugin-de-morgan` (Rslint community plugin).
4
+ */
5
+ export declare const deMorgan: () => TypedFlatConfig[];
@@ -0,0 +1,5 @@
1
+ import type { TypedFlatConfig } from '../types.js';
2
+ /**
3
+ * `eslint-disable` hygiene via `@eslint-community/eslint-plugin-eslint-comments`.
4
+ */
5
+ export declare const eslintComments: () => TypedFlatConfig[];
@@ -0,0 +1,2 @@
1
+ import type { TypedFlatConfig } from '../types.js';
2
+ export declare const ignores: (extra?: string[]) => TypedFlatConfig[];
@@ -0,0 +1,10 @@
1
+ import type { SortImportsOptions, TypedFlatConfig } from '../types.js';
2
+ export interface ImportsOptions {
3
+ typescript?: boolean;
4
+ /**
5
+ * Enable Oxfmt-shaped import sorting via `import/order`.
6
+ * @default true
7
+ */
8
+ sortImports?: boolean | SortImportsOptions;
9
+ }
10
+ export declare const imports: (options?: ImportsOptions) => TypedFlatConfig[];
@@ -0,0 +1,16 @@
1
+ export * from './de-morgan.js';
2
+ export * from './eslint-comments.js';
3
+ export * from './ignores.js';
4
+ export * from './imports.js';
5
+ export * from './javascript.js';
6
+ export * from './jest.js';
7
+ export * from './node.js';
8
+ export * from './promise.js';
9
+ export * from './react.js';
10
+ export * from './regexp.js';
11
+ export * from './rstest.js';
12
+ export * from './sort-imports.js';
13
+ export * from './special-cases.js';
14
+ export * from './typescript.js';
15
+ export * from './unicorn.js';
16
+ export * from './unused-imports.js';
@@ -0,0 +1,3 @@
1
+ import type { TypedFlatConfig } from '../types.js';
2
+ export declare const restrictedSyntaxJs: string[];
3
+ export declare const javascript: () => TypedFlatConfig[];
@@ -0,0 +1,2 @@
1
+ import type { TypedFlatConfig } from '../types.js';
2
+ export declare const jest: () => TypedFlatConfig[];
@@ -0,0 +1,2 @@
1
+ import type { NodePreset, TypedFlatConfig } from '../types.js';
2
+ export declare const node: (preset?: Exclude<NodePreset, false>) => TypedFlatConfig[];
@@ -0,0 +1,2 @@
1
+ import type { TypedFlatConfig } from '../types.js';
2
+ export declare const promise: () => TypedFlatConfig[];
@@ -0,0 +1,5 @@
1
+ import type { TypedFlatConfig } from '../types.js';
2
+ export declare const jsxA11y: () => TypedFlatConfig[];
3
+ export declare const react: (options?: {
4
+ jsxA11y?: boolean;
5
+ }) => TypedFlatConfig[];
@@ -0,0 +1,5 @@
1
+ import type { TypedFlatConfig } from '../types.js';
2
+ /**
3
+ * RegExp quality rules via `eslint-plugin-regexp` (Rslint community plugin).
4
+ */
5
+ export declare const regexp: () => TypedFlatConfig[];
@@ -0,0 +1,2 @@
1
+ import type { TypedFlatConfig } from '../types.js';
2
+ export declare const rstest: () => TypedFlatConfig[];
@@ -0,0 +1,42 @@
1
+ import type { ImportOrderOptions } from '@rslint/core';
2
+ import type { SortImportsCustomGroup, SortImportsOptions } from '../types.js';
3
+ /** eslint-plugin-import / Rslint `import/order` group names. */
4
+ export type ImportOrderGroup = 'builtin' | 'external' | 'internal' | 'unknown' | 'parent' | 'sibling' | 'index' | 'object' | 'type';
5
+ type ImportOrderConfig = NonNullable<ImportOrderOptions[0]>;
6
+ /**
7
+ * Default group order inspired by Oxfmt / perfectionist `sort-imports`
8
+ * (type-first, then builtin+external, internal, relative, unknown).
9
+ *
10
+ * Mapped onto `import/order` groups — modifier-selectors like
11
+ * `value-builtin` / `type-internal` are not expressible 1:1, so types are
12
+ * collected via the dedicated `type` group.
13
+ *
14
+ * @see https://oxc.rs/docs/guide/usage/formatter/sorting.html
15
+ */
16
+ export declare const DEFAULT_SORT_IMPORT_GROUPS: (ImportOrderGroup | ImportOrderGroup[])[];
17
+ /** Oxfmt default prefixes for internal modules. */
18
+ export declare const DEFAULT_INTERNAL_PATTERN: string[];
19
+ /**
20
+ * Convert Oxfmt-style glob prefixes (`~/`, `@/`, `#`) into a single
21
+ * `import/internal-regex` source string.
22
+ */
23
+ export declare function internalPatternToRegex(patterns: string[]): string;
24
+ /**
25
+ * Map Oxfmt-like `customGroups` onto `import/order` `pathGroups`.
26
+ *
27
+ * Custom group names are not first-class in `import/order`; each entry must
28
+ * attach to a real group via `group` / `position` (defaults: `external` /
29
+ * `before`), matching the common “react before other externals” pattern.
30
+ */
31
+ export declare function customGroupsToPathGroups(customGroups: SortImportsCustomGroup[]): Exclude<ImportOrderConfig['pathGroups'], undefined>;
32
+ /**
33
+ * Translate Oxfmt-shaped `sortImports` options into `import/order` options +
34
+ * settings. Options that cannot be honored (per-group `newlinesBetween`
35
+ * markers, `partitionByComment`, perfectionist modifier-selectors, etc.) are
36
+ * intentionally omitted — see README.
37
+ */
38
+ export declare function resolveSortImports(options?: true | SortImportsOptions): {
39
+ rule: ImportOrderConfig;
40
+ settings: Record<string, unknown>;
41
+ };
42
+ export {};
@@ -0,0 +1,2 @@
1
+ import type { TypedFlatConfig } from '../types.js';
2
+ export declare const specialCases: () => TypedFlatConfig[];
@@ -0,0 +1,2 @@
1
+ import type { TypeScriptOptions, TypedFlatConfig } from '../types.js';
2
+ export declare const typescript: (options?: true | TypeScriptOptions) => TypedFlatConfig[];
@@ -0,0 +1,2 @@
1
+ import type { TypedFlatConfig } from '../types.js';
2
+ export declare const unicorn: () => TypedFlatConfig[];
@@ -0,0 +1,5 @@
1
+ import type { TypedFlatConfig } from '../types.js';
2
+ /**
3
+ * Autofix unused imports via `eslint-plugin-unused-imports` (Rslint community plugin).
4
+ */
5
+ export declare const unusedImports: () => TypedFlatConfig[];
package/dist/env.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ export declare const hasTypeScript: () => boolean;
2
+ export declare const hasReact: () => boolean;
3
+ export declare const hasJest: () => boolean;
4
+ export declare const hasRstest: () => boolean;
5
+ export declare function isInEditorEnv(): boolean;
6
+ export declare function isInGitHooksOrLintStaged(): boolean;
@@ -0,0 +1,11 @@
1
+ export declare const GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
2
+ export declare const GLOB_SRC = "**/*.?([cm])[jt]s?(x)";
3
+ export declare const GLOB_JS = "**/*.?([cm])js";
4
+ export declare const GLOB_JSX = "**/*.jsx";
5
+ export declare const GLOB_TS = "**/*.?([cm])ts";
6
+ export declare const GLOB_TSX = "**/*.tsx";
7
+ export declare const GLOB_TESTS: readonly ["**/__tests__/**/*.?([cm])[jt]s?(x)", "**/*.spec.?([cm])[jt]s?(x)", "**/*.test.?([cm])[jt]s?(x)", "**/*.bench.?([cm])[jt]s?(x)", "**/*.benchmark.?([cm])[jt]s?(x)"];
8
+ export declare const GLOB_NODE_MODULES: '**/node_modules';
9
+ export declare const GLOB_DIST: '**/dist';
10
+ export declare const GLOB_LOCKFILE: string[];
11
+ export declare const GLOB_EXCLUDE: string[];
@@ -0,0 +1,6 @@
1
+ export * from './configs/index.js';
2
+ export * from './env.js';
3
+ export * from './globs.js';
4
+ export * from './presets.js';
5
+ export * from './types.js';
6
+ export * from './utils.js';