@forthtilliath/eslint-config 0.4.2 → 0.6.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 +31 -0
- package/dist/angular.d.ts.map +1 -1
- package/dist/angular.js +21 -1
- package/dist/base.d.ts +35 -1
- package/dist/base.d.ts.map +1 -1
- package/dist/base.js +62 -31
- package/dist/nextjs.d.ts.map +1 -1
- package/dist/nextjs.js +4 -1
- package/dist/react.d.ts +1 -1
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +7 -25
- package/package.json +10 -5
package/README.md
CHANGED
|
@@ -31,6 +31,17 @@ there's nothing else to install per variant.
|
|
|
31
31
|
|
|
32
32
|
## Usage
|
|
33
33
|
|
|
34
|
+
Quick reference — pick the row matching the package, in its `eslint.config.ts`:
|
|
35
|
+
|
|
36
|
+
| Variant | Subpath | Use for | Extends |
|
|
37
|
+
| ------------------- | --------------- | -------------------------- | ------------- |
|
|
38
|
+
| `baseConfig` | `.` (root) | A plain TypeScript library | — |
|
|
39
|
+
| `reactConfig` | `/react` | A React library | `baseConfig` |
|
|
40
|
+
| `nextJsConfig` | `/nextjs` | A Next.js app | `reactConfig` |
|
|
41
|
+
| `storybookConfig` | `/storybook` | A Storybook app | `reactConfig` |
|
|
42
|
+
| `reactNativeConfig` | `/react-native` | A React Native / Expo app | `reactConfig` |
|
|
43
|
+
| `angularConfig` | `/angular` | An Angular app/library | `baseConfig` |
|
|
44
|
+
|
|
34
45
|
Pick the variant that matches the package, in its `eslint.config.ts`:
|
|
35
46
|
|
|
36
47
|
```ts
|
|
@@ -104,6 +115,7 @@ export default createBaseConfig({ strict: false, turbo: false });
|
|
|
104
115
|
| `prettier` | `true` | Append `eslint-config-prettier` at the end. |
|
|
105
116
|
| `strict` | `true` | Use `strictTypeChecked`/`stylisticTypeChecked` instead of plain `recommended`. |
|
|
106
117
|
| `turbo` | `true` | Enable `eslint-plugin-turbo`'s `no-undeclared-env-vars` rule. |
|
|
118
|
+
| `snakeCase` | `false` | Also accept `snake_case` variable names in `@typescript-eslint/naming-convention` (e.g. rows destructured straight from a Supabase/SQL database). |
|
|
107
119
|
| `a11y` | `true`\* | _(react/nextjs/storybook/react-native)_ Enable `eslint-plugin-jsx-a11y`'s recommended rules. \*Defaults to `false` in `createReactNativeConfig` (jsx-a11y targets DOM semantics, which RN doesn't have). |
|
|
108
120
|
| `i18n` | `false` | _(react/nextjs/storybook/react-native)_ Enable `eslint-plugin-i18next`'s `no-literal-string` rule. |
|
|
109
121
|
| `testingLibrary` | `false` | _(react/nextjs/storybook/react-native)_ Enable `eslint-plugin-testing-library` + `eslint-plugin-jest-dom` on test files. |
|
|
@@ -144,6 +156,23 @@ Rules that need type information (`consistent-type-exports`,
|
|
|
144
156
|
from linting entirely — none of them belong to a package's own `tsconfig`
|
|
145
157
|
project, so type-aware rules crash on them otherwise.
|
|
146
158
|
|
|
159
|
+
### Angular import order
|
|
160
|
+
|
|
161
|
+
`angularConfig` overrides `simple-import-sort/imports` on `**/*.ts` so
|
|
162
|
+
`@angular/core`/`rxjs` sort before every other package, ahead of the generic
|
|
163
|
+
"third-party packages, alphabetically" group `baseConfig` uses everywhere
|
|
164
|
+
else — the conventional Angular reading order (framework, then everything
|
|
165
|
+
else, then app code).
|
|
166
|
+
|
|
167
|
+
## Testing this package
|
|
168
|
+
|
|
169
|
+
Unlike the other five variants — each already exercised by whatever
|
|
170
|
+
package/app in this monorepo lints under them — `angularConfig` has no real
|
|
171
|
+
consumer here yet, so `src/angular.test.js` lints small fixture files under
|
|
172
|
+
`src/__fixtures__/angular/` through ESLint's Node API directly, standing in
|
|
173
|
+
for that. Extend it (or add a sibling `<variant>.test.js`) whenever a variant
|
|
174
|
+
changes without a real consumer to catch a regression.
|
|
175
|
+
|
|
147
176
|
## Scripts
|
|
148
177
|
|
|
149
178
|
```bash
|
|
@@ -151,6 +180,8 @@ pnpm run build # tsc -> dist/ (consumers import the built output)
|
|
|
151
180
|
pnpm run dev # tsc --watch
|
|
152
181
|
pnpm run check-types # tsc --noEmit
|
|
153
182
|
pnpm run lint # eslint (lints its own src/)
|
|
183
|
+
pnpm run test # vitest run
|
|
184
|
+
pnpm run test:watch # vitest
|
|
154
185
|
```
|
|
155
186
|
|
|
156
187
|
Run `pnpm run build` after editing `src/*.js` — consuming packages resolve
|
package/dist/angular.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"angular.d.ts","sourceRoot":"","sources":["../src/angular.js"],"names":[],"mappings":"AAMA;;;;;;;;;;GAUG;AACH,8CAHW,OAAO,WAAW,EAAE,iBAAiB,GACnC,OAAO,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"angular.d.ts","sourceRoot":"","sources":["../src/angular.js"],"names":[],"mappings":"AAMA;;;;;;;;;;GAUG;AACH,8CAHW,OAAO,WAAW,EAAE,iBAAiB,GACnC,OAAO,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,CA+D5C;AAED;;;;8CAI8C;AAC9C,4BADU,OAAO,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,CACS"}
|
package/dist/angular.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import angular from "angular-eslint";
|
|
2
2
|
import { defineConfig } from "eslint/config";
|
|
3
3
|
import tseslint from "typescript-eslint";
|
|
4
|
-
import { createBaseConfig } from "./base.js";
|
|
4
|
+
import { createBaseConfig, NODE_BUILTIN_IMPORT_GROUP } from "./base.js";
|
|
5
5
|
/**
|
|
6
6
|
* A custom ESLint configuration for Angular applications/libraries.
|
|
7
7
|
*
|
|
@@ -38,6 +38,26 @@ export function createAngularConfig(options) {
|
|
|
38
38
|
// Un composant/page Angular sans logique propre (juste un template +
|
|
39
39
|
// decorateur) est un corps de classe legitimement vide, pas du code mort.
|
|
40
40
|
"@typescript-eslint/no-extraneous-class": "off",
|
|
41
|
+
// Convention Angular : le framework (et RxJS, quasi-systematiquement
|
|
42
|
+
// utilise a ses cotes) se lit avant le reste — packages tiers, puis
|
|
43
|
+
// imports internes de l'app. baseConfig's generic "^@?\\w" group
|
|
44
|
+
// sorts every third-party package alphabetically together, which
|
|
45
|
+
// would interleave "@angular/core" with unrelated libs instead.
|
|
46
|
+
"simple-import-sort/imports": [
|
|
47
|
+
"error",
|
|
48
|
+
{
|
|
49
|
+
groups: [
|
|
50
|
+
NODE_BUILTIN_IMPORT_GROUP,
|
|
51
|
+
["^@angular", "^rxjs"],
|
|
52
|
+
["^@?\\w"],
|
|
53
|
+
["^(@forthtilliath)(/.*|$)"],
|
|
54
|
+
["^(@|@ui|components|utils|config)(/.*|$)"],
|
|
55
|
+
["^\\u0000"],
|
|
56
|
+
["^\\.\\.(?!/?$)", "^\\.\\./?$"],
|
|
57
|
+
["^\\./(?=.*/)(?!/?$)", "^\\.(?!/?$)", "^\\./?$"],
|
|
58
|
+
],
|
|
59
|
+
},
|
|
60
|
+
],
|
|
41
61
|
},
|
|
42
62
|
},
|
|
43
63
|
{
|
package/dist/base.d.ts
CHANGED
|
@@ -11,14 +11,41 @@
|
|
|
11
11
|
* @property {boolean} [turbo=true] - Enable eslint-plugin-turbo's
|
|
12
12
|
* `no-undeclared-env-vars` rule. Only relevant inside a Turborepo; set to
|
|
13
13
|
* `false` for a standalone project.
|
|
14
|
+
* @property {boolean} [snakeCase=false] - Also accept `snake_case` variable
|
|
15
|
+
* names in `@typescript-eslint/naming-convention` — for code that
|
|
16
|
+
* destructures rows straight from a SQL database (e.g. Supabase), whose
|
|
17
|
+
* columns are snake_case.
|
|
14
18
|
*/
|
|
19
|
+
/**
|
|
20
|
+
* Builds the `@typescript-eslint/naming-convention` rule entry. Exported so
|
|
21
|
+
* variants that loosen it (react.js accepts PascalCase components) stay in
|
|
22
|
+
* sync with the `snakeCase` option instead of redeclaring the whole list.
|
|
23
|
+
*
|
|
24
|
+
* @param {object} [options]
|
|
25
|
+
* @param {boolean} [options.snakeCase=false] - See {@link BaseConfigOptions}.
|
|
26
|
+
* @param {boolean} [options.react=false] - Accept PascalCase for `const`
|
|
27
|
+
* variables and functions (React components).
|
|
28
|
+
* @returns {import("eslint").Linter.RuleEntry}
|
|
29
|
+
*/
|
|
30
|
+
export function createNamingConventionRule({ snakeCase, react, }?: {
|
|
31
|
+
snakeCase?: boolean | undefined;
|
|
32
|
+
react?: boolean | undefined;
|
|
33
|
+
}): import("eslint").Linter.RuleEntry;
|
|
15
34
|
/**
|
|
16
35
|
* Builds a shared ESLint configuration for the repository.
|
|
17
36
|
*
|
|
18
37
|
* @param {BaseConfigOptions} [options]
|
|
19
38
|
* @returns {import("eslint").Linter.Config[]}
|
|
20
39
|
*/
|
|
21
|
-
export function createBaseConfig({ prettier, strict, turbo, }?: BaseConfigOptions): import("eslint").Linter.Config[];
|
|
40
|
+
export function createBaseConfig({ prettier, strict, turbo, snakeCase, }?: BaseConfigOptions): import("eslint").Linter.Config[];
|
|
41
|
+
/**
|
|
42
|
+
* Node.js builtins without the `node:` prefix, as the first
|
|
43
|
+
* `simple-import-sort/imports` group. Exported so other variants (e.g.
|
|
44
|
+
* angular.js, which overrides this rule with Angular-specific groups) don't
|
|
45
|
+
* have to duplicate the list to keep builtins sorted first too.
|
|
46
|
+
* @type {string[]}
|
|
47
|
+
*/
|
|
48
|
+
export const NODE_BUILTIN_IMPORT_GROUP: string[];
|
|
22
49
|
/**
|
|
23
50
|
* A shared ESLint configuration for the repository, with the default options.
|
|
24
51
|
* Use `createBaseConfig(options)` instead to customize it.
|
|
@@ -47,5 +74,12 @@ export type BaseConfigOptions = {
|
|
|
47
74
|
* `false` for a standalone project.
|
|
48
75
|
*/
|
|
49
76
|
turbo?: boolean | undefined;
|
|
77
|
+
/**
|
|
78
|
+
* - Also accept `snake_case` variable
|
|
79
|
+
* names in `@typescript-eslint/naming-convention` — for code that
|
|
80
|
+
* destructures rows straight from a SQL database (e.g. Supabase), whose
|
|
81
|
+
* columns are snake_case.
|
|
82
|
+
*/
|
|
83
|
+
snakeCase?: boolean | undefined;
|
|
50
84
|
};
|
|
51
85
|
//# sourceMappingURL=base.d.ts.map
|
package/dist/base.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../src/base.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../src/base.js"],"names":[],"mappings":"AAuBA;;;;;;;;;;;;;;;;;GAiBG;AAEH;;;;;;;;;;GAUG;AACH,mEALG;IAA0B,SAAS;IACT,KAAK;CAE/B,GAAU,OAAO,QAAQ,EAAE,MAAM,CAAC,SAAS,CA+B7C;AAED;;;;;GAKG;AACH,2EAHW,iBAAiB,GACf,OAAO,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,CAiH5C;AAjMD;;;;;;GAMG;AACH,wCAFU,MAAM,EAAE,CAQhB;AAsLF;;;;;KAKK;AACL,yBAFU,OAAO,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,CAEG"}
|
package/dist/base.js
CHANGED
|
@@ -5,6 +5,20 @@ import simpleImportSortPlugin from "eslint-plugin-simple-import-sort";
|
|
|
5
5
|
import turboPlugin from "eslint-plugin-turbo";
|
|
6
6
|
import globals from "globals";
|
|
7
7
|
import tseslint from "typescript-eslint";
|
|
8
|
+
/**
|
|
9
|
+
* Node.js builtins without the `node:` prefix, as the first
|
|
10
|
+
* `simple-import-sort/imports` group. Exported so other variants (e.g.
|
|
11
|
+
* angular.js, which overrides this rule with Angular-specific groups) don't
|
|
12
|
+
* have to duplicate the list to keep builtins sorted first too.
|
|
13
|
+
* @type {string[]}
|
|
14
|
+
*/
|
|
15
|
+
export const NODE_BUILTIN_IMPORT_GROUP = [
|
|
16
|
+
// Node.js builtins. You could also generate this regex if you use a `.js` config.
|
|
17
|
+
// For example: `^(${require("module").builtinModules.join("|")})(/|$)`
|
|
18
|
+
// Note that if you use the `node:` prefix for Node.js builtins,
|
|
19
|
+
// you can avoid this complexity: You can simply use "^node:".
|
|
20
|
+
"^(assert|buffer|child_process|cluster|console|constants|crypto|dgram|dns|domain|events|fs|http|https|module|net|os|path|punycode|querystring|readline|repl|stream|string_decoder|sys|timers|tls|tty|url|util|vm|zlib|freelist|v8|process|async_hooks|http2|perf_hooks)(/.*|$)",
|
|
21
|
+
];
|
|
8
22
|
/**
|
|
9
23
|
* @typedef {object} BaseConfigOptions
|
|
10
24
|
* @property {boolean} [prettier=true] - Append eslint-config-prettier at the
|
|
@@ -18,14 +32,56 @@ import tseslint from "typescript-eslint";
|
|
|
18
32
|
* @property {boolean} [turbo=true] - Enable eslint-plugin-turbo's
|
|
19
33
|
* `no-undeclared-env-vars` rule. Only relevant inside a Turborepo; set to
|
|
20
34
|
* `false` for a standalone project.
|
|
35
|
+
* @property {boolean} [snakeCase=false] - Also accept `snake_case` variable
|
|
36
|
+
* names in `@typescript-eslint/naming-convention` — for code that
|
|
37
|
+
* destructures rows straight from a SQL database (e.g. Supabase), whose
|
|
38
|
+
* columns are snake_case.
|
|
39
|
+
*/
|
|
40
|
+
/**
|
|
41
|
+
* Builds the `@typescript-eslint/naming-convention` rule entry. Exported so
|
|
42
|
+
* variants that loosen it (react.js accepts PascalCase components) stay in
|
|
43
|
+
* sync with the `snakeCase` option instead of redeclaring the whole list.
|
|
44
|
+
*
|
|
45
|
+
* @param {object} [options]
|
|
46
|
+
* @param {boolean} [options.snakeCase=false] - See {@link BaseConfigOptions}.
|
|
47
|
+
* @param {boolean} [options.react=false] - Accept PascalCase for `const`
|
|
48
|
+
* variables and functions (React components).
|
|
49
|
+
* @returns {import("eslint").Linter.RuleEntry}
|
|
21
50
|
*/
|
|
51
|
+
export function createNamingConventionRule({ snakeCase = false, react = false, } = {}) {
|
|
52
|
+
const snake = snakeCase ? ["snake_case"] : [];
|
|
53
|
+
const pascal = react ? ["PascalCase"] : [];
|
|
54
|
+
return [
|
|
55
|
+
"error",
|
|
56
|
+
// https://typescript-eslint.io/rules/naming-convention
|
|
57
|
+
{
|
|
58
|
+
selector: "variable",
|
|
59
|
+
format: ["camelCase", ...snake],
|
|
60
|
+
leadingUnderscore: "allow",
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
selector: "variable",
|
|
64
|
+
modifiers: ["const"],
|
|
65
|
+
format: ["camelCase", "UPPER_CASE", ...pascal, ...snake],
|
|
66
|
+
leadingUnderscore: "allow",
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
selector: "function",
|
|
70
|
+
format: ["camelCase", ...pascal],
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
selector: "typeLike",
|
|
74
|
+
format: ["PascalCase"],
|
|
75
|
+
},
|
|
76
|
+
];
|
|
77
|
+
}
|
|
22
78
|
/**
|
|
23
79
|
* Builds a shared ESLint configuration for the repository.
|
|
24
80
|
*
|
|
25
81
|
* @param {BaseConfigOptions} [options]
|
|
26
82
|
* @returns {import("eslint").Linter.Config[]}
|
|
27
83
|
*/
|
|
28
|
-
export function createBaseConfig({ prettier = true, strict = true, turbo = true, } = {}) {
|
|
84
|
+
export function createBaseConfig({ prettier = true, strict = true, turbo = true, snakeCase = false, } = {}) {
|
|
29
85
|
return defineConfig([
|
|
30
86
|
eslint.configs.recommended,
|
|
31
87
|
strict ? tseslint.configs.strictTypeChecked : tseslint.configs.recommended,
|
|
@@ -33,6 +89,7 @@ export function createBaseConfig({ prettier = true, strict = true, turbo = true,
|
|
|
33
89
|
{
|
|
34
90
|
ignores: [
|
|
35
91
|
"dist/**",
|
|
92
|
+
"coverage/**",
|
|
36
93
|
"storybook-static/**",
|
|
37
94
|
"postcss.config.cjs",
|
|
38
95
|
"postcss.config.mjs",
|
|
@@ -72,13 +129,7 @@ export function createBaseConfig({ prettier = true, strict = true, turbo = true,
|
|
|
72
129
|
"error",
|
|
73
130
|
{
|
|
74
131
|
groups: [
|
|
75
|
-
|
|
76
|
-
// For example: `^(${require("module").builtinModules.join("|")})(/|$)`
|
|
77
|
-
// Note that if you use the `node:` prefix for Node.js builtins,
|
|
78
|
-
// you can avoid this complexity: You can simply use "^node:".
|
|
79
|
-
[
|
|
80
|
-
"^(assert|buffer|child_process|cluster|console|constants|crypto|dgram|dns|domain|events|fs|http|https|module|net|os|path|punycode|querystring|readline|repl|stream|string_decoder|sys|timers|tls|tty|url|util|vm|zlib|freelist|v8|process|async_hooks|http2|perf_hooks)(/.*|$)",
|
|
81
|
-
],
|
|
132
|
+
NODE_BUILTIN_IMPORT_GROUP,
|
|
82
133
|
// Packages. `react` related packages come first.
|
|
83
134
|
["^react", "^@?\\w"],
|
|
84
135
|
// Internal packages.
|
|
@@ -129,29 +180,9 @@ export function createBaseConfig({ prettier = true, strict = true, turbo = true,
|
|
|
129
180
|
"error",
|
|
130
181
|
{ allowNumber: true },
|
|
131
182
|
],
|
|
132
|
-
"@typescript-eslint/naming-convention":
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
{
|
|
136
|
-
selector: "variable",
|
|
137
|
-
format: ["camelCase"],
|
|
138
|
-
leadingUnderscore: "allow",
|
|
139
|
-
},
|
|
140
|
-
{
|
|
141
|
-
selector: "variable",
|
|
142
|
-
modifiers: ["const"],
|
|
143
|
-
format: ["camelCase", "UPPER_CASE"],
|
|
144
|
-
leadingUnderscore: "allow",
|
|
145
|
-
},
|
|
146
|
-
{
|
|
147
|
-
selector: "function",
|
|
148
|
-
format: ["camelCase"],
|
|
149
|
-
},
|
|
150
|
-
{
|
|
151
|
-
selector: "typeLike",
|
|
152
|
-
format: ["PascalCase"],
|
|
153
|
-
},
|
|
154
|
-
],
|
|
183
|
+
"@typescript-eslint/naming-convention": createNamingConventionRule({
|
|
184
|
+
snakeCase,
|
|
185
|
+
}),
|
|
155
186
|
},
|
|
156
187
|
},
|
|
157
188
|
prettier ? eslintConfigPrettier : [],
|
package/dist/nextjs.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nextjs.d.ts","sourceRoot":"","sources":["../src/nextjs.js"],"names":[],"mappings":"AAKA;;;;;;;KAOK;AACL,6CAHW,OAAO,WAAW,EAAE,iBAAiB,GAAG,OAAO,YAAY,EAAE,kBAAkB,GAC7E,OAAO,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"nextjs.d.ts","sourceRoot":"","sources":["../src/nextjs.js"],"names":[],"mappings":"AAKA;;;;;;;KAOK;AACL,6CAHW,OAAO,WAAW,EAAE,iBAAiB,GAAG,OAAO,YAAY,EAAE,kBAAkB,GAC7E,OAAO,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,CAsD5C;AAED;;;;;KAKK;AACL,2BAFU,OAAO,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,CAEO"}
|
package/dist/nextjs.js
CHANGED
|
@@ -12,7 +12,10 @@ import { createReactConfig } from "./react.js";
|
|
|
12
12
|
export function createNextJsConfig(options) {
|
|
13
13
|
return defineConfig([
|
|
14
14
|
{
|
|
15
|
-
ignores
|
|
15
|
+
// Same default ignores as eslint-config-next: build output
|
|
16
|
+
// (`.next/`, and `out/`/`build/` for static exports) and the generated
|
|
17
|
+
// `next-env.d.ts`.
|
|
18
|
+
ignores: [".next/**", "out/**", "build/**", "next-env.d.ts"],
|
|
16
19
|
},
|
|
17
20
|
...createReactConfig(options),
|
|
18
21
|
{
|
package/dist/react.d.ts
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
* @param {import("./base.js").BaseConfigOptions & ReactConfigOptions} [options]
|
|
22
22
|
* @returns {import("eslint").Linter.Config[]}
|
|
23
23
|
*/
|
|
24
|
-
export function createReactConfig({ a11y, i18n, testingLibrary, ...options }?: import("./base.js").BaseConfigOptions & ReactConfigOptions): import("eslint").Linter.Config[];
|
|
24
|
+
export function createReactConfig({ a11y, i18n, testingLibrary, snakeCase, ...options }?: import("./base.js").BaseConfigOptions & ReactConfigOptions): import("eslint").Linter.Config[];
|
|
25
25
|
/**
|
|
26
26
|
* A custom ESLint configuration for libraries that use React, with the
|
|
27
27
|
* default options. Use `createReactConfig(options)` instead to customize it.
|
package/dist/react.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react.d.ts","sourceRoot":"","sources":["../src/react.js"],"names":[],"mappings":"AAqBA;;;;;;;;;;;;;;;;GAgBG;AAEH;;;;;GAKG;AACH
|
|
1
|
+
{"version":3,"file":"react.d.ts","sourceRoot":"","sources":["../src/react.js"],"names":[],"mappings":"AAqBA;;;;;;;;;;;;;;;;GAgBG;AAEH;;;;;GAKG;AACH,0FAHW,OAAO,WAAW,EAAE,iBAAiB,GAAG,kBAAkB,GACxD,OAAO,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,CA8E5C;AAED;;;;8CAI8C;AAC9C,0BADU,OAAO,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,CACK"}
|
package/dist/react.js
CHANGED
|
@@ -8,7 +8,7 @@ import pluginReactHooks from "eslint-plugin-react-hooks";
|
|
|
8
8
|
import pluginReactRefresh from "eslint-plugin-react-refresh";
|
|
9
9
|
import pluginTestingLibrary from "eslint-plugin-testing-library";
|
|
10
10
|
import globals from "globals";
|
|
11
|
-
import { createBaseConfig } from "./base.js";
|
|
11
|
+
import { createBaseConfig, createNamingConventionRule } from "./base.js";
|
|
12
12
|
/**
|
|
13
13
|
* Any file matching this is a test file, whatever runner or naming
|
|
14
14
|
* convention is used to suffix it (`.test.`, `.spec.`, `.dom.test.`...) —
|
|
@@ -39,9 +39,9 @@ const TEST_FILE_GLOBS = ["**/*.{test,spec}.{ts,tsx,js,jsx}"];
|
|
|
39
39
|
* @param {import("./base.js").BaseConfigOptions & ReactConfigOptions} [options]
|
|
40
40
|
* @returns {import("eslint").Linter.Config[]}
|
|
41
41
|
*/
|
|
42
|
-
export function createReactConfig({ a11y = true, i18n = false, testingLibrary = false, ...options } = {}) {
|
|
42
|
+
export function createReactConfig({ a11y = true, i18n = false, testingLibrary = false, snakeCase = false, ...options } = {}) {
|
|
43
43
|
return defineConfig([
|
|
44
|
-
...createBaseConfig(options),
|
|
44
|
+
...createBaseConfig({ snakeCase, ...options }),
|
|
45
45
|
a11y ? pluginJsxA11y.flatConfigs.recommended : [],
|
|
46
46
|
i18n
|
|
47
47
|
? {
|
|
@@ -102,28 +102,10 @@ export function createReactConfig({ a11y = true, i18n = false, testingLibrary =
|
|
|
102
102
|
rules: {
|
|
103
103
|
"@typescript-eslint/no-unsafe-call": "warn",
|
|
104
104
|
"@typescript-eslint/restrict-template-expressions": "warn",
|
|
105
|
-
"@typescript-eslint/naming-convention":
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
format: ["camelCase"],
|
|
110
|
-
leadingUnderscore: "allow",
|
|
111
|
-
},
|
|
112
|
-
{
|
|
113
|
-
selector: "variable",
|
|
114
|
-
modifiers: ["const"],
|
|
115
|
-
format: ["camelCase", "UPPER_CASE", "PascalCase"],
|
|
116
|
-
leadingUnderscore: "allow",
|
|
117
|
-
},
|
|
118
|
-
{
|
|
119
|
-
selector: "function",
|
|
120
|
-
format: ["camelCase", "PascalCase"],
|
|
121
|
-
},
|
|
122
|
-
{
|
|
123
|
-
selector: "typeLike",
|
|
124
|
-
format: ["PascalCase"],
|
|
125
|
-
},
|
|
126
|
-
],
|
|
105
|
+
"@typescript-eslint/naming-convention": createNamingConventionRule({
|
|
106
|
+
snakeCase,
|
|
107
|
+
react: true,
|
|
108
|
+
}),
|
|
127
109
|
},
|
|
128
110
|
},
|
|
129
111
|
]);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forthtilliath/eslint-config",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -45,15 +45,20 @@
|
|
|
45
45
|
"typescript": ">=5.0.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
+
"@angular/core": "^21.0.0",
|
|
48
49
|
"eslint": "10.7.0",
|
|
50
|
+
"rxjs": "^7.8.0",
|
|
49
51
|
"typescript": "^5.9.3",
|
|
50
|
-
"
|
|
52
|
+
"vitest": "^4.1.10",
|
|
53
|
+
"@forthtilliath/typescript-config": "0.1.0"
|
|
51
54
|
},
|
|
52
55
|
"scripts": {
|
|
53
|
-
"dev": "tsc --watch",
|
|
54
|
-
"build": "tsc",
|
|
56
|
+
"dev": "tsc --watch -p tsconfig.build.json",
|
|
57
|
+
"build": "tsc -p tsconfig.build.json",
|
|
55
58
|
"clean": "rm -rf dist",
|
|
56
59
|
"check-types": "tsc --noEmit",
|
|
57
|
-
"lint": "eslint . --max-warnings 0"
|
|
60
|
+
"lint": "eslint . --max-warnings 0",
|
|
61
|
+
"test": "vitest run",
|
|
62
|
+
"test:watch": "vitest"
|
|
58
63
|
}
|
|
59
64
|
}
|