eslint-plugin-nima 1.0.0 → 1.2.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.
Files changed (84) hide show
  1. package/LICENSE +7 -0
  2. package/README.md +134 -1
  3. package/dist/constants/consoles.js +21 -1
  4. package/dist/constants/consoles.js.map +1 -1
  5. package/dist/index.d.ts +60 -86
  6. package/dist/index.js +4 -1
  7. package/dist/index.js.map +1 -1
  8. package/dist/models/boolean-naming-convention.model.d.ts +15 -0
  9. package/dist/models/boolean-naming-convention.model.js +11 -0
  10. package/dist/models/boolean-naming-convention.model.js.map +1 -0
  11. package/dist/models/no-handler-suffix.model.d.ts +4 -0
  12. package/dist/models/no-handler-suffix.model.js +8 -0
  13. package/dist/models/no-handler-suffix.model.js.map +1 -0
  14. package/dist/models/no-objects-in-deps.model.d.ts +4 -0
  15. package/dist/models/no-objects-in-deps.model.js +8 -0
  16. package/dist/models/no-objects-in-deps.model.js.map +1 -0
  17. package/dist/models/params-naming-convention.model.d.ts +11 -0
  18. package/dist/models/params-naming-convention.model.js +8 -0
  19. package/dist/models/params-naming-convention.model.js.map +1 -0
  20. package/dist/models/prefer-arrow-functions.model.d.ts +15 -0
  21. package/dist/models/prefer-arrow-functions.model.js +10 -0
  22. package/dist/models/prefer-arrow-functions.model.js.map +1 -0
  23. package/dist/models/prefer-export-under-component.model.d.ts +9 -0
  24. package/dist/models/prefer-export-under-component.model.js +8 -0
  25. package/dist/models/prefer-export-under-component.model.js.map +1 -0
  26. package/dist/models/prefer-react-fc.model.d.ts +9 -0
  27. package/dist/models/prefer-react-fc.model.js +8 -0
  28. package/dist/models/prefer-react-fc.model.js.map +1 -0
  29. package/dist/models/prefer-react-with-hooks.model.d.ts +5 -0
  30. package/dist/models/prefer-react-with-hooks.model.js +9 -0
  31. package/dist/models/prefer-react-with-hooks.model.js.map +1 -0
  32. package/dist/models/restrict-console-methods.model.d.ts +8 -0
  33. package/dist/models/restrict-console-methods.model.js +8 -0
  34. package/dist/models/restrict-console-methods.model.js.map +1 -0
  35. package/dist/models/restrict-function-usage.model.d.ts +11 -0
  36. package/dist/models/restrict-function-usage.model.js +8 -0
  37. package/dist/models/restrict-function-usage.model.js.map +1 -0
  38. package/dist/rules/boolean-naming-convention.d.ts +4 -8
  39. package/dist/rules/boolean-naming-convention.js +87 -35
  40. package/dist/rules/boolean-naming-convention.js.map +1 -1
  41. package/dist/rules/no-handler-suffix.d.ts +4 -2
  42. package/dist/rules/no-handler-suffix.js +13 -8
  43. package/dist/rules/no-handler-suffix.js.map +1 -1
  44. package/dist/rules/no-objects-in-deps.d.ts +4 -2
  45. package/dist/rules/no-objects-in-deps.js +21 -14
  46. package/dist/rules/no-objects-in-deps.js.map +1 -1
  47. package/dist/rules/params-naming-convention.d.ts +4 -7
  48. package/dist/rules/params-naming-convention.js +30 -30
  49. package/dist/rules/params-naming-convention.js.map +1 -1
  50. package/dist/rules/prefer-arrow-functions.d.ts +4 -9
  51. package/dist/rules/prefer-arrow-functions.js +37 -34
  52. package/dist/rules/prefer-arrow-functions.js.map +1 -1
  53. package/dist/rules/prefer-export-under-component.d.ts +5 -0
  54. package/dist/rules/prefer-export-under-component.js +115 -0
  55. package/dist/rules/prefer-export-under-component.js.map +1 -0
  56. package/dist/rules/prefer-react-fc.d.ts +4 -5
  57. package/dist/rules/prefer-react-fc.js +26 -27
  58. package/dist/rules/prefer-react-fc.js.map +1 -1
  59. package/dist/rules/prefer-react-with-hooks.d.ts +4 -4
  60. package/dist/rules/prefer-react-with-hooks.js +57 -41
  61. package/dist/rules/prefer-react-with-hooks.js.map +1 -1
  62. package/dist/rules/restrict-console-methods.d.ts +4 -8
  63. package/dist/rules/restrict-console-methods.js +20 -29
  64. package/dist/rules/restrict-console-methods.js.map +1 -1
  65. package/dist/rules/restrict-function-usage.d.ts +5 -0
  66. package/dist/rules/{manage-functions.js → restrict-function-usage.js} +24 -41
  67. package/dist/rules/restrict-function-usage.js.map +1 -0
  68. package/dist/utility/core.d.ts +6 -0
  69. package/dist/utility/core.js +6 -0
  70. package/dist/utility/core.js.map +1 -0
  71. package/dist/utility/function-helpers.d.ts +9 -0
  72. package/dist/utility/function-helpers.js +146 -0
  73. package/dist/utility/function-helpers.js.map +1 -0
  74. package/dist/utility/type-helpers.d.ts +2 -0
  75. package/dist/utility/{getType.js → type-helpers.js} +2 -2
  76. package/dist/utility/type-helpers.js.map +1 -0
  77. package/package.json +32 -17
  78. package/dist/rules/manage-functions.d.ts +0 -12
  79. package/dist/rules/manage-functions.js.map +0 -1
  80. package/dist/utility/getFunctionName.d.ts +0 -2
  81. package/dist/utility/getFunctionName.js +0 -36
  82. package/dist/utility/getFunctionName.js.map +0 -1
  83. package/dist/utility/getType.d.ts +0 -3
  84. package/dist/utility/getType.js.map +0 -1
