Skip to content

Commit 1a7106f

Browse files
committed
internal imports now prefixed with @
1 parent de7db23 commit 1a7106f

15 files changed

+50
-38
lines changed

eslint.config.js

+8
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,14 @@ export default tseslint.config(
6969
"type",
7070
"unknown"
7171
],
72+
"pathGroups": [
73+
{
74+
"pattern": "@*",
75+
"group": "internal",
76+
"position": "after"
77+
}
78+
],
79+
"pathGroupsExcludedImportTypes": ["builtin", "internal"],
7280
"newlines-between": "always",
7381
"alphabetize": {
7482
"order": "asc",

src/App.tsx

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import SnippetList from "components/SnippetList";
2-
import { useAppContext } from "contexts/AppContext";
3-
import Banner from "layouts/Banner";
4-
import Footer from "layouts/Footer";
5-
import Header from "layouts/Header";
6-
import Sidebar from "layouts/Sidebar";
1+
import SnippetList from "@components/SnippetList";
2+
import { useAppContext } from "@contexts/AppContext";
3+
import Banner from "@layouts/Banner";
4+
import Footer from "@layouts/Footer";
5+
import Header from "@layouts/Header";
6+
import Sidebar from "@layouts/Sidebar";
77

88
const App = () => {
99
const { category } = useAppContext();

src/components/CategoryList.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { useEffect } from "react";
22

3-
import { useAppContext } from "contexts/AppContext";
4-
import { useCategories } from "hooks/useCategories";
3+
import { useAppContext } from "@contexts/AppContext";
4+
import { useCategories } from "@hooks/useCategories";
55

66
const CategoryList = () => {
77
const { category, setCategory } = useAppContext();

src/components/LanguageSelector.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { useRef, useEffect, useState } from "react";
22

3-
import { useAppContext } from "contexts/AppContext";
4-
import { useKeyboardNavigation } from "hooks/useKeyboardNavigation";
5-
import { useLanguages } from "hooks/useLanguages";
6-
import { LanguageType } from "types";
3+
import { useAppContext } from "@contexts/AppContext";
4+
import { useKeyboardNavigation } from "@hooks/useKeyboardNavigation";
5+
import { useLanguages } from "@hooks/useLanguages";
6+
import { LanguageType } from "@types";
77

88
// Inspired by https://blog.logrocket.com/creating-custom-select-dropdown-css/
99

src/components/SnippetList.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { useState } from "react";
22

3-
import { useAppContext } from "contexts/AppContext";
4-
import { useSnippets } from "hooks/useSnippets";
5-
import { SnippetType } from "types";
3+
import { useAppContext } from "@contexts/AppContext";
4+
import { useSnippets } from "@hooks/useSnippets";
5+
import { SnippetType } from "@types";
66

77
import { LeftAngleArrowIcon } from "./Icons";
88
import SnippetModal from "./SnippetModal";

src/components/SnippetModal.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import React from "react";
22
import ReactDOM from "react-dom";
33

4-
import { useEscapeKey } from "hooks/useEscapeKey";
5-
import { SnippetType } from "types";
6-
import { slugify } from "utils/slugify";
4+
import { useEscapeKey } from "@hooks/useEscapeKey";
5+
import { SnippetType } from "@types";
6+
import { slugify } from "@utils/slugify";
77

88
import Button from "./Button";
99
import CodePreview from "./CodePreview";

src/contexts/AppContext.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { createContext, FC, useContext, useState } from "react";
22

3-
import { AppState, LanguageType, SnippetType } from "types";
3+
import { AppState, LanguageType, SnippetType } from "@types";
44

55
// tokens
66
const defaultLanguage: LanguageType = {

src/hooks/useCategories.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { useMemo } from "react";
22

3-
import { useAppContext } from "contexts/AppContext";
4-
import { SnippetType } from "types";
5-
import { slugify } from "utils/slugify";
3+
import { useAppContext } from "@contexts/AppContext";
4+
import { SnippetType } from "@types";
5+
import { slugify } from "@utils/slugify";
66

77
import { useFetch } from "./useFetch";
88

src/hooks/useKeyboardNavigation.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useState } from "react";
22

3-
import { LanguageType } from "types";
3+
import { LanguageType } from "@types";
44

55
interface UseKeyboardNavigationProps {
66
items: LanguageType[];

src/hooks/useLanguages.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { LanguageType } from "types";
1+
import { LanguageType } from "@types";
22

33
import { useFetch } from "./useFetch";
44

src/hooks/useSnippets.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { useAppContext } from "contexts/AppContext";
2-
import { SnippetType } from "types";
3-
import { slugify } from "utils/slugify";
1+
import { useAppContext } from "@contexts/AppContext";
2+
import { SnippetType } from "@types";
3+
import { slugify } from "@utils/slugify";
44

55
import { useFetch } from "./useFetch";
66

src/layouts/Header.tsx

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { GitHubIcon } from "components/Icons";
2-
import LinkButton from "components/LinkButton";
3-
import Logo from "components/Logo";
4-
import SearchInput from "components/SearchInput";
5-
import ThemeToggle from "components/ThemeToggle";
1+
import { GitHubIcon } from "@components/Icons";
2+
import LinkButton from "@components/LinkButton";
3+
import Logo from "@components/Logo";
4+
import SearchInput from "@components/SearchInput";
5+
import ThemeToggle from "@components/ThemeToggle";
66

77
const Header = () => {
88
return (

src/layouts/Sidebar.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import CategoryList from "components/CategoryList";
2-
import LanguageSelector from "components/LanguageSelector";
1+
import CategoryList from "@components/CategoryList";
2+
import LanguageSelector from "@components/LanguageSelector";
33

44
const Sidebar = () => {
55
return (

src/main.tsx

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
import "styles/main.css";
1+
import "@styles/main.css";
22

33
import { StrictMode } from "react";
44
import { createRoot } from "react-dom/client";
55

6-
import App from "App";
7-
import { AppProvider } from "contexts/AppContext";
6+
import { AppProvider } from "@contexts/AppContext";
7+
8+
import App from "./App";
89

910
createRoot(document.getElementById("root")!).render(
1011
<StrictMode>

tsconfig.app.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
"lib": ["ES2020", "DOM", "DOM.Iterable"],
66
"module": "ESNext",
77
"skipLibCheck": true,
8-
"baseUrl": "./src",
8+
"baseUrl": "./",
9+
"paths": {
10+
"@*": ["src/*"]
11+
},
912

1013
/* Bundler mode */
1114
"moduleResolution": "bundler",

0 commit comments

Comments
 (0)