Skip to content

Commit 9ed8d9e

Browse files
committed
feat: replace relative import closes nodejs#5484
1 parent 201d2e3 commit 9ed8d9e

File tree

71 files changed

+181
-163
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+181
-163
lines changed

.eslintrc

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,16 @@
88
"overrides": [
99
{
1010
"files": ["**/*.ts?(x)"],
11-
"plugins": ["@typescript-eslint"],
11+
"plugins": ["@typescript-eslint", "no-relative-import-paths"],
1212
"rules": {
13-
"@typescript-eslint/consistent-type-imports": "error"
13+
"@typescript-eslint/consistent-type-imports": "error",
14+
"no-relative-import-paths/no-relative-import-paths": [
15+
"warn",
16+
{
17+
"allowSameFolder": true,
18+
"prefix": "@"
19+
}
20+
]
1421
}
1522
},
1623
{

__fixtures__/nodeReleases.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { NodeRelease } from '../types';
1+
import type { NodeRelease } from '@/types';
22

33
export const createNodeReleases = (): NodeRelease[] => [
44
{

components/Api/ApiChanges/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { FormattedMessage } from 'react-intl';
22
import styles from './index.module.scss';
3-
import { parseApiDocsVersion } from '../../../util/parseApiDocsVersion';
4-
import type { ApiChange, ApiUpdate } from '../../../types';
3+
import { parseApiDocsVersion } from '@/util/parseApiDocsVersion';
4+
import type { ApiChange, ApiUpdate } from '@/types';
55
import type { FC } from 'react';
66

77
type ApiChangesProps = {

components/Article/Codebox/__tests__/index.test.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ import userEvent from '@testing-library/user-event';
22
import { render, screen } from '@testing-library/react';
33
import { IntlProvider } from 'react-intl';
44

5-
import Codebox, { replaceLabelLanguages, replaceLanguages } from '../index';
5+
import Codebox, {
6+
replaceLabelLanguages,
7+
replaceLanguages,
8+
} from '@/components/Article/Codebox/index';
69

710
describe('Replacer tests', (): void => {
811
it('replaceLabelLanguages', (): void => {

components/Article/Codebox/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { FormattedMessage } from 'react-intl';
33
import { highlight, languages } from 'prismjs';
44
import classnames from 'classnames';
55
import styles from './index.module.scss';
6-
import { useCopyToClipboard } from '../../../hooks/useCopyToClipboard';
6+
import { useCopyToClipboard } from '@/hooks/useCopyToClipboard';
77
import type { FC, PropsWithChildren, ReactElement, MouseEvent } from 'react';
88

99
type CodeBoxProps = {

components/Article/EditLink/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { FaPencilAlt } from 'react-icons/fa';
22
import { FormattedMessage } from 'react-intl';
33
import styles from './index.module.scss';
4-
import { useLocale } from './../../../hooks/useLocale';
4+
import { useLocale } from '@/hooks/useLocale';
55
import type { FC } from 'react';
66

77
type EditLinkProps = {

components/Blog/BlogCard/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { FormattedDate, FormattedMessage } from 'react-intl';
22
import styles from './index.module.scss';
3-
import LocalizedLink from '../../LocalizedLink';
4-
import navigation from '../../../navigation.json';
5-
import type { BlogPost } from '../../../types';
3+
import LocalizedLink from '@/components/LocalizedLink';
4+
import navigation from '@/navigation.json';
5+
import type { BlogPost } from '@/types';
66
import type { FC } from 'react';
77

88
const getBlogCategoryUrl = (category: string): string =>

components/Common/ActiveLocalizedLink/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { useRouter } from 'next/router';
22
import { useState, useEffect, type FC } from 'react';
33
import classNames from 'classnames';
4-
import LocalizedLink from '../../LocalizedLink';
4+
import LocalizedLink from '@/components/LocalizedLink';
55
import type Link from 'next/link';
66
import type { ComponentProps } from 'react';
77

components/Common/Banner/__tests__/index.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { render, screen } from '@testing-library/react';
22
import { IntlProvider } from 'react-intl';
3-
import Banner from '../index';
4-
import type { WebsiteBanner } from '../../../../types';
3+
import Banner from '@/components/Common/Banner/index';
4+
import type { WebsiteBanner } from '@/types';
55

66
const bannersIndex: WebsiteBanner = {
77
endDate: '',

components/Common/Banner/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { useMemo } from 'react';
22
import { useIntl } from 'react-intl';
33
import styles from './index.module.scss';
4-
import { dateIsBetween } from '../../../util/dateIsBetween';
5-
import { isAbsoluteUrl } from '../../../util/isAbsoluteUrl';
4+
import { dateIsBetween } from '@/util/dateIsBetween';
5+
import { isAbsoluteUrl } from '@/util/isAbsoluteUrl';
66
import type { FC } from 'react';
7-
import type { WebsiteBanner } from '../../../types';
7+
import type { WebsiteBanner } from '@/types';
88

99
const useTextContent = ({ text, link }: WebsiteBanner, bannerBtnText: string) =>
1010
useMemo(() => {

0 commit comments

Comments
 (0)