package/LICENSE ADDED
@@ -0,0 +1,7 @@
1
+ Copyright 2025 NIMA Labs
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -1 +1,134 @@
1
- To be added...
1
+ <div align="center">
2
+
3
+ [![npm](https://img.shields.io/npm/v/eslint-plugin-nima?logo=npm&cacheSeconds=1800)](https://www.npmjs.com/package/eslint-plugin-nima)
4
+ [![main-suite](https://github.com/NIMA-Enterprises/eslint-plugin-nima/actions/workflows/publish.yml/badge.svg)](https://github.com/NIMA-Enterprises/eslint-plugin-nima/actions/workflows/publish.yml)
5
+
6
+ </div>
7
+
8
+ An **ESLint plugin** that enforces conventions, prevents common mistakes, and speeds up code reviews at NIMA.
9
+ It includes opinionated rules for naming, React, parameters, and restrictions on unsafe patterns.
10
+
11
+ ---
12
+
13
+ ## Table of Contents
14
+
15
+ - [Installation](#installation)
16
+ - [Usage](#usage)
17
+ - [Recommended setup](#recommended-setup)
18
+ - [Custom setup](#custom-setup)
19
+ - [Rules](#rules)
20
+ - [Contributing](#contributing)
21
+ - [License](#license)
22
+
23
+ ---
24
+
25
+ ## Installation
26
+
27
+ First, install [ESLint](http://eslint.org):
28
+
29
+ ```bash
30
+ pnpm add -D eslint
31
+ ```
32
+
33
+ Then install `eslint-plugin-nima`:
34
+
35
+ ```bash
36
+ pnpm add -D eslint-plugin-nima
37
+ ```
38
+
39
+ > **Note**: Don’t install ESLint globally. Keep it project-local for consistent results.
40
+
41
+ ---
42
+
43
+ ## Usage
44
+
45
+ You can enable this plugin in two ways: using the **recommended setup** or a **custom setup**.
46
+
47
+ ### Recommended setup
48
+
49
+ Add the following to your `eslint.config.js`:
50
+
51
+ ```js
52
+ import pluginNIMA from "eslint-plugin-nima";
53
+
54
+ export default [
55
+ pluginNIMA.configs["flat/recommended"],
56
+ // Any other config...
57
+ ];
58
+ ```
59
+
60
+ This enables the recommended set of rules we’ve curated for most NIMA projects.
61
+
62
+ ### Custom setup
63
+
64
+ If you prefer to configure rules manually, load the plugin and specify only the rules you want:
65
+
66
+ ```js
67
+ import pluginNIMA from "eslint-plugin-nima";
68
+
69
+ export default [
70
+ {
71
+ plugins: {
72
+ nima: pluginNIMA,
73
+ },
74
+ rules: {
75
+ "nima/restrict-console-methods": "error",
76
+ },
77
+ },
78
+ ];
79
+ ```
80
+
81
+ You can also extend the recommended config and override specific rules:
82
+
83
+ ```js
84
+ import pluginNIMA from "eslint-plugin-nima";
85
+
86
+ export default [
87
+ {
88
+ ...pluginNIMA.configs["flat/recommended"],
89
+ rules: {
90
+ ...pluginNIMA.configs["flat/recommended"].rules,
91
+ "nima/restrict-console-methods": "off",
92
+ },
93
+ },
94
+ ];
95
+ ```
96
+
97
+ ---
98
+
99
+ ## Rules
100
+
101
+ Each rule has three levels of explanation:
102
+
103
+ - **Short**: one-liner summary (good for quick scanning).
104
+ - **Medium**: sentences with examples (on the overview page).
105
+ - **Full**: dedicated docs per rule.
106
+
107
+ Before diving deep into what each rule does, I recommend reading the [Rule Overview Page](documentation/rules/index.md) where you can read a little bit about each rule and then you can see which one you want to dig into.
108
+
109
+ The plugin currently provides these rules:
110
+
111
+ - [no-handler-suffix](documentation/rules/no-handler-suffix.md)
112
+ - [restrict-console-methods](documentation/rules/restrict-console-methods.md)
113
+ - [prefer-export-under-component](documentation/rules/prefer-export-under-component.md)
114
+ - [prefer-react-fc](documentation/rules/prefer-react-fc.md)
115
+ - [prefer-arrow-functions](documentation/rules/prefer-arrow-functions.md)
116
+ - [prefer-react-with-hooks](documentation/rules/prefer-react-with-hooks.md)
117
+ - [restrict-function-usage](documentation/rules/restrict-function-usage.md)
118
+ - [no-objects-in-deps](documentation/rules/no-objects-in-deps.md)
119
+ - [params-naming-convention](documentation/rules/params-naming-convention.md)
120
+ - [boolean-naming-convention](documentation/rules/boolean-naming-convention.md)
121
+
122
+ See the full [Rules overview](documentation/rules/index.md).
123
+
124
+ ---
125
+
126
+ ## Configurations
127
+
128
+ There's also pre-built configurations:
129
+
130
+ - [recommended](documentation/configs/index.md)
131
+
132
+ ## License
133
+
134
+ [MIT](LICENSE)
@@ -1,5 +1,25 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CONSOLES = void 0;
4
- exports.CONSOLES = new Set(["error", "log", "warn"]);
4
+ exports.CONSOLES = new Set([
5
+ "assert",
6
+ "clear",
7
+ "count",
8
+ "countReset",
9
+ "debug",
10
+ "dir",
11
+ "dirxml",
12
+ "error",
13
+ "group",
14
+ "groupEnd",
15
+ "info",
16
+ "log",
17
+ "profile",
18
+ "profileEnd",
19
+ "table",
20
+ "time",
21
+ "timeEnd",
22
+ "trace",
23
+ "warn",
24
+ ]);
5
25
  //# sourceMappingURL=consoles.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"consoles.js","sourceRoot":"","sources":["../../src/constants/consoles.ts"],"names":[],"mappings":";;;AAAa,QAAA,QAAQ,GAAG,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"consoles.js","sourceRoot":"","sources":["../../src/constants/consoles.ts"],"names":[],"mappings":";;;AAAa,QAAA,QAAQ,GAAG,IAAI,GAAG,CAAC;IAC9B,QAAQ;IACR,OAAO;IACP,OAAO;IACP,YAAY;IACZ,OAAO;IACP,KAAK;IACL,QAAQ;IACR,OAAO;IACP,OAAO;IACP,UAAU;IACV,MAAM;IACN,KAAK;IACL,SAAS;IACT,YAAY;IACZ,OAAO;IACP,MAAM;IACN,SAAS;IACT,OAAO;IACP,MAAM;CACP,CAAC,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,49 +1,36 @@
1
1
  import type { RuleModule } from "@typescript-eslint/utils/ts-eslint";
2
2
  import type { ESLint, Linter } from "eslint";
3
3
  declare const rules: {
4
- "boolean-naming-convention": RuleModule<"booleanFunctionName" | "booleanParameterName" | "booleanPropertyName" | "booleanVariableName", [{
5
- allowedPrefixes: string[];
6
- checkFunctions: boolean;
7
- checkParameters: boolean;
8
- checkProperties: boolean;
9
- checkVariables: boolean;
10
- }], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
11
- "manage-functions": RuleModule<"noOptional", {
12
- options: {
13
- allowFunctions?: string[];
14
- disableFunctions?: string[];
15
- files?: string[];
16
- folders?: string[];
17
- }[];
18
- }[], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
19
- "no-handler-suffix": RuleModule<"badHandleName", [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
20
- "no-objects-in-deps": RuleModule<"noObjects", [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
21
- "params-naming-convention": RuleModule<"useObjectParams", [{
22
- allowedParameters: number;
23
- ignore: string[];
24
- ignoreFunctions: string[];
25
- ignorePrefixes: string[];
26
- }], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
27
- "prefer-arrow-functions": RuleModule<"preferArrowFunction" | "preferArrowFunctionExpression" | "preferArrowMethod", [{
28
- allowAsync: boolean;
29
- allowConstructors: boolean;
30
- allowFunctionDeclarations: boolean;
31
- allowFunctionExpressions: boolean;
32
- allowGenerators: boolean;
33
- allowMethodDefinitions: boolean;
34
- }], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
35
- "prefer-react-fc": RuleModule<"requireReactFC", [{
36
- allowArrowFunctions: boolean;
37
- allowFunctionDeclarations: boolean;
38
- }], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
39
- "prefer-react-with-hooks": RuleModule<"preferReact" | "preferReactPrefix", [{
40
- autoFix: boolean;
41
- }], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
42
- "restrict-console-methods": RuleModule<"noConsole", {
43
- noConsoleError?: boolean;
44
- noConsoleLog?: boolean;
45
- noConsoleWarn?: boolean;
46
- }[], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
4
+ "boolean-naming-convention": RuleModule<import("./models/boolean-naming-convention.model").Messages, import("./models/boolean-naming-convention.model").Options, {
5
+ recommended: boolean;
6
+ }, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
7
+ "restrict-function-usage": RuleModule<import("./models/restrict-function-usage.model").Messages, import("./models/restrict-function-usage.model").Options, {
8
+ recommended: boolean;
9
+ }, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
10
+ "no-handler-suffix": RuleModule<import("./models/no-handler-suffix.model").Messages, [], {
11
+ recommended: boolean;
12
+ }, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
13
+ "no-objects-in-deps": RuleModule<import("./models/no-objects-in-deps.model").Messages, [], {
14
+ recommended: boolean;
15
+ }, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
16
+ "params-naming-convention": RuleModule<import("./models/params-naming-convention.model").Messages, import("./models/params-naming-convention.model").Options, {
17
+ recommended: boolean;
18
+ }, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
19
+ "prefer-arrow-functions": RuleModule<import("./models/prefer-arrow-functions.model").Messages, import("./models/prefer-arrow-functions.model").Options, {
20
+ recommended: boolean;
21
+ }, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
22
+ "prefer-export-under-component": RuleModule<import("./models/prefer-export-under-component.model").Messages, import("./models/prefer-export-under-component.model").Options, {
23
+ recommended: boolean;
24
+ }, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
25
+ "prefer-react-fc": RuleModule<import("./models/prefer-react-fc.model").Messages, import("./models/prefer-react-fc.model").Options, {
26
+ recommended: boolean;
27
+ }, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
28
+ "prefer-react-with-hooks": RuleModule<import("./models/prefer-react-with-hooks.model").Messages, [], {
29
+ recommended: boolean;
30
+ }, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
31
+ "restrict-console-methods": RuleModule<import("./models/restrict-console-methods.model").Messages, import("./models/restrict-console-methods.model").Options, {
32
+ recommended: boolean;
33
+ }, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
47
34
  };
48
35
  interface Plugin extends Omit<ESLint.Plugin, "rules"> {
49
36
  configs: {
@@ -59,49 +46,36 @@ declare const plugin: {
59
46
  name: string;
60
47
  };
61
48
  rules: {
62
- "boolean-naming-convention": RuleModule<"booleanFunctionName" | "booleanParameterName" | "booleanPropertyName" | "booleanVariableName", [{
63
- allowedPrefixes: string[];
64
- checkFunctions: boolean;
65
- checkParameters: boolean;
66
- checkProperties: boolean;
67
- checkVariables: boolean;
68
- }], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
69
- "manage-functions": RuleModule<"noOptional", {
70
- options: {
71
- allowFunctions?: string[];
72
- disableFunctions?: string[];
73
- files?: string[];
74
- folders?: string[];
75
- }[];
76
- }[], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
77
- "no-handler-suffix": RuleModule<"badHandleName", [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
78
- "no-objects-in-deps": RuleModule<"noObjects", [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
79
- "params-naming-convention": RuleModule<"useObjectParams", [{
80
- allowedParameters: number;
81
- ignore: string[];
82
- ignoreFunctions: string[];
83
- ignorePrefixes: string[];
84
- }], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
85
- "prefer-arrow-functions": RuleModule<"preferArrowFunction" | "preferArrowFunctionExpression" | "preferArrowMethod", [{
86
- allowAsync: boolean;
87
- allowConstructors: boolean;
88
- allowFunctionDeclarations: boolean;
89
- allowFunctionExpressions: boolean;
90
- allowGenerators: boolean;
91
- allowMethodDefinitions: boolean;
92
- }], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
93
- "prefer-react-fc": RuleModule<"requireReactFC", [{
94
- allowArrowFunctions: boolean;
95
- allowFunctionDeclarations: boolean;
96
- }], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
97
- "prefer-react-with-hooks": RuleModule<"preferReact" | "preferReactPrefix", [{
98
- autoFix: boolean;
99
- }], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
100
- "restrict-console-methods": RuleModule<"noConsole", {
101
- noConsoleError?: boolean;
102
- noConsoleLog?: boolean;
103
- noConsoleWarn?: boolean;
104
- }[], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
49
+ "boolean-naming-convention": RuleModule<import("./models/boolean-naming-convention.model").Messages, import("./models/boolean-naming-convention.model").Options, {
50
+ recommended: boolean;
51
+ }, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
52
+ "restrict-function-usage": RuleModule<import("./models/restrict-function-usage.model").Messages, import("./models/restrict-function-usage.model").Options, {
53
+ recommended: boolean;
54
+ }, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
55
+ "no-handler-suffix": RuleModule<import("./models/no-handler-suffix.model").Messages, [], {
56
+ recommended: boolean;
57
+ }, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
58
+ "no-objects-in-deps": RuleModule<import("./models/no-objects-in-deps.model").Messages, [], {
59
+ recommended: boolean;
60
+ }, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
61
+ "params-naming-convention": RuleModule<import("./models/params-naming-convention.model").Messages, import("./models/params-naming-convention.model").Options, {
62
+ recommended: boolean;
63
+ }, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
64
+ "prefer-arrow-functions": RuleModule<import("./models/prefer-arrow-functions.model").Messages, import("./models/prefer-arrow-functions.model").Options, {
65
+ recommended: boolean;
66
+ }, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
67
+ "prefer-export-under-component": RuleModule<import("./models/prefer-export-under-component.model").Messages, import("./models/prefer-export-under-component.model").Options, {
68
+ recommended: boolean;
69
+ }, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
70
+ "prefer-react-fc": RuleModule<import("./models/prefer-react-fc.model").Messages, import("./models/prefer-react-fc.model").Options, {
71
+ recommended: boolean;
72
+ }, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
73
+ "prefer-react-with-hooks": RuleModule<import("./models/prefer-react-with-hooks.model").Messages, [], {
74
+ recommended: boolean;
75
+ }, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
76
+ "restrict-console-methods": RuleModule<import("./models/restrict-console-methods.model").Messages, import("./models/restrict-console-methods.model").Options, {
77
+ recommended: boolean;
78
+ }, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
105
79
  };
106
80
  };
107
81
  export = plugin;
package/dist/index.js CHANGED
@@ -33,14 +33,15 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  const BooleanNamingConvention = __importStar(require("./rules/boolean-naming-convention"));
36
- const ManageFunctions = __importStar(require("./rules/manage-functions"));
37
36
  const NoHandlerSuffix = __importStar(require("./rules/no-handler-suffix"));
38
37
  const NoObjectsInDeps = __importStar(require("./rules/no-objects-in-deps"));
39
38
  const ParamsNamingConvention = __importStar(require("./rules/params-naming-convention"));
40
39
  const PreferArrowFunctions = __importStar(require("./rules/prefer-arrow-functions"));
40
+ const PreferNamedExport = __importStar(require("./rules/prefer-export-under-component"));
41
41
  const PreferReactFc = __importStar(require("./rules/prefer-react-fc"));
42
42
  const PreferReactWithHooks = __importStar(require("./rules/prefer-react-with-hooks"));
43
43
  const RestrictConsoleMethods = __importStar(require("./rules/restrict-console-methods"));
44
+ const ManageFunctions = __importStar(require("./rules/restrict-function-usage"));
44
45
  const rules = {
45
46
  [BooleanNamingConvention.name]: BooleanNamingConvention.rule,
46
47
  [ManageFunctions.name]: ManageFunctions.rule,
@@ -48,6 +49,7 @@ const rules = {
48
49
  [NoObjectsInDeps.name]: NoObjectsInDeps.rule,
49
50
  [ParamsNamingConvention.name]: ParamsNamingConvention.rule,
50
51
  [PreferArrowFunctions.name]: PreferArrowFunctions.rule,
52
+ [PreferNamedExport.name]: PreferNamedExport.rule,
51
53
  [PreferReactFc.name]: PreferReactFc.rule,
52
54
  [PreferReactWithHooks.name]: PreferReactWithHooks.rule,
53
55
  [RestrictConsoleMethods.name]: RestrictConsoleMethods.rule,
@@ -61,6 +63,7 @@ const plugin = {
61
63
  };
62
64
  const recommended = {
63
65
  "nima/no-handler-suffix": "error",
66
+ "nima/prefer-export-under-component": "error",
64
67
  "nima/prefer-react-fc": "warn",
65
68
  "nima/restrict-console-methods": "error",
66
69
  };
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file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E,OAAO;IAC7C,sBAAsB,EAAE,MAAM;IAC9B,+BAA+B,EAAE,OAAO;CACzC,CAAC;AAEF,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE;IAC5B,kBAAkB,EAAE;QAClB,OAAO,EAAE;YACP,IAAI,EAAE,MAAM;SACb;QACD,KAAK,EAAE,WAAW;KACnB;IACD,WAAW,EAAE;QACX,OAAO,EAAE,CAAC,MAAM,CAAC;QACjB,KAAK,EAAE,WAAW;KACnB;CACF,CAAC,CAAC;AAEH,iBAAS,MAAM,CAAC"}
@@ -0,0 +1,15 @@
1
+ export declare const enum Messages {
2
+ BAD_FUNCTION_BOOLEAN_PREFIX = "BAD_FUNCTION_BOOLEAN_PREFIX",
3
+ BAD_PARAMETER_BOOLEAN_PREFIX = "BAD_PARAMETER_BOOLEAN_PREFIX",
4
+ BAD_PROPERTY_BOOLEAN_PREFIX = "BAD_PROPERTY_BOOLEAN_PREFIX",
5
+ BAD_VARIABLE_BOOLEAN_PREFIX = "BAD_VARIABLE_BOOLEAN_PREFIX"
6
+ }
7
+ export type Options = [
8
+ Partial<{
9
+ allowedPrefixes: string[];
10
+ checkFunctions: boolean;
11
+ checkParameters: boolean;
12
+ checkProperties: boolean;
13
+ checkVariables: boolean;
14
+ }>
15
+ ];
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Messages = void 0;
4
+ var Messages;
5
+ (function (Messages) {
6
+ Messages["BAD_FUNCTION_BOOLEAN_PREFIX"] = "BAD_FUNCTION_BOOLEAN_PREFIX";
7
+ Messages["BAD_PARAMETER_BOOLEAN_PREFIX"] = "BAD_PARAMETER_BOOLEAN_PREFIX";
8
+ Messages["BAD_PROPERTY_BOOLEAN_PREFIX"] = "BAD_PROPERTY_BOOLEAN_PREFIX";
9
+ Messages["BAD_VARIABLE_BOOLEAN_PREFIX"] = "BAD_VARIABLE_BOOLEAN_PREFIX";
10
+ })(Messages || (exports.Messages = Messages = {}));
11
+ //# sourceMappingURL=boolean-naming-convention.model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"boolean-naming-convention.model.js","sourceRoot":"","sources":["../../src/models/boolean-naming-convention.model.ts"],"names":[],"mappings":";;;AAAA,IAAkB,QAKjB;AALD,WAAkB,QAAQ;IACxB,uEAA2D,CAAA;IAC3D,yEAA6D,CAAA;IAC7D,uEAA2D,CAAA;IAC3D,uEAA2D,CAAA;AAC7D,CAAC,EALiB,QAAQ,wBAAR,QAAQ,QAKzB"}
@@ -0,0 +1,4 @@
1
+ export declare const enum Messages {
2
+ BAD_HANDLER_NAME = "BAD_HANDLER_NAME"
3
+ }
4
+ export type Options = [];
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Messages = void 0;
4
+ var Messages;
5
+ (function (Messages) {
6
+ Messages["BAD_HANDLER_NAME"] = "BAD_HANDLER_NAME";
7
+ })(Messages || (exports.Messages = Messages = {}));
8
+ //# sourceMappingURL=no-handler-suffix.model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-handler-suffix.model.js","sourceRoot":"","sources":["../../src/models/no-handler-suffix.model.ts"],"names":[],"mappings":";;;AAAA,IAAkB,QAEjB;AAFD,WAAkB,QAAQ;IACxB,iDAAqC,CAAA;AACvC,CAAC,EAFiB,QAAQ,wBAAR,QAAQ,QAEzB"}
@@ -0,0 +1,4 @@
1
+ export declare const enum Messages {
2
+ NO_OBJECTS_IN_DEPENDENCIES = "NO_OBJECTS_IN_DEPENDENCIES"
3
+ }
4
+ export type Options = [];
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Messages = void 0;
4
+ var Messages;
5
+ (function (Messages) {
6
+ Messages["NO_OBJECTS_IN_DEPENDENCIES"] = "NO_OBJECTS_IN_DEPENDENCIES";
7
+ })(Messages || (exports.Messages = Messages = {}));
8
+ //# sourceMappingURL=no-objects-in-deps.model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-objects-in-deps.model.js","sourceRoot":"","sources":["../../src/models/no-objects-in-deps.model.ts"],"names":[],"mappings":";;;AAAA,IAAkB,QAEjB;AAFD,WAAkB,QAAQ;IACxB,qEAAyD,CAAA;AAC3D,CAAC,EAFiB,QAAQ,wBAAR,QAAQ,QAEzB"}
@@ -0,0 +1,11 @@
1
+ export declare const enum Messages {
2
+ USE_OBJECT_PARAMETERS = "USE_OBJECT_PARAMETERS"
3
+ }
4
+ export type Options = [
5
+ Partial<{
6
+ allowedParameters: number;
7
+ ignore: string[];
8
+ ignoreFunctions: string[];
9
+ ignorePrefixes: string[];
10
+ }>
11
+ ];
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Messages = void 0;
4
+ var Messages;
5
+ (function (Messages) {
6
+ Messages["USE_OBJECT_PARAMETERS"] = "USE_OBJECT_PARAMETERS";
7
+ })(Messages || (exports.Messages = Messages = {}));
8
+ //# sourceMappingURL=params-naming-convention.model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"params-naming-convention.model.js","sourceRoot":"","sources":["../../src/models/params-naming-convention.model.ts"],"names":[],"mappings":";;;AAAA,IAAkB,QAEjB;AAFD,WAAkB,QAAQ;IACxB,2DAA+C,CAAA;AACjD,CAAC,EAFiB,QAAQ,wBAAR,QAAQ,QAEzB"}
@@ -0,0 +1,15 @@
1
+ export declare const enum Messages {
2
+ PREFER_ARROW_FUNCTION_EXPRESSION = "PREFER_ARROW_FUNCTION_EXPRESSION",
3
+ PREFER_ARROW_FUNCTIONS = "PREFER_ARROW_FUNCTIONS",
4
+ PREFER_ARROW_METHOD = "PREFER_ARROW_METHOD"
5
+ }
6
+ export type Options = [
7
+ Partial<{
8
+ allowAsync: boolean;
9
+ allowConstructors: boolean;
10
+ allowFunctionDeclarations: boolean;
11
+ allowFunctionExpressions: boolean;
12
+ allowGenerators: boolean;
13
+ allowMethodDefinitions: boolean;
14
+ }>
15
+ ];
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Messages = void 0;
4
+ var Messages;
5
+ (function (Messages) {
6
+ Messages["PREFER_ARROW_FUNCTION_EXPRESSION"] = "PREFER_ARROW_FUNCTION_EXPRESSION";
7
+ Messages["PREFER_ARROW_FUNCTIONS"] = "PREFER_ARROW_FUNCTIONS";
8
+ Messages["PREFER_ARROW_METHOD"] = "PREFER_ARROW_METHOD";
9
+ })(Messages || (exports.Messages = Messages = {}));
10
+ //# sourceMappingURL=prefer-arrow-functions.model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prefer-arrow-functions.model.js","sourceRoot":"","sources":["../../src/models/prefer-arrow-functions.model.ts"],"names":[],"mappings":";;;AAAA,IAAkB,QAIjB;AAJD,WAAkB,QAAQ;IACxB,iFAAqE,CAAA;IACrE,6DAAiD,CAAA;IACjD,uDAA2C,CAAA;AAC7C,CAAC,EAJiB,QAAQ,wBAAR,QAAQ,QAIzB"}
@@ -0,0 +1,9 @@
1
+ export declare const enum Messages {
2
+ EXPORT_BELOW_COMPONENT = "EXPORT_BELOW_COMPONENT"
3
+ }
4
+ export type Options = [
5
+ Partial<{
6
+ allowGenerators: boolean;
7
+ allowMethodDefinitions: boolean;
8
+ }>
9
+ ];
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Messages = void 0;
4
+ var Messages;
5
+ (function (Messages) {
6
+ Messages["EXPORT_BELOW_COMPONENT"] = "EXPORT_BELOW_COMPONENT";
7
+ })(Messages || (exports.Messages = Messages = {}));
8
+ //# sourceMappingURL=prefer-export-under-component.model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prefer-export-under-component.model.js","sourceRoot":"","sources":["../../src/models/prefer-export-under-component.model.ts"],"names":[],"mappings":";;;AAAA,IAAkB,QAEjB;AAFD,WAAkB,QAAQ;IACxB,6DAAiD,CAAA;AACnD,CAAC,EAFiB,QAAQ,wBAAR,QAAQ,QAEzB"}
@@ -0,0 +1,9 @@
1
+ export declare const enum Messages {
2
+ REQUIRE_REACT_FC = "REQUIRE_REACT_FC"
3
+ }
4
+ export type Options = [
5
+ Partial<{
6
+ allowArrowFunctions: boolean;
7
+ allowFunctionDeclarations: boolean;
8
+ }>
9
+ ];
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Messages = void 0;
4
+ var Messages;
5
+ (function (Messages) {
6
+ Messages["REQUIRE_REACT_FC"] = "REQUIRE_REACT_FC";
7
+ })(Messages || (exports.Messages = Messages = {}));
8
+ //# sourceMappingURL=prefer-react-fc.model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prefer-react-fc.model.js","sourceRoot":"","sources":["../../src/models/prefer-react-fc.model.ts"],"names":[],"mappings":";;;AAAA,IAAkB,QAEjB;AAFD,WAAkB,QAAQ;IACxB,iDAAqC,CAAA;AACvC,CAAC,EAFiB,QAAQ,wBAAR,QAAQ,QAEzB"}
@@ -0,0 +1,5 @@
1
+ export declare const enum Messages {
2
+ PREFER_REACT = "PREFER_REACT",
3
+ PREFER_REACT_PREFIX = "PREFER_REACT_PREFIX"
4
+ }
5
+ export type Options = [];
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Messages = void 0;
4
+ var Messages;
5
+ (function (Messages) {
6
+ Messages["PREFER_REACT"] = "PREFER_REACT";
7
+ Messages["PREFER_REACT_PREFIX"] = "PREFER_REACT_PREFIX";
8
+ })(Messages || (exports.Messages = Messages = {}));
9
+ //# sourceMappingURL=prefer-react-with-hooks.model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prefer-react-with-hooks.model.js","sourceRoot":"","sources":["../../src/models/prefer-react-with-hooks.model.ts"],"names":[],"mappings":";;;AAAA,IAAkB,QAGjB;AAHD,WAAkB,QAAQ;IACxB,yCAA6B,CAAA;IAC7B,uDAA2C,CAAA;AAC7C,CAAC,EAHiB,QAAQ,wBAAR,QAAQ,QAGzB"}
@@ -0,0 +1,8 @@
1
+ export declare const enum Messages {
2
+ NO_CONSOLE = "NO_CONSOLE"
3
+ }
4
+ export type Options = [
5
+ Partial<{
6
+ allow: string[];
7
+ }>
8
+ ];
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Messages = void 0;
4
+ var Messages;
5
+ (function (Messages) {
6
+ Messages["NO_CONSOLE"] = "NO_CONSOLE";
7
+ })(Messages || (exports.Messages = Messages = {}));
8
+ //# sourceMappingURL=restrict-console-methods.model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"restrict-console-methods.model.js","sourceRoot":"","sources":["../../src/models/restrict-console-methods.model.ts"],"names":[],"mappings":";;;AAAA,IAAkB,QAEjB;AAFD,WAAkB,QAAQ;IACxB,qCAAyB,CAAA;AAC3B,CAAC,EAFiB,QAAQ,wBAAR,QAAQ,QAEzB"}
@@ -0,0 +1,11 @@
1
+ export declare const enum Messages {
2
+ FUNCTION_DISALLOWED = "FUNCTION_DISALLOWED"
3
+ }
4
+ export type Options = [
5
+ Partial<{
6
+ allowFunctions: string[];
7
+ disableFunctions: string[];
8
+ files: string[];
9
+ folders: string[];
10
+ }>[]
11
+ ];
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Messages = void 0;
4
+ var Messages;
5
+ (function (Messages) {
6
+ Messages["FUNCTION_DISALLOWED"] = "FUNCTION_DISALLOWED";
7
+ })(Messages || (exports.Messages = Messages = {}));
8
+ //# sourceMappingURL=restrict-function-usage.model.js.map