NMF-earth / nmf-app

Understand and reduce your carbon footprint 🌱 iOS & Android.
https://nmf.earth
GNU General Public License v3.0
498 stars 156 forks source link

Fixed the unexpected line break in the imports group #240

Closed hb2708 closed 3 years ago

hb2708 commented 3 years ago

✅ I have read the contributing file

Summary

Fixes #172 issue where auto save -> Reformat add extra new line in the imports

Changelog

Updated newlines-between to always as per https://dev.to/otamnitram/sorting-your-imports-correctly-in-react-213m

Demo

On top of BudgetScreen.tsx, we have :

import React from "react";
import { ScrollView } from "react-native";
import { useSelector } from "react-redux";

import styles from "./BudgetScreen.styles";
import { Text, Button } from "../../components";

If changed it to the following :

import React from "react";
import { ScrollView } from "react-native";

import styles from "./BudgetScreen.styles";
import { useSelector } from "react-redux";
import { Text, Button } from "../../components";

And save the file, get the following :

import React from "react";
import { ScrollView } from "react-native";
import { useSelector } from "react-redux";

import styles from "./BudgetScreen.styles";
import { Text, Button } from "../../components";

Instead of :

import React from "react";
import { ScrollView } from "react-native";

import { useSelector } from "react-redux";

import styles from "./BudgetScreen.styles";
import { Text, Button } from "../../components";
hb2708 commented 3 years ago

Okey so the above cases works but this cases like this fails. nmf-app/app/utils/translations/resources.ts image

hb2708 commented 3 years ago

See this from the the eslint doc

/* eslint import/order: ["error", {"newlines-between": "always-and-inside-groups"}] */
import fs from 'fs';

import path from 'path';

import index from './';

import sibling from './foo';

always-and-inside-groups Is the culprit to give u the extra new line, and you get following output.

import React from "react";
import { ScrollView } from "react-native";

import { useSelector } from "react-redux";

import styles from "./BudgetScreen.styles";
import { Text, Button } from "../../components";
PierreBresson commented 3 years ago

@hb2708 : almost there. However, you need to have the CI working before merging like mentionned in the contributing file.

To do so:

hb2708 commented 3 years ago

@PierreBresson Thanks for confirming about the case above. Applied the changes and pushed. CI Checks are passed now

PierreBresson commented 3 years ago

@hb2708 thanks for the changes :)