eslint-config-typed 2.3.2 → 3.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 +29 -26
- package/dist/configs/plugins.d.mts +1 -1
- package/dist/configs/plugins.d.mts.map +1 -1
- package/dist/configs/plugins.mjs +2 -0
- package/dist/configs/plugins.mjs.map +1 -1
- package/dist/configs/react-base.d.mts.map +1 -1
- package/dist/configs/react-base.mjs +2 -0
- package/dist/configs/react-base.mjs.map +1 -1
- package/dist/entry-point.d.mts +1 -1
- package/dist/entry-point.d.mts.map +1 -1
- package/dist/entry-point.mjs +2 -1
- package/dist/entry-point.mjs.map +1 -1
- package/dist/index.mjs +3 -1
- package/dist/index.mjs.map +1 -1
- package/dist/plugins/index.d.mts +1 -0
- package/dist/plugins/index.d.mts.map +1 -1
- package/dist/plugins/index.mjs +1 -0
- package/dist/plugins/index.mjs.map +1 -1
- package/dist/plugins/react-coding-style/index.d.mts +2 -0
- package/dist/plugins/react-coding-style/index.d.mts.map +1 -0
- package/dist/plugins/react-coding-style/index.mjs +2 -0
- package/dist/plugins/react-coding-style/index.mjs.map +1 -0
- package/dist/plugins/react-coding-style/plugin.d.mts +3 -0
- package/dist/plugins/react-coding-style/plugin.d.mts.map +1 -0
- package/dist/plugins/react-coding-style/plugin.mjs +8 -0
- package/dist/plugins/react-coding-style/plugin.mjs.map +1 -0
- package/dist/plugins/react-coding-style/rules/ban-use-imperative-handle-hook.d.mts +5 -0
- package/dist/plugins/react-coding-style/rules/ban-use-imperative-handle-hook.d.mts.map +1 -0
- package/dist/plugins/react-coding-style/rules/ban-use-imperative-handle-hook.mjs +29 -0
- package/dist/plugins/react-coding-style/rules/ban-use-imperative-handle-hook.mjs.map +1 -0
- package/dist/plugins/react-coding-style/rules/component-name.d.mts +10 -0
- package/dist/plugins/react-coding-style/rules/component-name.d.mts.map +1 -0
- package/dist/plugins/react-coding-style/rules/component-name.mjs +78 -0
- package/dist/plugins/react-coding-style/rules/component-name.mjs.map +1 -0
- package/dist/plugins/react-coding-style/rules/component-var-type-annotation.d.mts +5 -0
- package/dist/plugins/react-coding-style/rules/component-var-type-annotation.d.mts.map +1 -0
- package/dist/plugins/react-coding-style/rules/component-var-type-annotation.mjs +41 -0
- package/dist/plugins/react-coding-style/rules/component-var-type-annotation.mjs.map +1 -0
- package/dist/plugins/react-coding-style/rules/import-style.d.mts +5 -0
- package/dist/plugins/react-coding-style/rules/import-style.d.mts.map +1 -0
- package/dist/plugins/react-coding-style/rules/import-style.mjs +45 -0
- package/dist/plugins/react-coding-style/rules/import-style.mjs.map +1 -0
- package/dist/plugins/react-coding-style/rules/index.d.mts +2 -0
- package/dist/plugins/react-coding-style/rules/index.d.mts.map +1 -0
- package/dist/plugins/react-coding-style/rules/index.mjs +2 -0
- package/dist/plugins/react-coding-style/rules/index.mjs.map +1 -0
- package/dist/plugins/react-coding-style/rules/props-type-annotation-style.d.mts +5 -0
- package/dist/plugins/react-coding-style/rules/props-type-annotation-style.d.mts.map +1 -0
- package/dist/plugins/react-coding-style/rules/props-type-annotation-style.mjs +44 -0
- package/dist/plugins/react-coding-style/rules/props-type-annotation-style.mjs.map +1 -0
- package/dist/plugins/react-coding-style/rules/react-memo-props-argument-name.d.mts +5 -0
- package/dist/plugins/react-coding-style/rules/react-memo-props-argument-name.d.mts.map +1 -0
- package/dist/plugins/react-coding-style/rules/react-memo-props-argument-name.mjs +55 -0
- package/dist/plugins/react-coding-style/rules/react-memo-props-argument-name.mjs.map +1 -0
- package/dist/plugins/react-coding-style/rules/react-memo-type-parameter.d.mts +5 -0
- package/dist/plugins/react-coding-style/rules/react-memo-type-parameter.d.mts.map +1 -0
- package/dist/plugins/react-coding-style/rules/react-memo-type-parameter.mjs +78 -0
- package/dist/plugins/react-coding-style/rules/react-memo-type-parameter.mjs.map +1 -0
- package/dist/plugins/react-coding-style/rules/rules.d.mts +14 -0
- package/dist/plugins/react-coding-style/rules/rules.d.mts.map +1 -0
- package/dist/plugins/react-coding-style/rules/rules.mjs +22 -0
- package/dist/plugins/react-coding-style/rules/rules.mjs.map +1 -0
- package/dist/plugins/react-coding-style/rules/shared.d.mts +5 -0
- package/dist/plugins/react-coding-style/rules/shared.d.mts.map +1 -0
- package/dist/plugins/react-coding-style/rules/shared.mjs +22 -0
- package/dist/plugins/react-coding-style/rules/shared.mjs.map +1 -0
- package/dist/plugins/react-coding-style/rules/use-memo-hooks-style.d.mts +5 -0
- package/dist/plugins/react-coding-style/rules/use-memo-hooks-style.d.mts.map +1 -0
- package/dist/plugins/react-coding-style/rules/use-memo-hooks-style.mjs +42 -0
- package/dist/plugins/react-coding-style/rules/use-memo-hooks-style.mjs.map +1 -0
- package/dist/rules/eslint-react-coding-style-rules.d.mts +13 -0
- package/dist/rules/eslint-react-coding-style-rules.d.mts.map +1 -0
- package/dist/rules/eslint-react-coding-style-rules.mjs +13 -0
- package/dist/rules/eslint-react-coding-style-rules.mjs.map +1 -0
- package/dist/rules/eslint-rules.d.mts +0 -57
- package/dist/rules/eslint-rules.d.mts.map +1 -1
- package/dist/rules/eslint-rules.mjs +1 -151
- package/dist/rules/eslint-rules.mjs.map +1 -1
- package/dist/rules/index.d.mts +1 -0
- package/dist/rules/index.d.mts.map +1 -1
- package/dist/rules/index.mjs +2 -1
- package/dist/rules/index.mjs.map +1 -1
- package/dist/types/define-known-rules.d.mts +2 -2
- package/dist/types/define-known-rules.d.mts.map +1 -1
- package/dist/types/define-known-rules.mjs.map +1 -1
- package/dist/types/rules/eslint-react-coding-style-rules.d.mts +148 -0
- package/dist/types/rules/eslint-react-coding-style-rules.d.mts.map +1 -0
- package/dist/types/rules/eslint-react-coding-style-rules.mjs +2 -0
- package/dist/types/rules/eslint-react-coding-style-rules.mjs.map +1 -0
- package/dist/types/rules/index.d.mts +1 -0
- package/dist/types/rules/index.d.mts.map +1 -1
- package/package.json +1 -5
- package/src/configs/plugins.mts +3 -0
- package/src/configs/react-base.mts +2 -0
- package/src/entry-point.mts +2 -1
- package/src/plugins/index.mts +1 -0
- package/src/plugins/react-coding-style/README.md +36 -0
- package/src/plugins/react-coding-style/index.mts +1 -0
- package/src/plugins/react-coding-style/plugin.mts +6 -0
- package/src/plugins/react-coding-style/rules/ban-use-imperative-handle-hook.mts +31 -0
- package/src/plugins/react-coding-style/rules/ban-use-imperative-handle-hook.test.mts +40 -0
- package/src/plugins/react-coding-style/rules/component-name.mts +93 -0
- package/src/plugins/react-coding-style/rules/component-name.test.mts +72 -0
- package/src/plugins/react-coding-style/rules/component-var-type-annotation.mts +54 -0
- package/src/plugins/react-coding-style/rules/component-var-type-annotation.test.mts +62 -0
- package/src/plugins/react-coding-style/rules/import-style.mts +53 -0
- package/src/plugins/react-coding-style/rules/import-style.test.mts +63 -0
- package/src/plugins/react-coding-style/rules/index.mts +1 -0
- package/src/plugins/react-coding-style/rules/props-type-annotation-style.mts +59 -0
- package/src/plugins/react-coding-style/rules/props-type-annotation-style.test.mts +71 -0
- package/src/plugins/react-coding-style/rules/react-memo-props-argument-name.mts +70 -0
- package/src/plugins/react-coding-style/rules/react-memo-props-argument-name.test.mts +56 -0
- package/src/plugins/react-coding-style/rules/react-memo-type-parameter.mts +102 -0
- package/src/plugins/react-coding-style/rules/react-memo-type-parameter.test.mts +98 -0
- package/src/plugins/react-coding-style/rules/rules.mts +20 -0
- package/src/plugins/react-coding-style/rules/shared.mts +33 -0
- package/src/plugins/react-coding-style/rules/use-memo-hooks-style.mts +52 -0
- package/src/plugins/react-coding-style/rules/use-memo-hooks-style.test.mts +72 -0
- package/src/rules/eslint-react-coding-style-rules.mts +12 -0
- package/src/rules/eslint-rules.mts +0 -181
- package/src/rules/index.mts +1 -0
- package/src/types/define-known-rules.mts +2 -0
- package/src/types/rules/eslint-react-coding-style-rules.mts +166 -0
- package/src/types/rules/index.mts +1 -0
package/README.md
CHANGED
|
@@ -401,31 +401,32 @@ These functions return arrays of ESLint flat configurations:
|
|
|
401
401
|
|
|
402
402
|
Pre-configured rule sets that can be imported and customized:
|
|
403
403
|
|
|
404
|
-
| Rule set | Plugin name | Description
|
|
405
|
-
| :----------------------------------------- | :------------------------------------- |
|
|
406
|
-
| **`eslintRules`** | (eslint) | Core ESLint rules
|
|
407
|
-
| **`typescriptEslintRules`** | `@typescript-eslint/eslint-plugin` | TypeScript-specific ESLint rules
|
|
408
|
-
| **`eslintFunctionalRules`** | `eslint-plugin-functional` | Functional programming style rules
|
|
409
|
-
| **`eslintTotalFunctionsRules`** | `eslint-plugin-total-functions` | Functional programming style rules
|
|
410
|
-
| **`eslintUnicornRules`** | `eslint-plugin-unicorn` | Unicorn plugin rules for better code
|
|
411
|
-
| **`eslintArrayFuncRules`** | `eslint-plugin-array-func` | Array function preference rules
|
|
412
|
-
| **`eslintPreferArrowFunctionRules`** | `eslint-plugin-prefer-arrow-functions` | Arrow function preference rules
|
|
413
|
-
| **`eslintPluginSortDestructureKeysRules`** | `eslint-plugin-sort-destructure-keys` | Object destructuring rules
|
|
414
|
-
| **`eslintPromiseRules`** | `eslint-plugin-promise` | Promise handling rules
|
|
415
|
-
| **`eslintImportsRules`** | `eslint-plugin-import` | Import/export rules
|
|
416
|
-
| **`eslintSecurityRules`** | `eslint-plugin-security` | Security best practices
|
|
417
|
-
| **`eslintTreeShakableRules`** | `eslint-plugin-tree-shakable` | Tree-shaking optimization rules
|
|
418
|
-
| **`eslintReactRules`** | `eslint-plugin-react` | React-specific rules
|
|
419
|
-
| **`eslintReactHooksRules`** | `eslint-plugin-react-hooks` | React Hooks rules
|
|
420
|
-
| **`eslintReactPerfRules`** | `eslint-plugin-react-perf` | React performance optimization rules
|
|
421
|
-
| **`eslintReactRefreshRules`** | `eslint-plugin-react-refresh` | React Refresh (HMR) rules
|
|
422
|
-
| **`
|
|
423
|
-
| **`
|
|
424
|
-
| **`
|
|
425
|
-
| **`
|
|
426
|
-
| **`
|
|
427
|
-
| **`
|
|
428
|
-
| **`
|
|
404
|
+
| Rule set | Plugin name | Description |
|
|
405
|
+
| :----------------------------------------- | :------------------------------------- | :-------------------------------------- |
|
|
406
|
+
| **`eslintRules`** | (eslint) | Core ESLint rules |
|
|
407
|
+
| **`typescriptEslintRules`** | `@typescript-eslint/eslint-plugin` | TypeScript-specific ESLint rules |
|
|
408
|
+
| **`eslintFunctionalRules`** | `eslint-plugin-functional` | Functional programming style rules |
|
|
409
|
+
| **`eslintTotalFunctionsRules`** | `eslint-plugin-total-functions` | Functional programming style rules |
|
|
410
|
+
| **`eslintUnicornRules`** | `eslint-plugin-unicorn` | Unicorn plugin rules for better code |
|
|
411
|
+
| **`eslintArrayFuncRules`** | `eslint-plugin-array-func` | Array function preference rules |
|
|
412
|
+
| **`eslintPreferArrowFunctionRules`** | `eslint-plugin-prefer-arrow-functions` | Arrow function preference rules |
|
|
413
|
+
| **`eslintPluginSortDestructureKeysRules`** | `eslint-plugin-sort-destructure-keys` | Object destructuring rules |
|
|
414
|
+
| **`eslintPromiseRules`** | `eslint-plugin-promise` | Promise handling rules |
|
|
415
|
+
| **`eslintImportsRules`** | `eslint-plugin-import` | Import/export rules |
|
|
416
|
+
| **`eslintSecurityRules`** | `eslint-plugin-security` | Security best practices |
|
|
417
|
+
| **`eslintTreeShakableRules`** | `eslint-plugin-tree-shakable` | Tree-shaking optimization rules |
|
|
418
|
+
| **`eslintReactRules`** | `eslint-plugin-react` | React-specific rules |
|
|
419
|
+
| **`eslintReactHooksRules`** | `eslint-plugin-react-hooks` | React Hooks rules |
|
|
420
|
+
| **`eslintReactPerfRules`** | `eslint-plugin-react-perf` | React performance optimization rules |
|
|
421
|
+
| **`eslintReactRefreshRules`** | `eslint-plugin-react-refresh` | React Refresh (HMR) rules |
|
|
422
|
+
| **`eslintReactCodingStyleRules`** | `eslint-plugin-react-coding-style` | Opinionated React component style rules |
|
|
423
|
+
| **`eslintJsxA11yRules`** | `eslint-plugin-jsx-a11y` | Accessibility rules for JSX |
|
|
424
|
+
| **`eslintVitestRules`** | `eslint-plugin-vitest` | Vitest-specific rules |
|
|
425
|
+
| **`eslintJestRules`** | `eslint-plugin-jest` | Jest-specific rules |
|
|
426
|
+
| **`eslintTestingLibraryRules`** | `eslint-plugin-testing-library` | Testing Library rules |
|
|
427
|
+
| **`eslintPlaywrightRules`** | `eslint-plugin-playwright` | Playwright-specific rules |
|
|
428
|
+
| **`eslintCypressRules`** | `eslint-plugin-cypress` | Cypress-specific rules |
|
|
429
|
+
| **`eslintPluginRules`** | `eslint-plugin-eslint-plugin` | eslint-plugin development rules |
|
|
429
430
|
|
|
430
431
|
### Exported Pre-configured Rule Options
|
|
431
432
|
|
|
@@ -434,7 +435,6 @@ Pre-configured rule sets that can be imported and customized:
|
|
|
434
435
|
| **`restrictedGlobals`** | `no-restricted-globals` | Array of restricted global variables |
|
|
435
436
|
| **`restrictedGlobalsForBrowser`** | `no-restricted-globals` | Browser-environment-specific restricted globals |
|
|
436
437
|
| **`restrictedSyntax`** | `no-restricted-syntax` | Disallows the `in` operator, `Object.prototype.hasOwnProperty.call` (suggests using `Object.hasOwn`), and `new Array(*)` syntax (suggests using `Array.from`) |
|
|
437
|
-
| **`restrictedSyntaxForReact`** | `no-restricted-syntax` | Rule set to restrict React component styling |
|
|
438
438
|
|
|
439
439
|
You can find other pre-configured rule options by traversing the pre-defined rules object like this:
|
|
440
440
|
|
|
@@ -449,6 +449,9 @@ The shape of the rule option varies depending on the rule, so please check the c
|
|
|
449
449
|
- `eslint-plugin-total-functions` with support for Flat Config
|
|
450
450
|
- **`eslintPluginTreeShakable`**
|
|
451
451
|
- `eslint-plugin-tree-shakable` with support for Flat Config
|
|
452
|
+
- **`eslintPluginReactCodingStyle`**
|
|
453
|
+
- Custom ESLint plugin that codifies this repository's React memo component conventions (namespace imports, `React.memo<Props>`, arrow props naming, etc.). See [`src/plugins/react-coding-style/README.md`](src/plugins/react-coding-style/README.md) for the rationale and examples.
|
|
454
|
+
- Provides rules such as `react-coding-style/import-style`, `react-coding-style/component-var-type-annotation`, `react-coding-style/react-memo-type-parameter`, `react-coding-style/react-memo-props-argument-name`, `react-coding-style/props-type-annotation-style`, and `react-coding-style/react-hooks-definition-style`.
|
|
452
455
|
- **`eslintPluginCustom`** - Custom ESLint plugin with additional rules
|
|
453
456
|
- Currently, this plugin only provides the `custom/no-restricted-syntax` rule (which duplicates ESLint's `no-restricted-syntax` rule).
|
|
454
457
|
- Can be used to set the error level to `error` or `warn` as needed.
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { type ESLintPlugin } from '../types/index.mjs';
|
|
2
|
-
export declare const plugins: Record<'@typescript-eslint' | 'array-func' | 'cypress' | 'playwright' | 'functional' | 'import' | 'jest' | 'vitest' | 'jsx-a11y' | 'prefer-arrow-functions' | 'promise' | 'react' | 'react-hooks' | 'react-refresh' | 'react-perf' | 'security' | 'strict-dependencies' | 'testing-library' | 'total-functions' | 'unicorn' | 'sort-destructure-keys' | 'tree-shakable' | 'eslint-plugin' | 'custom', Omit<ESLintPlugin, 'configs'>>;
|
|
2
|
+
export declare const plugins: Record<'@typescript-eslint' | 'array-func' | 'cypress' | 'playwright' | 'functional' | 'import' | 'jest' | 'vitest' | 'jsx-a11y' | 'prefer-arrow-functions' | 'promise' | 'react' | 'react-hooks' | 'react-refresh' | 'react-perf' | 'react-coding-style' | 'security' | 'strict-dependencies' | 'testing-library' | 'total-functions' | 'unicorn' | 'sort-destructure-keys' | 'tree-shakable' | 'eslint-plugin' | 'custom', Omit<ESLintPlugin, 'configs'>>;
|
|
3
3
|
//# sourceMappingURL=plugins.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugins.d.mts","sourceRoot":"","sources":["../../src/configs/plugins.mts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"plugins.d.mts","sourceRoot":"","sources":["../../src/configs/plugins.mts"],"names":[],"mappings":"AAwDA,OAAO,EAAE,KAAK,YAAY,EAAmB,MAAM,oBAAoB,CAAC;AAExE,eAAO,MAAM,OAAO,EAAE,MAAM,CACxB,oBAAoB,GACpB,YAAY,GACZ,SAAS,GACT,YAAY,GACZ,YAAY,GACZ,QAAQ,GACR,MAAM,GACN,QAAQ,GACR,UAAU,GACV,wBAAwB,GACxB,SAAS,GACT,OAAO,GACP,aAAa,GACb,eAAe,GACf,YAAY,GACZ,oBAAoB,GACpB,UAAU,GACV,qBAAqB,GACrB,iBAAiB,GACjB,iBAAiB,GACjB,SAAS,GACT,uBAAuB,GACvB,eAAe,GACf,eAAe,GACf,QAAQ,EACV,IAAI,CAAC,YAAY,EAAE,SAAS,CAAC,CAkCW,CAAC"}
|
package/dist/configs/plugins.mjs
CHANGED
|
@@ -19,6 +19,7 @@ import eslintPluginReactPerf from 'eslint-plugin-react-perf';
|
|
|
19
19
|
import eslintPluginJsxA11y from 'eslint-plugin-jsx-a11y';
|
|
20
20
|
import eslintPluginEslintPlugin from 'eslint-plugin-eslint-plugin';
|
|
21
21
|
import { eslintPluginCustom } from '../plugins/custom/custom.mjs';
|
|
22
|
+
import { eslintPluginReactCodingStyle } from '../plugins/react-coding-style/plugin.mjs';
|
|
22
23
|
import { eslintPluginStrictDependencies } from '../plugins/strict-dependencies/plugin.mjs';
|
|
23
24
|
import { eslintPluginTotalFunctions } from '../plugins/total-functions/plugin.mjs';
|
|
24
25
|
import { eslintPluginTreeShakable } from '../plugins/tree-shakable/plugin.mjs';
|
|
@@ -46,6 +47,7 @@ const plugins = {
|
|
|
46
47
|
'react-refresh': eslintPluginReactRefresh,
|
|
47
48
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
48
49
|
'react-perf': eslintPluginReactPerf,
|
|
50
|
+
'react-coding-style': eslintPluginReactCodingStyle,
|
|
49
51
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
50
52
|
security: eslintPluginSecurity,
|
|
51
53
|
'strict-dependencies': eslintPluginStrictDependencies,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugins.mjs","sources":["../../src/configs/plugins.mts"],"sourcesContent":[null],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"plugins.mjs","sources":["../../src/configs/plugins.mts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA0DO,MAAM,OAAO,GA2BhB;AACF,IAAA,oBAAoB,EAAE,gBAAgB;;AAEtC,IAAA,YAAY,EAAE,qBAAqB;AACnC,IAAA,OAAO,EAAE,mBAAmB;AAC5B,IAAA,UAAU,EAAE,sBAAsB;AAClC,IAAA,UAAU,EAAE,sBAAsB;;AAElC,IAAA,uBAAuB,EAAE,+BAA+B;AACxD,IAAA,MAAM,EAAE,kBAAkB;AAC1B,IAAA,IAAI,EAAE,gBAAgB;AACtB,IAAA,MAAM,EAAE,kBAAkB;;AAE1B,IAAA,UAAU,EAAE,mBAAmB;AAC/B,IAAA,wBAAwB,EAAE,gCAAgC;;AAE1D,IAAA,OAAO,EAAE,mBAAmB;AAC5B,IAAA,KAAK,EAAE,iBAAiB;;AAExB,IAAA,aAAa,EAAE,sBAAiD;AAChE,IAAA,eAAe,EAAE,wBAAwB;;AAEzC,IAAA,YAAY,EAAE,qBAAqB;AACnC,IAAA,oBAAoB,EAAE,4BAA4B;;AAElD,IAAA,QAAQ,EAAE,oBAAoB;AAC9B,IAAA,qBAAqB,EAAE,8BAA8B;AACrD,IAAA,iBAAiB,EAAE,0BAA0B;AAC7C,IAAA,iBAAiB,EAAE,0BAA0B;AAC7C,IAAA,OAAO,EAAE,mBAAmB;AAC5B,IAAA,eAAe,EAAE,wBAAwB;AACzC,IAAA,eAAe,EAAE,wBAAwB;AACzC,IAAA,MAAM,EAAE,kBAAkB;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react-base.d.mts","sourceRoot":"","sources":["../../src/configs/react-base.mts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"react-base.d.mts","sourceRoot":"","sources":["../../src/configs/react-base.mts"],"names":[],"mappings":"AAQA,OAAO,EAAoB,KAAK,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAGvE,eAAO,MAAM,wBAAwB,GACnC,QAAQ,SAAS,MAAM,EAAE,KACxB,SAAS,UAAU,EAqBV,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { defineKnownRules } from '../types/define-known-rules.mjs';
|
|
2
2
|
import { eslintJsxA11yRules } from '../rules/eslint-jsx-a11y-rules.mjs';
|
|
3
|
+
import { eslintReactCodingStyleRules } from '../rules/eslint-react-coding-style-rules.mjs';
|
|
3
4
|
import { eslintReactHooksRules } from '../rules/eslint-react-hooks-rules.mjs';
|
|
4
5
|
import { eslintReactPerfRules } from '../rules/eslint-react-perf-rules.mjs';
|
|
5
6
|
import { eslintReactRefreshRules } from '../rules/eslint-react-refresh-rules.mjs';
|
|
@@ -24,6 +25,7 @@ const eslintConfigForReactBase = (files) => [
|
|
|
24
25
|
...eslintReactRefreshRules,
|
|
25
26
|
...eslintJsxA11yRules,
|
|
26
27
|
...eslintReactPerfRules,
|
|
28
|
+
...eslintReactCodingStyleRules,
|
|
27
29
|
}),
|
|
28
30
|
},
|
|
29
31
|
];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react-base.mjs","sources":["../../src/configs/react-base.mts"],"sourcesContent":[null],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"react-base.mjs","sources":["../../src/configs/react-base.mts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;;MAWa,wBAAwB,GAAG,CACtC,KAAyB,KAEzB;IACE,sBAAsB,CAAC,KAAK,CAAC;AAC7B,IAAA;AACE,QAAA,IAAI,KAAK,KAAK,SAAS,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC;AACzC,QAAA,eAAe,EAAE;AACf,YAAA,aAAa,EAAE;AACb,gBAAA,YAAY,EAAE;AACZ,oBAAA,GAAG,EAAE,IAAI;AACV,iBAAA;AACF,aAAA;AACF,SAAA;QACD,KAAK,EAAE,gBAAgB,CAAC;AACtB,YAAA,GAAG,gBAAgB;AACnB,YAAA,GAAG,qBAAqB;AACxB,YAAA,GAAG,uBAAuB;AAC1B,YAAA,GAAG,kBAAkB;AACrB,YAAA,GAAG,oBAAoB;AACvB,YAAA,GAAG,2BAA2B;SAC/B,CAAC;AACH,KAAA;;;;;"}
|
package/dist/entry-point.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { eslintConfigForTypeScriptWithoutRules, eslintConfigForTypeScript, eslintConfigForBrowser, eslintConfigForNodeJs, eslintConfigForReact, eslintConfigForPreact, eslintConfigForVitest, eslintConfigForJest, eslintConfigForPlaywright, eslintConfigForCypress, eslintConfigForTestingLibrary, eslintRules, typescriptEslintRules, eslintFunctionalRules, eslintTotalFunctionsRules, eslintUnicornRules, eslintArrayFuncRules, eslintPreferArrowFunctionRules, eslintPluginSortDestructureKeysRules, eslintImportsRules, eslintPromiseRules, eslintSecurityRules, eslintTreeShakableRules, eslintReactRules, eslintReactHooksRules, eslintReactPerfRules, eslintReactRefreshRules, eslintVitestRules, eslintJestRules, eslintJsxA11yRules, eslintTestingLibraryRules, eslintCypressRules, eslintPlaywrightRules, eslintPluginRules, restrictedGlobals, restrictedGlobalsForBrowser, restrictedSyntax,
|
|
1
|
+
export { eslintConfigForTypeScriptWithoutRules, eslintConfigForTypeScript, eslintConfigForBrowser, eslintConfigForNodeJs, eslintConfigForReact, eslintConfigForPreact, eslintConfigForVitest, eslintConfigForJest, eslintConfigForPlaywright, eslintConfigForCypress, eslintConfigForTestingLibrary, eslintRules, typescriptEslintRules, eslintFunctionalRules, eslintTotalFunctionsRules, eslintUnicornRules, eslintArrayFuncRules, eslintPreferArrowFunctionRules, eslintPluginSortDestructureKeysRules, eslintImportsRules, eslintPromiseRules, eslintSecurityRules, eslintTreeShakableRules, eslintReactRules, eslintReactHooksRules, eslintReactPerfRules, eslintReactRefreshRules, eslintVitestRules, eslintJestRules, eslintJsxA11yRules, eslintTestingLibraryRules, eslintCypressRules, eslintPlaywrightRules, eslintPluginRules, restrictedGlobals, restrictedGlobalsForBrowser, restrictedSyntax, eslintPluginCustom, eslintPluginReactCodingStyle, eslintPluginTotalFunctions, eslintPluginTreeShakable, defineConfig, defineKnownRules, withDefaultOption, plugins, type EslintRules, type EslintRulesOption, type TypeScriptEslintRules, type TypeScriptEslintRulesOption, type EslintFunctionalRules, type EslintFunctionalRulesOption, type EslintTotalFunctionsRules, type EslintUnicornRules, type EslintUnicornRulesOption, type EslintArrayFuncRules, type EslintPreferArrowFunctionRules, type EslintPreferArrowFunctionRulesOption, type EslintPluginSortDestructureKeysRules, type EslintPluginSortDestructureKeysRulesOption, type EslintPromiseRules, type EslintPromiseRulesOption, type EslintImportsRules, type EslintImportsRulesOption, type EslintStrictDependenciesRules, type EslintStrictDependenciesRulesOption, type EslintReactCodingStyleRules, type EslintSecurityRules, type EslintTreeShakableRules, type EslintReactRules, type EslintReactRulesOption, type EslintReactHooksRules, type EslintReactHooksRulesOption, type EslintReactPerfRules, type EslintReactPerfRulesOption, type EslintReactRefreshRules, type EslintReactRefreshRulesOption, type EslintJsxA11yRules, type EslintJsxA11yRulesOption, type EslintVitestRules, type EslintVitestRulesOption, type EslintJestRules, type EslintJestRulesOption, type EslintPlaywrightRules, type EslintPlaywrightRulesOption, type EslintCypressRules, type EslintCypressRulesOption, type EslintTestingLibraryRules, type EslintTestingLibraryRulesOption, type EslintPluginRules, type EslintPluginRulesOption, type FlatConfig, type ESLintPlugin, type Rule, type Rules, } from './index.mjs';
|
|
2
2
|
//# sourceMappingURL=entry-point.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entry-point.d.mts","sourceRoot":"","sources":["../src/entry-point.mts"],"names":[],"mappings":"AACA,OAAO,EAEL,qCAAqC,EACrC,yBAAyB,EACzB,sBAAsB,EACtB,qBAAqB,EACrB,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,EACrB,mBAAmB,EACnB,yBAAyB,EACzB,sBAAsB,EACtB,6BAA6B,EAG7B,WAAW,EACX,qBAAqB,EACrB,qBAAqB,EACrB,yBAAyB,EACzB,kBAAkB,EAClB,oBAAoB,EACpB,8BAA8B,EAC9B,oCAAoC,EACpC,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,uBAAuB,EACvB,gBAAgB,EAChB,qBAAqB,EACrB,oBAAoB,EACpB,uBAAuB,EACvB,iBAAiB,EACjB,eAAe,EACf,kBAAkB,EAClB,yBAAyB,EACzB,kBAAkB,EAClB,qBAAqB,EACrB,iBAAiB,EAGjB,iBAAiB,EACjB,2BAA2B,EAC3B,gBAAgB,
|
|
1
|
+
{"version":3,"file":"entry-point.d.mts","sourceRoot":"","sources":["../src/entry-point.mts"],"names":[],"mappings":"AACA,OAAO,EAEL,qCAAqC,EACrC,yBAAyB,EACzB,sBAAsB,EACtB,qBAAqB,EACrB,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,EACrB,mBAAmB,EACnB,yBAAyB,EACzB,sBAAsB,EACtB,6BAA6B,EAG7B,WAAW,EACX,qBAAqB,EACrB,qBAAqB,EACrB,yBAAyB,EACzB,kBAAkB,EAClB,oBAAoB,EACpB,8BAA8B,EAC9B,oCAAoC,EACpC,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,uBAAuB,EACvB,gBAAgB,EAChB,qBAAqB,EACrB,oBAAoB,EACpB,uBAAuB,EACvB,iBAAiB,EACjB,eAAe,EACf,kBAAkB,EAClB,yBAAyB,EACzB,kBAAkB,EAClB,qBAAqB,EACrB,iBAAiB,EAGjB,iBAAiB,EACjB,2BAA2B,EAC3B,gBAAgB,EAGhB,kBAAkB,EAClB,4BAA4B,EAC5B,0BAA0B,EAC1B,wBAAwB,EAGxB,YAAY,EACZ,gBAAgB,EAChB,iBAAiB,EAGjB,OAAO,EAGP,KAAK,WAAW,EAChB,KAAK,iBAAiB,EACtB,KAAK,qBAAqB,EAC1B,KAAK,2BAA2B,EAChC,KAAK,qBAAqB,EAC1B,KAAK,2BAA2B,EAChC,KAAK,yBAAyB,EAC9B,KAAK,kBAAkB,EACvB,KAAK,wBAAwB,EAC7B,KAAK,oBAAoB,EACzB,KAAK,8BAA8B,EACnC,KAAK,oCAAoC,EACzC,KAAK,oCAAoC,EACzC,KAAK,0CAA0C,EAC/C,KAAK,kBAAkB,EACvB,KAAK,wBAAwB,EAC7B,KAAK,kBAAkB,EACvB,KAAK,wBAAwB,EAC7B,KAAK,6BAA6B,EAClC,KAAK,mCAAmC,EACxC,KAAK,2BAA2B,EAChC,KAAK,mBAAmB,EACxB,KAAK,uBAAuB,EAC5B,KAAK,gBAAgB,EACrB,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,EAC1B,KAAK,2BAA2B,EAChC,KAAK,oBAAoB,EACzB,KAAK,0BAA0B,EAC/B,KAAK,uBAAuB,EAC5B,KAAK,6BAA6B,EAClC,KAAK,kBAAkB,EACvB,KAAK,wBAAwB,EAC7B,KAAK,iBAAiB,EACtB,KAAK,uBAAuB,EAC5B,KAAK,eAAe,EACpB,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,EAC1B,KAAK,2BAA2B,EAChC,KAAK,kBAAkB,EACvB,KAAK,wBAAwB,EAC7B,KAAK,yBAAyB,EAC9B,KAAK,+BAA+B,EACpC,KAAK,iBAAiB,EACtB,KAAK,uBAAuB,EAG5B,KAAK,UAAU,EACf,KAAK,YAAY,EACjB,KAAK,IAAI,EACT,KAAK,KAAK,GACX,MAAM,aAAa,CAAC"}
|
package/dist/entry-point.mjs
CHANGED
|
@@ -20,7 +20,7 @@ export { eslintReactHooksRules } from './rules/eslint-react-hooks-rules.mjs';
|
|
|
20
20
|
export { eslintReactPerfRules } from './rules/eslint-react-perf-rules.mjs';
|
|
21
21
|
export { eslintReactRefreshRules } from './rules/eslint-react-refresh-rules.mjs';
|
|
22
22
|
export { eslintReactRules } from './rules/eslint-react-rules.mjs';
|
|
23
|
-
export { eslintRules, restrictedGlobals, restrictedGlobalsForBrowser, restrictedSyntax
|
|
23
|
+
export { eslintRules, restrictedGlobals, restrictedGlobalsForBrowser, restrictedSyntax } from './rules/eslint-rules.mjs';
|
|
24
24
|
export { eslintSecurityRules } from './rules/eslint-security-rules.mjs';
|
|
25
25
|
export { eslintTestingLibraryRules } from './rules/eslint-testing-library-rules.mjs';
|
|
26
26
|
export { eslintTotalFunctionsRules } from './rules/eslint-total-functions-rules.mjs';
|
|
@@ -37,6 +37,7 @@ export { eslintConfigForTypeScriptWithoutRules } from './configs/typescript-with
|
|
|
37
37
|
export { eslintConfigForTypeScript } from './configs/typescript.mjs';
|
|
38
38
|
export { eslintConfigForVitest } from './configs/vitest.mjs';
|
|
39
39
|
export { eslintPluginCustom } from './plugins/custom/custom.mjs';
|
|
40
|
+
export { eslintPluginReactCodingStyle } from './plugins/react-coding-style/plugin.mjs';
|
|
40
41
|
import 'is-glob';
|
|
41
42
|
import 'micromatch';
|
|
42
43
|
import 'node:path';
|
package/dist/entry-point.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entry-point.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"entry-point.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/index.mjs
CHANGED
|
@@ -12,6 +12,7 @@ export { eslintConfigForTypeScriptWithoutRules } from './configs/typescript-with
|
|
|
12
12
|
export { eslintConfigForTypeScript } from './configs/typescript.mjs';
|
|
13
13
|
export { eslintConfigForVitest } from './configs/vitest.mjs';
|
|
14
14
|
export { eslintPluginCustom } from './plugins/custom/custom.mjs';
|
|
15
|
+
export { eslintPluginReactCodingStyle } from './plugins/react-coding-style/plugin.mjs';
|
|
15
16
|
export { eslintPluginStrictDependencies } from './plugins/strict-dependencies/plugin.mjs';
|
|
16
17
|
export { eslintPluginTotalFunctions } from './plugins/total-functions/plugin.mjs';
|
|
17
18
|
export { eslintPluginTreeShakable } from './plugins/tree-shakable/plugin.mjs';
|
|
@@ -26,11 +27,12 @@ export { eslintPluginRules } from './rules/eslint-plugin-rules.mjs';
|
|
|
26
27
|
export { eslintPluginSortDestructureKeysRules } from './rules/eslint-plugin-sort-destructure-keys-rules.mjs';
|
|
27
28
|
export { eslintPreferArrowFunctionRules } from './rules/eslint-prefer-arrow-functions-rules.mjs';
|
|
28
29
|
export { eslintPromiseRules } from './rules/eslint-promise-rules.mjs';
|
|
30
|
+
export { eslintReactCodingStyleRules } from './rules/eslint-react-coding-style-rules.mjs';
|
|
29
31
|
export { eslintReactHooksRules } from './rules/eslint-react-hooks-rules.mjs';
|
|
30
32
|
export { eslintReactPerfRules } from './rules/eslint-react-perf-rules.mjs';
|
|
31
33
|
export { eslintReactRefreshRules } from './rules/eslint-react-refresh-rules.mjs';
|
|
32
34
|
export { eslintReactRules } from './rules/eslint-react-rules.mjs';
|
|
33
|
-
export { eslintRules, restrictedGlobals, restrictedGlobalsForBrowser, restrictedSyntax
|
|
35
|
+
export { eslintRules, restrictedGlobals, restrictedGlobalsForBrowser, restrictedSyntax } from './rules/eslint-rules.mjs';
|
|
34
36
|
export { eslintSecurityRules } from './rules/eslint-security-rules.mjs';
|
|
35
37
|
export { eslintTestingLibraryRules } from './rules/eslint-testing-library-rules.mjs';
|
|
36
38
|
export { eslintTotalFunctionsRules } from './rules/eslint-total-functions-rules.mjs';
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/plugins/index.d.mts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../src/plugins/index.mts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,iCAAiC,CAAC;AAChD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,2BAA2B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../src/plugins/index.mts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,iCAAiC,CAAC;AAChD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,2BAA2B,CAAC"}
|
package/dist/plugins/index.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { eslintPluginCustom } from './custom/custom.mjs';
|
|
2
|
+
export { eslintPluginReactCodingStyle } from './react-coding-style/plugin.mjs';
|
|
2
3
|
export { eslintPluginStrictDependencies } from './strict-dependencies/plugin.mjs';
|
|
3
4
|
export { eslintPluginTotalFunctions } from './total-functions/plugin.mjs';
|
|
4
5
|
export { eslintPluginTreeShakable } from './tree-shakable/plugin.mjs';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../src/plugins/react-coding-style/index.mts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.mts","sourceRoot":"","sources":["../../../src/plugins/react-coding-style/plugin.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAG1D,eAAO,MAAM,4BAA4B,EAAE,IAAI,CAAC,YAAY,EAAE,SAAS,CAE7D,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.mjs","sources":["../../../src/plugins/react-coding-style/plugin.mts"],"sourcesContent":[null],"names":[],"mappings":";;AAGO,MAAM,4BAA4B,GAAkC;AACzE,IAAA,KAAK,EAAE,qBAAqB;;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ban-use-imperative-handle-hook.d.mts","sourceRoot":"","sources":["../../../../src/plugins/react-coding-style/rules/ban-use-imperative-handle-hook.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAiB,MAAM,0BAA0B,CAAC;AAIxE,KAAK,UAAU,GAAG,6BAA6B,CAAC;AAEhD,eAAO,MAAM,0BAA0B,EAAE,QAAQ,CAAC,UAAU,CAAC,UAAU,CAwBtE,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { castDeepMutable } from 'ts-data-forge';
|
|
2
|
+
import { isReactMemberExpression } from './shared.mjs';
|
|
3
|
+
|
|
4
|
+
const banUseImperativeHandleHook = {
|
|
5
|
+
meta: {
|
|
6
|
+
type: 'suggestion',
|
|
7
|
+
docs: {
|
|
8
|
+
description: 'Restricts specific React hook usage patterns for consistent component styles.',
|
|
9
|
+
},
|
|
10
|
+
schema: [],
|
|
11
|
+
messages: {
|
|
12
|
+
disallowUseImperativeHandle: 'Move logic to parent component instead of using React.useImperativeHandle.',
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
create: (context) => ({
|
|
16
|
+
MemberExpression: (node) => {
|
|
17
|
+
if (isReactMemberExpression(node, 'useImperativeHandle')) {
|
|
18
|
+
context.report({
|
|
19
|
+
node: castDeepMutable(node),
|
|
20
|
+
messageId: 'disallowUseImperativeHandle',
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
}),
|
|
25
|
+
defaultOptions: [],
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export { banUseImperativeHandleHook };
|
|
29
|
+
//# sourceMappingURL=ban-use-imperative-handle-hook.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ban-use-imperative-handle-hook.mjs","sources":["../../../../src/plugins/react-coding-style/rules/ban-use-imperative-handle-hook.mts"],"sourcesContent":[null],"names":[],"mappings":";;;AAMO,MAAM,0BAA0B,GAAoC;AACzE,IAAA,IAAI,EAAE;AACJ,QAAA,IAAI,EAAE,YAAY;AAClB,QAAA,IAAI,EAAE;AACJ,YAAA,WAAW,EACT,+EAA+E;AAClF,SAAA;AACD,QAAA,MAAM,EAAE,EAAE;AACV,QAAA,QAAQ,EAAE;AACR,YAAA,2BAA2B,EACzB,4EAA4E;AAC/E,SAAA;AACF,KAAA;AACD,IAAA,MAAM,EAAE,CAAC,OAAO,MAAM;AACpB,QAAA,gBAAgB,EAAE,CAAC,IAA6C,KAAI;AAClE,YAAA,IAAI,uBAAuB,CAAC,IAAI,EAAE,qBAAqB,CAAC,EAAE;gBACxD,OAAO,CAAC,MAAM,CAAC;AACb,oBAAA,IAAI,EAAE,eAAe,CAAC,IAAI,CAAC;AAC3B,oBAAA,SAAS,EAAE,6BAA6B;AACzC,iBAAA,CAAC;YACJ;QACF,CAAC;KACF,CAAC;AACF,IAAA,cAAc,EAAE,EAAE;;;;;"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type TSESLint } from '@typescript-eslint/utils';
|
|
2
|
+
type ComponentNameOption = Readonly<{
|
|
3
|
+
maxLength?: number;
|
|
4
|
+
pattern?: RegExp;
|
|
5
|
+
}>;
|
|
6
|
+
type Options = readonly [ComponentNameOption] | readonly [];
|
|
7
|
+
type MessageIds = 'componentNameTooLong' | 'componentNameDoesNotMatch';
|
|
8
|
+
export declare const componentNameRule: TSESLint.RuleModule<MessageIds, Options>;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=component-name.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component-name.d.mts","sourceRoot":"","sources":["../../../../src/plugins/react-coding-style/rules/component-name.mts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAGzE,KAAK,mBAAmB,GAAG,QAAQ,CAAC;IAClC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC,CAAC;AAEH,KAAK,OAAO,GAAG,SAAS,CAAC,mBAAmB,CAAC,GAAG,SAAS,EAAE,CAAC;AAE5D,KAAK,UAAU,GAAG,sBAAsB,GAAG,2BAA2B,CAAC;AAcvE,eAAO,MAAM,iBAAiB,EAAE,QAAQ,CAAC,UAAU,CAAC,UAAU,EAAE,OAAO,CAoEtE,CAAC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { AST_NODE_TYPES } from '@typescript-eslint/utils';
|
|
2
|
+
import { isReactCallExpression } from './shared.mjs';
|
|
3
|
+
|
|
4
|
+
// NOTE:
|
|
5
|
+
// `const Name = React.memo<Props>((props) => {`
|
|
6
|
+
// が1行に収まるようにするためのルール。1行に収まらないとインデントが増えてコンポーネント実装の可読性が下がりやすくなるため。
|
|
7
|
+
// component props の型名や引数名の制約と併せて、 prettier のデフォルト print-width = 80 で export を省いた場合の最大長としてデフォルト値 42 を設定している。
|
|
8
|
+
// 抵触する場合、以下のように書き換える。
|
|
9
|
+
//
|
|
10
|
+
// const Component = React.memo<Props>((props) => {
|
|
11
|
+
// ...
|
|
12
|
+
// });
|
|
13
|
+
//
|
|
14
|
+
// export { Component as SomeComponent };
|
|
15
|
+
const componentNameRule = {
|
|
16
|
+
meta: {
|
|
17
|
+
type: 'suggestion',
|
|
18
|
+
docs: {
|
|
19
|
+
description: 'Enforces naming conventions for variables assigned to React.memo(...) components.',
|
|
20
|
+
},
|
|
21
|
+
schema: [
|
|
22
|
+
{
|
|
23
|
+
type: 'object',
|
|
24
|
+
properties: {
|
|
25
|
+
maxLength: {
|
|
26
|
+
type: 'integer',
|
|
27
|
+
minimum: 1,
|
|
28
|
+
},
|
|
29
|
+
pattern: {
|
|
30
|
+
type: 'object',
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
additionalProperties: false,
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
messages: {
|
|
37
|
+
componentNameTooLong: 'The component name length should be less than {{ maxLength }}. Consider rewrite as `const Component = React.memo<Props>((props) => { }); export { Component as SomeComponent };`.',
|
|
38
|
+
componentNameDoesNotMatch: 'The component name should match {{ pattern }}.',
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
create: (context) => {
|
|
42
|
+
const option = context.options[0];
|
|
43
|
+
const maxLength = option?.maxLength ?? 42;
|
|
44
|
+
const pattern = option?.pattern;
|
|
45
|
+
return {
|
|
46
|
+
VariableDeclarator: (node) => {
|
|
47
|
+
if (node.id.type !== AST_NODE_TYPES.Identifier ||
|
|
48
|
+
node.init?.type !== AST_NODE_TYPES.CallExpression ||
|
|
49
|
+
!isReactCallExpression(node.init, 'memo')) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
if (node.id.name.length >= maxLength) {
|
|
53
|
+
context.report({
|
|
54
|
+
node: node.id,
|
|
55
|
+
messageId: 'componentNameTooLong',
|
|
56
|
+
data: {
|
|
57
|
+
maxLength: String(maxLength),
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
if (pattern !== undefined && !pattern.test(node.id.name)) {
|
|
63
|
+
context.report({
|
|
64
|
+
node: node.id,
|
|
65
|
+
messageId: 'componentNameDoesNotMatch',
|
|
66
|
+
data: {
|
|
67
|
+
pattern: String(pattern),
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
},
|
|
74
|
+
defaultOptions: [],
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export { componentNameRule };
|
|
78
|
+
//# sourceMappingURL=component-name.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component-name.mjs","sources":["../../../../src/plugins/react-coding-style/rules/component-name.mts"],"sourcesContent":[null],"names":[],"mappings":";;;AAYA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEO,MAAM,iBAAiB,GAA6C;AACzE,IAAA,IAAI,EAAE;AACJ,QAAA,IAAI,EAAE,YAAY;AAClB,QAAA,IAAI,EAAE;AACJ,YAAA,WAAW,EACT,mFAAmF;AACtF,SAAA;AACD,QAAA,MAAM,EAAE;AACN,YAAA;AACE,gBAAA,IAAI,EAAE,QAAQ;AACd,gBAAA,UAAU,EAAE;AACV,oBAAA,SAAS,EAAE;AACT,wBAAA,IAAI,EAAE,SAAS;AACf,wBAAA,OAAO,EAAE,CAAC;AACX,qBAAA;AACD,oBAAA,OAAO,EAAE;AACP,wBAAA,IAAI,EAAE,QAAQ;AACf,qBAAA;AACF,iBAAA;AACD,gBAAA,oBAAoB,EAAE,KAAK;AAC5B,aAAA;AACF,SAAA;AACD,QAAA,QAAQ,EAAE;AACR,YAAA,oBAAoB,EAClB,mLAAmL;AACrL,YAAA,yBAAyB,EACvB,gDAAgD;AACnD,SAAA;AACF,KAAA;AACD,IAAA,MAAM,EAAE,CAAC,OAAO,KAAI;QAClB,MAAM,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;AACjC,QAAA,MAAM,SAAS,GAAG,MAAM,EAAE,SAAS,IAAI,EAAE;AACzC,QAAA,MAAM,OAAO,GAAG,MAAM,EAAE,OAAO;QAE/B,OAAO;AACL,YAAA,kBAAkB,EAAE,CAAC,IAAI,KAAI;gBAC3B,IACE,IAAI,CAAC,EAAE,CAAC,IAAI,KAAK,cAAc,CAAC,UAAU;AAC1C,oBAAA,IAAI,CAAC,IAAI,EAAE,IAAI,KAAK,cAAc,CAAC,cAAc;oBACjD,CAAC,qBAAqB,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,EACzC;oBACA;gBACF;gBAEA,IAAI,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,IAAI,SAAS,EAAE;oBACpC,OAAO,CAAC,MAAM,CAAC;wBACb,IAAI,EAAE,IAAI,CAAC,EAAE;AACb,wBAAA,SAAS,EAAE,sBAAsB;AACjC,wBAAA,IAAI,EAAE;AACJ,4BAAA,SAAS,EAAE,MAAM,CAAC,SAAS,CAAC;AAC7B,yBAAA;AACF,qBAAA,CAAC;oBACF;gBACF;AAEA,gBAAA,IAAI,OAAO,KAAK,SAAS,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE;oBACxD,OAAO,CAAC,MAAM,CAAC;wBACb,IAAI,EAAE,IAAI,CAAC,EAAE;AACb,wBAAA,SAAS,EAAE,2BAA2B;AACtC,wBAAA,IAAI,EAAE;AACJ,4BAAA,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC;AACzB,yBAAA;AACF,qBAAA,CAAC;gBACJ;YACF,CAAC;SACF;IACH,CAAC;AACD,IAAA,cAAc,EAAE,EAAE;;;;;"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type TSESLint } from '@typescript-eslint/utils';
|
|
2
|
+
type MessageIds = 'disallowReactFunctionalComponentTypes';
|
|
3
|
+
export declare const componentVarTypeAnnotationRule: TSESLint.RuleModule<MessageIds>;
|
|
4
|
+
export {};
|
|
5
|
+
//# sourceMappingURL=component-var-type-annotation.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component-var-type-annotation.d.mts","sourceRoot":"","sources":["../../../../src/plugins/react-coding-style/rules/component-var-type-annotation.mts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,QAAQ,EAEd,MAAM,0BAA0B,CAAC;AAGlC,KAAK,UAAU,GAAG,uCAAuC,CAAC;AAK1D,eAAO,MAAM,8BAA8B,EAAE,QAAQ,CAAC,UAAU,CAAC,UAAU,CAwB1E,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { AST_NODE_TYPES } from '@typescript-eslint/utils';
|
|
2
|
+
import { castDeepMutable } from 'ts-data-forge';
|
|
3
|
+
|
|
4
|
+
// NOTE: React.FC による型注釈があれば React.memo を使うように促すルール。
|
|
5
|
+
// React.FC で型注釈されていない React.memo 化されていないコンポーネントは別途検出する必要がある。
|
|
6
|
+
const componentVarTypeAnnotationRule = {
|
|
7
|
+
meta: {
|
|
8
|
+
type: 'suggestion',
|
|
9
|
+
docs: {
|
|
10
|
+
description: 'Disallows using React.FC / React.FunctionComponent type annotations.',
|
|
11
|
+
},
|
|
12
|
+
schema: [],
|
|
13
|
+
messages: {
|
|
14
|
+
disallowReactFunctionalComponentTypes: 'Use React.memo<Props>((props) => { ... }) instead.',
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
create: (context) => ({
|
|
18
|
+
TSTypeReference: (node) => {
|
|
19
|
+
if (isReactFunctionalComponentReference(node.typeName)) {
|
|
20
|
+
context.report({
|
|
21
|
+
node: castDeepMutable(node),
|
|
22
|
+
messageId: 'disallowReactFunctionalComponentTypes',
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
}),
|
|
27
|
+
defaultOptions: [],
|
|
28
|
+
};
|
|
29
|
+
const isReactFunctionalComponentReference = (node) => {
|
|
30
|
+
if (node.type !== AST_NODE_TYPES.TSQualifiedName) {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
const left = node.left;
|
|
34
|
+
const right = node.right;
|
|
35
|
+
return (left.type === AST_NODE_TYPES.Identifier &&
|
|
36
|
+
left.name === 'React' &&
|
|
37
|
+
(right.name === 'FC' || right.name === 'FunctionComponent'));
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export { componentVarTypeAnnotationRule };
|
|
41
|
+
//# sourceMappingURL=component-var-type-annotation.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component-var-type-annotation.mjs","sources":["../../../../src/plugins/react-coding-style/rules/component-var-type-annotation.mts"],"sourcesContent":[null],"names":[],"mappings":";;;AASA;AACA;AAEO,MAAM,8BAA8B,GAAoC;AAC7E,IAAA,IAAI,EAAE;AACJ,QAAA,IAAI,EAAE,YAAY;AAClB,QAAA,IAAI,EAAE;AACJ,YAAA,WAAW,EACT,sEAAsE;AACzE,SAAA;AACD,QAAA,MAAM,EAAE,EAAE;AACV,QAAA,QAAQ,EAAE;AACR,YAAA,qCAAqC,EACnC,oDAAoD;AACvD,SAAA;AACF,KAAA;AACD,IAAA,MAAM,EAAE,CAAC,OAAO,MAAM;AACpB,QAAA,eAAe,EAAE,CAAC,IAA4C,KAAI;AAChE,YAAA,IAAI,mCAAmC,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE;gBACtD,OAAO,CAAC,MAAM,CAAC;AACb,oBAAA,IAAI,EAAE,eAAe,CAAC,IAAI,CAAC;AAC3B,oBAAA,SAAS,EAAE,uCAAuC;AACnD,iBAAA,CAAC;YACJ;QACF,CAAC;KACF,CAAC;AACF,IAAA,cAAc,EAAE,EAAE;;AAGpB,MAAM,mCAAmC,GAAG,CAC1C,IAAuC,KAC5B;IACX,IAAI,IAAI,CAAC,IAAI,KAAK,cAAc,CAAC,eAAe,EAAE;AAChD,QAAA,OAAO,KAAK;IACd;AAEA,IAAA,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI;AACtB,IAAA,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK;AAExB,IAAA,QACE,IAAI,CAAC,IAAI,KAAK,cAAc,CAAC,UAAU;QACvC,IAAI,CAAC,IAAI,KAAK,OAAO;AACrB,SAAC,KAAK,CAAC,IAAI,KAAK,IAAI,IAAI,KAAK,CAAC,IAAI,KAAK,mBAAmB,CAAC;AAE/D,CAAC;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"import-style.d.mts","sourceRoot":"","sources":["../../../../src/plugins/react-coding-style/rules/import-style.mts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAEzE,KAAK,UAAU,GAAG,yBAAyB,GAAG,0BAA0B,CAAC;AAMzE,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,UAAU,CAAC,UAAU,CA4C3D,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { AST_NODE_TYPES } from '@typescript-eslint/utils';
|
|
2
|
+
|
|
3
|
+
// NOTE: React の import 方法を `import * as React from 'react'` と namespace import のみに限定するルール。
|
|
4
|
+
// import を1回で済ませられて便利なのと、 React.* に対する以降のルールを書きやすくするため。
|
|
5
|
+
// tree-shaking に悪影響は無い。
|
|
6
|
+
const importStyleRule = {
|
|
7
|
+
meta: {
|
|
8
|
+
type: 'suggestion',
|
|
9
|
+
docs: {
|
|
10
|
+
description: "Enforces importing React with a single namespace import named 'React'.",
|
|
11
|
+
},
|
|
12
|
+
schema: [],
|
|
13
|
+
messages: {
|
|
14
|
+
namespaceImportRequired: "React should be imported as `import * as React from 'react'`.",
|
|
15
|
+
namespaceNameMustBeReact: "The namespace name imported from 'react' must be 'React'.",
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
create: (context) => ({
|
|
19
|
+
ImportDeclaration: (node) => {
|
|
20
|
+
if (node.source.value !== 'react') {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
const [firstSpecifier] = node.specifiers;
|
|
24
|
+
if (firstSpecifier === undefined ||
|
|
25
|
+
firstSpecifier.type !== AST_NODE_TYPES.ImportNamespaceSpecifier ||
|
|
26
|
+
node.specifiers.length !== 1) {
|
|
27
|
+
context.report({
|
|
28
|
+
node,
|
|
29
|
+
messageId: 'namespaceImportRequired',
|
|
30
|
+
});
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
if (firstSpecifier.local.name !== 'React') {
|
|
34
|
+
context.report({
|
|
35
|
+
node: firstSpecifier.local,
|
|
36
|
+
messageId: 'namespaceNameMustBeReact',
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
}),
|
|
41
|
+
defaultOptions: [],
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export { importStyleRule };
|
|
45
|
+
//# sourceMappingURL=import-style.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"import-style.mjs","sources":["../../../../src/plugins/react-coding-style/rules/import-style.mts"],"sourcesContent":[null],"names":[],"mappings":";;AAIA;AACA;AACA;AAEO,MAAM,eAAe,GAAoC;AAC9D,IAAA,IAAI,EAAE;AACJ,QAAA,IAAI,EAAE,YAAY;AAClB,QAAA,IAAI,EAAE;AACJ,YAAA,WAAW,EACT,wEAAwE;AAC3E,SAAA;AACD,QAAA,MAAM,EAAE,EAAE;AACV,QAAA,QAAQ,EAAE;AACR,YAAA,uBAAuB,EACrB,+DAA+D;AACjE,YAAA,wBAAwB,EACtB,2DAA2D;AAC9D,SAAA;AACF,KAAA;AACD,IAAA,MAAM,EAAE,CAAC,OAAO,MAAM;AACpB,QAAA,iBAAiB,EAAE,CAAC,IAAI,KAAI;YAC1B,IAAI,IAAI,CAAC,MAAM,CAAC,KAAK,KAAK,OAAO,EAAE;gBACjC;YACF;AAEA,YAAA,MAAM,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC,UAAU;YAExC,IACE,cAAc,KAAK,SAAS;AAC5B,gBAAA,cAAc,CAAC,IAAI,KAAK,cAAc,CAAC,wBAAwB;AAC/D,gBAAA,IAAI,CAAC,UAAU,CAAC,MAAM,KAAK,CAAC,EAC5B;gBACA,OAAO,CAAC,MAAM,CAAC;oBACb,IAAI;AACJ,oBAAA,SAAS,EAAE,yBAAyB;AACrC,iBAAA,CAAC;gBACF;YACF;YAEA,IAAI,cAAc,CAAC,KAAK,CAAC,IAAI,KAAK,OAAO,EAAE;gBACzC,OAAO,CAAC,MAAM,CAAC;oBACb,IAAI,EAAE,cAAc,CAAC,KAAK;AAC1B,oBAAA,SAAS,EAAE,0BAA0B;AACtC,iBAAA,CAAC;YACJ;QACF,CAAC;KACF,CAAC;AACF,IAAA,cAAc,EAAE,EAAE;;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../../src/plugins/react-coding-style/rules/index.mts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"props-type-annotation-style.d.mts","sourceRoot":"","sources":["../../../../src/plugins/react-coding-style/rules/props-type-annotation-style.mts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,QAAQ,EAEd,MAAM,0BAA0B,CAAC;AAIlC,KAAK,UAAU,GAAG,6BAA6B,CAAC;AAIhD,eAAO,MAAM,4BAA4B,EAAE,QAAQ,CAAC,UAAU,CAAC,UAAU,CA8CxE,CAAC"}
|