eslint-plugin-flawless 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -176,11 +176,13 @@ pnpm eslint-docs
176
176
  💭
177
177
  Requires [type information](https://typescript-eslint.io/linting/typed-linting).
178
178
 
179
- | Name                       | Description | 🔧 | 💭 |
180
- | :---------------------------------------------------------------------------------- | :-------------------------------------------------------------- | :-- | :-- |
181
- | [naming-convention](src/rules/naming-convention/documentation.md) | Enforce naming conventions for everything across a codebase | | 💭 |
182
- | [toml-sort-keys](src/rules/toml-sort-keys/documentation.md) | Enforce a configured sort order for TOML keys and tables | 🔧 | |
183
- | [yaml-block-key-blank-lines](src/rules/yaml-block-key-blank-lines/documentation.md) | Enforce blank lines around top-level YAML block collection keys | 🔧 | |
179
+ | Name                       | Description | 🔧 | 💭 |
180
+ | :---------------------------------------------------------------------------------- | :------------------------------------------------------------------- | :-- | :-- |
181
+ | [jsx-shorthand-boolean](src/rules/jsx-shorthand-boolean/documentation.md) | Disallow shorthand boolean JSX attributes | 🔧 | |
182
+ | [jsx-shorthand-fragment](src/rules/jsx-shorthand-fragment/documentation.md) | Disallow the shorthand fragment syntax in favour of a named fragment | 🔧 | |
183
+ | [naming-convention](src/rules/naming-convention/documentation.md) | Enforce naming conventions for everything across a codebase | | 💭 |
184
+ | [toml-sort-keys](src/rules/toml-sort-keys/documentation.md) | Enforce a configured sort order for TOML keys and tables | 🔧 | |
185
+ | [yaml-block-key-blank-lines](src/rules/yaml-block-key-blank-lines/documentation.md) | Enforce blank lines around top-level YAML block collection keys | 🔧 | |
184
186
 
185
187
  <!-- end auto-generated rules list -->
186
188
 
package/dist/index.d.mts CHANGED
@@ -8,6 +8,9 @@ interface PluginDocumentation {
8
8
  requiresTypeChecking: boolean;
9
9
  }
10
10
  //#endregion
11
+ //#region src/rules/jsx-shorthand-fragment/rule.d.ts
12
+ type Options$2 = [fragmentName?: string];
13
+ //#endregion
11
14
  //#region src/rules/naming-convention/utils/enums.d.ts
12
15
  declare const Selector: {
13
16
  readonly variable: 1;
@@ -138,6 +141,12 @@ declare const plugin: {
138
141
  version: string;
139
142
  };
140
143
  rules: {
144
+ "jsx-shorthand-boolean": TSESLint.RuleModule<"setAttributeValue", [], PluginDocumentation, TSESLint.RuleListener> & {
145
+ name: string;
146
+ };
147
+ "jsx-shorthand-fragment": TSESLint.RuleModule<"useNamedFragment", Options$2, PluginDocumentation, TSESLint.RuleListener> & {
148
+ name: string;
149
+ };
141
150
  "naming-convention": TSESLint.RuleModule<MessageIds, Options$1, PluginDocumentation, TSESLint.RuleListener> & {
142
151
  name: string;
143
152
  };
@@ -161,6 +170,12 @@ declare const _default: {
161
170
  version: string;
162
171
  };
163
172
  rules: {
173
+ "jsx-shorthand-boolean": import("${configDir}").RuleModule<"setAttributeValue", [], PluginDocumentation, import("${configDir}").RuleListener> & {
174
+ name: string;
175
+ };
176
+ "jsx-shorthand-fragment": import("${configDir}").RuleModule<"useNamedFragment", Options$2, PluginDocumentation, import("${configDir}").RuleListener> & {
177
+ name: string;
178
+ };
164
179
  "naming-convention": import("${configDir}").RuleModule<MessageIds, Options$1, PluginDocumentation, import("${configDir}").RuleListener> & {
165
180
  name: string;
166
181
  };
@@ -181,6 +196,12 @@ declare const _default: {
181
196
  version: string;
182
197
  };
183
198
  rules: {
199
+ "jsx-shorthand-boolean": import("${configDir}").RuleModule<"setAttributeValue", [], PluginDocumentation, import("${configDir}").RuleListener> & {
200
+ name: string;
201
+ };
202
+ "jsx-shorthand-fragment": import("${configDir}").RuleModule<"useNamedFragment", Options$2, PluginDocumentation, import("${configDir}").RuleListener> & {
203
+ name: string;
204
+ };
184
205
  "naming-convention": import("${configDir}").RuleModule<MessageIds, Options$1, PluginDocumentation, import("${configDir}").RuleListener> & {
185
206
  name: string;
186
207
  };
package/dist/index.mjs CHANGED
@@ -1,12 +1,12 @@
1
+ import { RuleCreator, getParserServices } from "@typescript-eslint/utils/eslint-utils";
1
2
  import { DefinitionType, ImplicitLibVariable, PatternVisitor, ScopeType, Visitor } from "@typescript-eslint/scope-manager";
2
3
  import { requiresQuoting } from "@typescript-eslint/type-utils";
3
4
  import { ASTUtils, AST_NODE_TYPES, ESLintUtils, TSESLint } from "@typescript-eslint/utils";
4
- import { RuleCreator, getParserServices } from "@typescript-eslint/utils/eslint-utils";
5
5
  import assert from "node:assert";
6
6
  import { getStaticTOMLValue } from "toml-eslint-parser";
7
7
  //#region package.json
8
8
  var name = "eslint-plugin-flawless";
9
- var version = "0.1.2";
9
+ var version = "0.1.3";
10
10
  var repository = {
11
11
  "url": "git+https://github.com/christopher-buss/eslint-plugin-flawless.git",
12
12
  "type": "git"
@@ -32,6 +32,82 @@ function createEslintRule(rule) {
32
32
  return createRule(rule);
33
33
  }
34
34
  //#endregion
35
+ //#region src/rules/jsx-shorthand-boolean/rule.ts
36
+ const RULE_NAME$4 = "jsx-shorthand-boolean";
37
+ const MESSAGE_ID$2 = "setAttributeValue";
38
+ const messages$4 = { [MESSAGE_ID$2]: "Set an explicit value for boolean attribute '{{name}}'." };
39
+ function create$4(context) {
40
+ const { sourceCode } = context;
41
+ return { JSXAttribute(node) {
42
+ if (node.value !== null) return;
43
+ context.report({
44
+ data: { name: sourceCode.getText(node.name) },
45
+ fix: (fixer) => fixer.insertTextAfter(node.name, "={true}"),
46
+ messageId: MESSAGE_ID$2,
47
+ node
48
+ });
49
+ } };
50
+ }
51
+ const jsxShorthandBoolean = createEslintRule({
52
+ name: RULE_NAME$4,
53
+ create: create$4,
54
+ defaultOptions: [],
55
+ meta: {
56
+ docs: {
57
+ description: "Disallow shorthand boolean JSX attributes",
58
+ recommended: false,
59
+ requiresTypeChecking: false
60
+ },
61
+ fixable: "code",
62
+ hasSuggestions: false,
63
+ messages: messages$4,
64
+ schema: [],
65
+ type: "suggestion"
66
+ }
67
+ });
68
+ //#endregion
69
+ //#region src/rules/jsx-shorthand-fragment/rule.ts
70
+ const RULE_NAME$3 = "jsx-shorthand-fragment";
71
+ const MESSAGE_ID$1 = "useNamedFragment";
72
+ const DEFAULT_FRAGMENT_NAME = "Fragment";
73
+ const messages$3 = { [MESSAGE_ID$1]: "Use the '{{name}}' component instead of fragment shorthand syntax." };
74
+ const schema$1 = [{
75
+ description: "The identifier to use for the named fragment element.",
76
+ type: "string"
77
+ }];
78
+ function create$3(context) {
79
+ const name = context.options[0] ?? DEFAULT_FRAGMENT_NAME;
80
+ return { JSXFragment(node) {
81
+ const { closingFragment, openingFragment } = node;
82
+ context.report({
83
+ data: { name },
84
+ fix: (fixer) => {
85
+ return [fixer.replaceText(openingFragment, `<${name}>`), fixer.replaceText(closingFragment, `</${name}>`)];
86
+ },
87
+ messageId: MESSAGE_ID$1,
88
+ node
89
+ });
90
+ } };
91
+ }
92
+ const jsxShorthandFragment = createEslintRule({
93
+ name: RULE_NAME$3,
94
+ create: create$3,
95
+ defaultOptions: [DEFAULT_FRAGMENT_NAME],
96
+ meta: {
97
+ defaultOptions: [DEFAULT_FRAGMENT_NAME],
98
+ docs: {
99
+ description: "Disallow the shorthand fragment syntax in favour of a named fragment",
100
+ recommended: false,
101
+ requiresTypeChecking: false
102
+ },
103
+ fixable: "code",
104
+ hasSuggestions: false,
105
+ messages: messages$3,
106
+ schema: schema$1,
107
+ type: "suggestion"
108
+ }
109
+ });
110
+ //#endregion
35
111
  //#region src/utils/is-type-import.ts
36
112
  /**
37
113
  * Determine whether a variable definition is a type import. E.g.:.
@@ -1878,6 +1954,8 @@ const plugin = {
1878
1954
  version
1879
1955
  },
1880
1956
  rules: {
1957
+ "jsx-shorthand-boolean": jsxShorthandBoolean,
1958
+ "jsx-shorthand-fragment": jsxShorthandFragment,
1881
1959
  "naming-convention": namingConvention,
1882
1960
  "toml-sort-keys": tomlSortKeys,
1883
1961
  "yaml-block-key-blank-lines": yamlBlockKeyBlankLines
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-flawless",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "Your ESLint plugin description",
5
5
  "keywords": [
6
6
  "eslint",