Skip to content

Commit

Permalink
chore: adds import/order eslint rule to demo-store template
Browse files Browse the repository at this point in the history
  • Loading branch information
QuintonC committed May 16, 2023
1 parent cd72b4a commit 7dcf57e
Show file tree
Hide file tree
Showing 53 changed files with 242 additions and 130 deletions.
34 changes: 34 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,38 @@ module.exports = {
'no-useless-escape': 'off',
'no-case-declarations': 'off',
},
overrides: [
{
files: ['./templates/demo-store/*'],
rules: {
'import/order': [
'error',
{
/**
* @description
*
* This keeps imports separate from one another, ensuring that imports are separated
* by their relative groups. As you move through the groups, imports become closer
* to the current file.
*
* @example
* ```
* import fs from 'fs';
*
* import package from 'npm-package';
*
* import xyz from '~/project-file';
*
* import index from '../';
*
* import sibling from './foo';
* ```
*/
groups: ['builtin', 'external', 'internal', 'parent', 'sibling'],
'newlines-between': 'always',
},
],
},
},
],
};
58 changes: 29 additions & 29 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 32 additions & 1 deletion templates/demo-store/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
* @type {import("@types/eslint").Linter.BaseConfig}
*/
module.exports = {
extends: ['plugin:hydrogen/recommended', 'plugin:hydrogen/typescript'],
extends: [
'@remix-run/eslint-config',
'plugin:hydrogen/recommended',
'plugin:hydrogen/typescript',
],
rules: {
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/naming-convention': 'off',
Expand All @@ -12,5 +16,32 @@ module.exports = {
'no-case-declarations': 'off',
// TODO: Remove jest plugin from hydrogen/eslint-plugin
'jest/no-deprecated-functions': 'off',
'import/order': [
'error',
{
/**
* @description
*
* This keeps imports separate from one another, ensuring that imports are separated
* by their relative groups. As you move through the groups, imports become closer
* to the current file.
*
* @example
* ```
* import fs from 'fs';
*
* import package from 'npm-package';
*
* import xyz from '~/project-file';
*
* import index from '../';
*
* import sibling from './foo';
* ```
*/
groups: ['builtin', 'external', 'internal', 'parent', 'sibling'],
'newlines-between': 'always',
},
],
},
};
1 change: 1 addition & 0 deletions templates/demo-store/app/components/AccountAddressBook.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type {
Customer,
MailingAddress,
} from '@shopify/hydrogen/storefront-api-types';

import {Button, Link, Text} from '~/components';

export function AccountAddressBook({
Expand Down
1 change: 1 addition & 0 deletions templates/demo-store/app/components/AccountDetails.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type {Customer} from '@shopify/hydrogen/storefront-api-types';

import {Link} from '~/components';

export function AccountDetails({customer}: {customer: Customer}) {
Expand Down
1 change: 1 addition & 0 deletions templates/demo-store/app/components/AddToCartButton.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type {CartLineInput} from '@shopify/hydrogen/storefront-api-types';
import {useFetcher, useMatches, useNavigation} from '@remix-run/react';

import {Button} from '~/components';
import {CartAction} from '~/lib/type';

Expand Down
15 changes: 8 additions & 7 deletions templates/demo-store/app/components/Cart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@ import clsx from 'clsx';
import {useRef} from 'react';
import {useScroll} from 'react-use';
import {flattenConnection, Image, Money} from '@shopify/hydrogen';
import type {
Cart as CartType,
CartCost,
CartLine,
CartLineUpdateInput,
} from '@shopify/hydrogen/storefront-api-types';
import {useFetcher} from '@remix-run/react';

import {
Button,
Heading,
Expand All @@ -11,13 +19,6 @@ import {
FeaturedProducts,
} from '~/components';
import {getInputStyleClasses} from '~/lib/utils';
import type {
Cart as CartType,
CartCost,
CartLine,
CartLineUpdateInput,
} from '@shopify/hydrogen/storefront-api-types';
import {useFetcher} from '@remix-run/react';
import {CartAction} from '~/lib/type';

type Layouts = 'page' | 'drawer';
Expand Down
10 changes: 6 additions & 4 deletions templates/demo-store/app/components/CountrySelector.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import {useFetcher, useLocation, useMatches} from '@remix-run/react';
import {Heading, Button, IconCheck} from '~/components';
import {useCallback, useEffect, useRef} from 'react';
import {useInView} from 'react-intersection-observer';
import {Localizations, Locale, CartAction} from '~/lib/type';
import {DEFAULT_LOCALE} from '~/lib/utils';
import clsx from 'clsx';
import {CartBuyerIdentityInput} from '@shopify/hydrogen/storefront-api-types';
import type {CartBuyerIdentityInput} from '@shopify/hydrogen/storefront-api-types';

import {Heading, Button, IconCheck} from '~/components';
import type {Localizations, Locale} from '~/lib/type';
import {CartAction} from '~/lib/type';
import {DEFAULT_LOCALE} from '~/lib/utils';

export function CountrySelector() {
const [root] = useMatches();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {Image} from '@shopify/hydrogen';
import type {Collection} from '@shopify/hydrogen/storefront-api-types';

import {Heading, Section, Grid, Link} from '~/components';

export function FeaturedCollections({
Expand Down
3 changes: 2 additions & 1 deletion templates/demo-store/app/components/FeaturedProducts.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import clsx from 'clsx';
import {useEffect, useId, useMemo} from 'react';
import {useFetcher} from '@remix-run/react';
import {Heading, ProductCard, Skeleton, Text} from '~/components';
import type {
Product,
ProductSortKeys,
} from '@shopify/hydrogen/storefront-api-types';

import {Heading, ProductCard, Skeleton, Text} from '~/components';
import {usePrefixPathWithLocale} from '~/lib/utils';

interface FeaturedProductsProps {
Expand Down
4 changes: 3 additions & 1 deletion templates/demo-store/app/components/FeaturedSection.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import {useEffect} from 'react';
import {useFetcher} from '@remix-run/react';
import type {Collection, Product} from '@shopify/hydrogen/storefront-api-types';

import {usePrefixPathWithLocale} from '~/lib/utils';

import {FeaturedCollections} from './FeaturedCollections';
import {ProductSwimlane} from './ProductSwimlane';
import {usePrefixPathWithLocale} from '~/lib/utils';

export interface FeaturedData {
featuredCollections: Collection[];
Expand Down
1 change: 1 addition & 0 deletions templates/demo-store/app/components/Hero.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import type {
Metafield,
Video as MediaVideo,
} from '@shopify/hydrogen/storefront-api-types';

import {Heading, Text, Link} from '~/components';

export interface CollectionHero {
Expand Down
20 changes: 11 additions & 9 deletions templates/demo-store/app/components/Layout.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {
type EnhancedMenu,
type EnhancedMenuItem,
useIsHomePath,
} from '~/lib/utils';
import {useParams, Form, Await, useMatches} from '@remix-run/react';
import {useWindowScroll} from 'react-use';
import {Disclosure} from '@headlessui/react';
import {Suspense, useEffect, useMemo} from 'react';

import {
Drawer,
useDrawer,
Expand All @@ -21,12 +21,14 @@ import {
CartLoading,
Link,
} from '~/components';
import {useParams, Form, Await, useMatches} from '@remix-run/react';
import {useWindowScroll} from 'react-use';
import {Disclosure} from '@headlessui/react';
import {Suspense, useEffect, useMemo} from 'react';
import {
type EnhancedMenu,
type EnhancedMenuItem,
useIsHomePath,
} from '~/lib/utils';
import {useIsHydrated} from '~/hooks/useIsHydrated';
import {useCartFetchers} from '~/hooks/useCartFetchers';

import type {LayoutData} from '../root';

export function Layout({
Expand Down
Loading

0 comments on commit 7dcf57e

Please sign in to comment.