Browse Source

Feature: New eslint rules added.

lfabl 2 weeks ago
parent
commit
57c0be5ee2

+ 31 - 0
eslint-local-rules/index.js

@@ -962,5 +962,36 @@ module.exports = {
                 }
             };
         }
+    },
+    "jsx-no-blank-lines": {
+        meta: {
+            type: "layout",
+            fixable: "whitespace",
+            schema: []
+        },
+        create(context) {
+            return {
+                JSXText(node) {
+                    const text = node.value;
+                    if (!/^\s*$/.test(text)) {
+                        return;
+                    }
+
+                    const newlines = text.match(/\n/g);
+                    if (newlines && newlines.length > 1) {
+                        context.report({
+                            node,
+                            message: "No blank lines allowed between JSX elements",
+                            fix(fixer) {
+                                const match = text.match(/\n[ \t]*$/);
+                                if (match) {
+                                    return fixer.replaceText(node, match[0]);
+                                }
+                            }
+                        });
+                    }
+                }
+            };
+        }
     }
 };

+ 1 - 0
eslint.config.mjs

@@ -32,6 +32,7 @@ export default tseslint.config(
             "local-rules/no-jsx-parens-in-return": "error",
             "local-rules/no-newline-after-jsx": "error",
             "local-rules/no-static-inline-styles": "error",
+            "local-rules/jsx-no-blank-lines": "error",
             "@typescript-eslint/no-empty-object-type": [
                 "error",
                 {

+ 0 - 1
example/src/pages/components/timeSelector/index.tsx

@@ -79,7 +79,6 @@ const TimeSelectorPage = () => {
             >
                 {localize("components-timeSelector")}
             </Text>
-
             <TimeSelector
                 setIsSheetContentReady={setIsSheetContentReady}
                 selectMultipleObject={() => {}}

+ 0 - 3
example/src/pages/coreFeatures/defaultJSONs/index.tsx

@@ -93,7 +93,6 @@ const DefaultJSONs = () => {
         >
             {localize("defaultJSONs-desc")}
         </Text>
-
         <Text
             variant="titleMediumSize"
             color="high"
@@ -121,7 +120,6 @@ const DefaultJSONs = () => {
                 language="json"
             />
         </View>
-
         <Text
             variant="titleMediumSize"
             color="high"
@@ -150,7 +148,6 @@ const DefaultJSONs = () => {
                 language="json"
             />
         </View>
-
         <View
             style={[
                 stylesheet.rowSpaceBetween,

+ 0 - 5
example/src/pages/coreFeatures/localeExamples/index.tsx

@@ -89,7 +89,6 @@ const LocaleExamples = () => {
         >
             <LocaleSwitcher/>
         </View>
-
         <View
             style={[
                 stylesheet.borderedCard,
@@ -109,7 +108,6 @@ const LocaleExamples = () => {
             >
                 {localize("localeExamples-localizedTexts")}
             </Text>
-
             <Text
                 color="mid"
                 style={{
@@ -123,7 +121,6 @@ const LocaleExamples = () => {
                     {activeLocale}
                 </Text>
             </Text>
-
             <View
                 style={[
                     stylesheet.borderedCard2,
@@ -178,7 +175,6 @@ const LocaleExamples = () => {
                 </View>
             </View>
         </View>
-
         <View
             style={[
                 stylesheet.rowSpaceBetween,
@@ -204,7 +200,6 @@ const LocaleExamples = () => {
                 }}
                 title={localize("themeExamples-title")}
             />
-
             <Button
                 icon={({
                     color,

+ 0 - 5
example/src/pages/coreFeatures/toolsUsage/index.tsx

@@ -139,7 +139,6 @@ const MyComponent = () => {
         >
             {localize("toolsUsage-desc")}
         </Text>
-
         <Text
             variant="titleMediumSize"
             color="high"
@@ -167,7 +166,6 @@ const MyComponent = () => {
                 language="tsx"
             />
         </View>
-
         <Text
             variant="titleMediumSize"
             color="high"
@@ -195,7 +193,6 @@ const MyComponent = () => {
                 language="tsx"
             />
         </View>
-
         <Text
             variant="titleMediumSize"
             color="high"
@@ -223,7 +220,6 @@ const MyComponent = () => {
                 language="tsx"
             />
         </View>
-
         <View
             style={[
                 stylesheet.rowSpaceBetween,
@@ -249,7 +245,6 @@ const MyComponent = () => {
                     });
                 }}
             />
-
             <Button
                 icon={({
                     color,

+ 0 - 4
example/src/pages/coreFeatures/typesOverride/index.tsx

@@ -118,7 +118,6 @@ const TypesOverride = () => {
         >
             {localize("typesOverride-desc")}
         </Text>
-
         <Text
             variant="titleMediumSize"
             color="high"
@@ -146,7 +145,6 @@ const TypesOverride = () => {
                 language="tsx"
             />
         </View>
-
         <Text
             variant="titleMediumSize"
             color="high"
@@ -174,7 +172,6 @@ const TypesOverride = () => {
                 language="json"
             />
         </View>
-
         <View
             style={[
                 stylesheet.rowSpaceBetween,
@@ -200,7 +197,6 @@ const TypesOverride = () => {
                     });
                 }}
             />
-
             <Button
                 icon={({
                     color,

+ 0 - 1
src/components/button/index.tsx

@@ -220,7 +220,6 @@ const Button: FC<IButtonProps> = ({
         {renderIcon("left")}
         {renderTitle()}
         {renderIcon("right")}
-
         {renderOverlay()}
     </TouchableOpacity>;
 };

+ 0 - 3
src/components/checkBox/index.tsx

@@ -194,7 +194,6 @@ const CheckBox: FC<ICheckBoxProps> = ({
             ]}
         >
             {renderCheckIcon()}
-
             {renderOverlay()}
         </View>;
     };
@@ -260,9 +259,7 @@ const CheckBox: FC<ICheckBoxProps> = ({
         })}
     >
         {isFlip ? null : renderCheckIndicator()}
-
         {renderContent()}
-
         {isFlip ? renderCheckIndicator() : null}
     </TouchableOpacity>;
 };

+ 0 - 6
src/components/dateTimePicker/index.tsx

@@ -901,7 +901,6 @@ const DateTimePicker = ({
         ]}
     >
         {renderTitle()}
-
         <TouchableOpacity
             disabled={isDisabled}
             style={[
@@ -916,17 +915,12 @@ const DateTimePicker = ({
             }}
         >
             {renderOverlay()}
-
             {renderIcon()}
-
             {renderContent()}
-
             {renderCleanButton()}
             {renderRightIcon()}
         </TouchableOpacity>
-
         {renderHintText()}
-
         <DateTimeSheet
             isTimeSelectWorksWithCenterWhenTimePicker={isTimeSelectWorksWithCenterWhenTimePicker}
             multipleSelectMinimumRequiredDayCount={multipleSelectMinimumRequiredDayCount}

+ 0 - 1
src/components/highlightButton/index.tsx

@@ -196,7 +196,6 @@ const HighlightButton: FC<IHighlightButtonProps> = ({
         {renderIcon("left")}
         {renderTitle()}
         {renderIcon("right")}
-
         {renderOverlay()}
     </TouchableOpacity>;
 };

+ 0 - 1
src/components/markdownEditor/index.tsx

@@ -347,7 +347,6 @@ const MarkdownEditor: FC<IMarkdownEditorProps> = ({
                     dynamicStyles.toolbarSeparator
                 ]}
             />
-
             <ScrollView
                 horizontal
                 showsHorizontalScrollIndicator={false}

+ 0 - 5
src/components/numericInput/index.tsx

@@ -596,7 +596,6 @@ const NumericInput: RefForwardingComponent<INumericInputRef, ITextInputProps> =
         })}
     >
         {renderTitle()}
-
         <View
             style={[
                 contentContainerStyle,
@@ -605,16 +604,12 @@ const NumericInput: RefForwardingComponent<INumericInputRef, ITextInputProps> =
             ]}
         >
             {renderIcon()}
-
             {renderInput()}
-
             {renderCleanButton()}
             {renderHideTextIcon()}
             {renderRightIcon()}
-
             {renderOverlay()}
         </View>
-
         {renderHintText()}
     </TouchableOpacity>;
 };

+ 0 - 3
src/components/radioButton/index.tsx

@@ -190,7 +190,6 @@ const RadioButton: FC<IRadioButtonProps> = ({
             ]}
         >
             {renderIndicator()}
-
             {renderOverlay()}
         </View>;
     };
@@ -256,9 +255,7 @@ const RadioButton: FC<IRadioButtonProps> = ({
         })}
     >
         {isFlip ? null : renderIndicatorContainer()}
-
         {renderContent()}
-
         {isFlip ? renderIndicatorContainer() : null}
     </TouchableOpacity>;
 };

+ 0 - 6
src/components/selectBox/index.tsx

@@ -801,7 +801,6 @@ function SelectBox<T>({
         ]}
     >
         {renderTitle()}
-
         <TouchableOpacity
             disabled={isDisabled}
             style={[
@@ -816,17 +815,12 @@ function SelectBox<T>({
             }}
         >
             {renderOverlay()}
-
             {renderIcon()}
-
             {renderContent()}
-
             {renderCleanButton()}
             {renderRightIcon()}
         </TouchableOpacity>
-
         {renderHintText()}
-
         <SelectSheet
             LoadingIconComponentProp={LoadingIconComponentProp}
             customLocalize={customSelectSheetLocalize}

+ 0 - 3
src/components/switch/index.tsx

@@ -211,7 +211,6 @@ const Switch: FC<ISwitchProps> = ({
             ]}
         >
             {renderIndicator()}
-
             {renderOverlay()}
         </View>;
     };
@@ -277,9 +276,7 @@ const Switch: FC<ISwitchProps> = ({
         })}
     >
         {isFlip ? null : renderIndicatorContainer()}
-
         {renderContent()}
-
         {isFlip ? renderIndicatorContainer() : null}
     </TouchableOpacity>;
 };

+ 0 - 5
src/components/textAreaInput/index.tsx

@@ -545,7 +545,6 @@ const TextAreaInput: RefForwardingComponent<ITextAreaInputRef, ITextAreaInputPro
         })}
     >
         {renderTitle()}
-
         <View
             style={[
                 contentContainerStyle,
@@ -554,15 +553,11 @@ const TextAreaInput: RefForwardingComponent<ITextAreaInputRef, ITextAreaInputPro
             ]}
         >
             {renderOverlay()}
-
             {renderIcon()}
-
             {renderInput()}
-
             {renderCleanButton()}
             {renderRightIcon()}
         </View>
-
         {renderHintText()}
     </View>;
 };

+ 0 - 5
src/components/textInput/index.tsx

@@ -538,7 +538,6 @@ const TextInput: RefForwardingComponent<ITextInputRef, ITextInputProps> = ({
         })}
     >
         {renderTitle()}
-
         <View
             style={[
                 contentContainerStyle,
@@ -547,16 +546,12 @@ const TextInput: RefForwardingComponent<ITextInputRef, ITextInputProps> = ({
             ]}
         >
             {renderIcon()}
-
             {renderInput()}
-
             {renderCleanButton()}
             {renderHideTextIcon()}
             {renderRightIcon()}
-
             {renderOverlay()}
         </View>
-
         {renderHintText()}
     </TouchableOpacity>;
 };

+ 0 - 1
src/helpers/portalize/Host.tsx

@@ -114,7 +114,6 @@ export const Host = ({
         >
             {children}
         </View>
-
         <Manager
             ref={managerRef}
             name={name}