Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: adds import/order eslint rule to demo-store template #895

Merged
merged 1 commit into from
May 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/tricky-rocks-perform.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'demo-store': patch
---

Added import/order ESLint rule and @remix-run/eslint plugin to demo-store template eslint configuration.
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/*'],
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was included to ensure that the pre-commit scripts for eslint used the correct import/order definition since the lint configuration at the root of the monorepo will be used for the eslint check.

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
Loading