@chanyuxi/eslint-waltz 0.0.0-alpha.2 → 0.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.
package/README.md CHANGED
@@ -1,12 +1,12 @@
1
1
  # Introduction
2
2
 
3
- 👋 A <b>fast eslint config boot</b> for `chanyuxi`.
3
+ 👋 A composable ESLint flat config for JavaScript, TypeScript, JSONC, imports, and React.
4
4
 
5
- 😘 Thanks for [@antfu/eslint-config](https://github.com/antfu/eslint-config)
5
+ Inspired by [@antfu/eslint-config](https://github.com/antfu/eslint-config).
6
6
 
7
7
  # Features
8
8
 
9
- At present, the following modes are supported, and more features are under development
9
+ The following configuration modules are available:
10
10
 
11
11
  - ✅ Javascript
12
12
  - ✅ Typescript
@@ -14,17 +14,20 @@ At present, the following modes are supported, and more features are under devel
14
14
  - ✅ Json
15
15
  - ✅ Import
16
16
  - ✅ React
17
- - 🕐 <i>Continuously updating...</i>
17
+ - JSONC is enabled by default and can be disabled with `json: false`.
18
+ - TypeScript, imports, React, and gitignore support are opt-in.
18
19
 
19
20
  # Usage
20
21
 
21
22
  #### Install
22
23
 
23
- Install from `npm` | `pnpm` | `yarn`
24
+ Install the core package and its core ESLint peers:
24
25
 
25
26
  ```bash
26
- npm i -D @chanyuxi/eslint-waltz
27
- ```
27
+ pnpm add -D @chanyuxi/eslint-waltz eslint @eslint/js @stylistic/eslint-plugin eslint-plugin-jsonc jsonc-eslint-parser globals
28
+ ```
29
+
30
+ Install the peer packages for any optional modules you enable, such as `typescript-eslint`, `eslint-plugin-import`, or the React ESLint plugins.
28
31
 
29
32
  #### Configuration
30
33
 
@@ -34,7 +37,24 @@ Create a `eslint.config.ts` file in the project root directory and configure it
34
37
  import waltz from '@chanyuxi/eslint-waltz'
35
38
 
36
39
  export default waltz({
37
- // enable typescript lint
38
- ts: true,
40
+ // JSONC is enabled by default
41
+ json: true,
42
+ ts: true,
43
+ imports: true,
44
+ react: true,
45
+ js: { globals: ['browser'] },
46
+ })
47
+ ```
48
+
49
+ Every module accepts `files` and `overrides` where applicable. Custom flat configs can be appended after the options:
50
+
51
+ ```ts
52
+ export default waltz({}, {
53
+ files: ['src/**/*.js'],
54
+ rules: {
55
+ 'no-console': 'off',
56
+ },
39
57
  })
40
58
  ```
59
+
60
+ Run `pnpm run check` before committing. `pnpm pack` and `npm publish` build the package automatically through the `prepack` lifecycle.
package/dist/index.d.ts CHANGED
@@ -5027,6 +5027,8 @@ type Rules = Record<string, Linter.RuleEntry | undefined> & RuleOptions;
5027
5027
  interface LinterConfig extends Omit<Linter.Config, 'rules'> {
5028
5028
  rules?: Rules;
5029
5029
  }
5030
+ type Arraiable<T> = T | Array<T>;
5031
+ type UnresolvedLinterConfig = Arraiable<LinterConfig> | Promise<Arraiable<LinterConfig>>;
5030
5032
  interface SharedOptions {
5031
5033
  /**
5032
5034
  * Each configuration automatically lints all corresponding files, this option is used to override
@@ -5034,7 +5036,7 @@ interface SharedOptions {
5034
5036
  files?: Linter.Config['files'];
5035
5037
  /**
5036
5038
  * Rewrite rules
5037
- */
5039
+ */
5038
5040
  overrides?: LinterConfig['rules'];
5039
5041
  }
5040
5042
  interface JsOptions extends SharedOptions {
@@ -5043,6 +5045,7 @@ interface JsOptions extends SharedOptions {
5043
5045
  type TsOptions = SharedOptions;
5044
5046
  type StylisticOptions = SharedOptions;
5045
5047
  type JsoncOptions = SharedOptions;
5048
+ type ImportsOptions = SharedOptions;
5046
5049
  type ReactOptions = SharedOptions;
5047
5050
  interface WaltzOptions {
5048
5051
  /**
@@ -5073,19 +5076,24 @@ interface WaltzOptions {
5073
5076
  */
5074
5077
  stylistic?: StylisticOptions;
5075
5078
  /**
5079
+ * Enable JSON/JSONC rules
5076
5080
  *
5081
+ * @default true
5077
5082
  */
5078
5083
  json?: boolean | JsoncOptions;
5079
5084
  /**
5085
+ * Enable import rules
5080
5086
  *
5087
+ * @default false
5081
5088
  */
5082
- imports?: boolean;
5089
+ imports?: boolean | ImportsOptions;
5083
5090
  /**
5084
5091
  * @default false
5085
5092
  */
5086
5093
  react?: boolean | ReactOptions;
5087
5094
  }
5088
5095
 
5089
- declare function waltz(options?: WaltzOptions, ...orders: LinterConfig[]): Promise<FlatArray<LinterConfig | LinterConfig[], 0 | 1 | -1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20>[]>;
5096
+ declare function waltz(options?: WaltzOptions, ...orders: LinterConfig[]): Promise<LinterConfig[]>;
5090
5097
 
5091
5098
  export { waltz as default };
5099
+ export type { ImportsOptions, JsOptions, JsoncOptions, LinterConfig, ReactOptions, SharedOptions, StylisticOptions, TsOptions, UnresolvedLinterConfig, WaltzOptions };