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

Add alias for absolute imports in coral. #150

Merged
merged 5 commits into from
Oct 26, 2022
Merged
Show file tree
Hide file tree
Changes from 4 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
6 changes: 5 additions & 1 deletion coral/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,17 @@ module.exports = {
},
"plugins": [
"react",
"@typescript-eslint"
"@typescript-eslint",
"no-relative-import-paths"
],
"settings": {
"react": {
"version": "detect"
}
},
"rules": {
"no-relative-import-paths/no-relative-import-paths": [
"error"
]
}
}
4 changes: 2 additions & 2 deletions coral/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ export default {
moduleFileExtensions: ["js", "jsx", "ts", "tsx"],
preset: "ts-jest",
testEnvironment: "jsdom",
setupFilesAfterEnv: ['<rootDir>/test-setup/setup-files-after-env.ts'],
setupFilesAfterEnv: ["<rootDir>/test-setup/setup-files-after-env.ts"],
moduleNameMapper: {
".+\\.(png|jpg|ttf|woff|woff2|svg)$": "jest-transform-stub",
"\\.css$": "identity-obj-proxy",
"^@/(.*)$": "<rootDir>/src/$1",
"^src/(.*)$": "<rootDir>/src/$1",
},
};
1 change: 1 addition & 0 deletions coral/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"@vitejs/plugin-react": "^2.1.0",
"eslint": "^8.25.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-no-relative-import-paths": "^1.4.0",
"eslint-plugin-react": "^7.31.10",
"husky": "^8.0.1",
"identity-obj-proxy": "^3.0.0",
Expand Down
6 changes: 6 additions & 0 deletions coral/pnpm-lock.yaml

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

2 changes: 1 addition & 1 deletion coral/src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react";
import ReactDOM from "react-dom/client";
import { RouterProvider } from "react-router-dom";
import router from "./router";
import router from "src/router";

import "@aivenio/design-system/dist/styles.css";

Expand Down
2 changes: 1 addition & 1 deletion coral/src/pages/hello/index.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import HelloPage from "./index";
import HelloPage from "src/pages/hello/index";
programmiri marked this conversation as resolved.
Show resolved Hide resolved
import { render, cleanup, screen } from "@testing-library/react";

describe("HelloPage", () => {
Expand Down
2 changes: 1 addition & 1 deletion coral/src/pages/index.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import HomePage from "./index";
import HomePage from "src/pages/index";
programmiri marked this conversation as resolved.
Show resolved Hide resolved
import { render, cleanup, screen } from "@testing-library/react";

describe("HomePage", () => {
Expand Down
4 changes: 2 additions & 2 deletions coral/src/router.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createBrowserRouter, Navigate, RouteObject } from "react-router-dom";
import HomePage from "./pages/index";
import HelloPage from "./pages/hello";
import HomePage from "src/pages/index";
programmiri marked this conversation as resolved.
Show resolved Hide resolved
import HelloPage from "src/pages/hello";

const routes: Array<RouteObject> = [
{
Expand Down
1 change: 1 addition & 0 deletions coral/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"compilerOptions": {
"baseUrl": ".",
"target": "ESNext",
"useDefineForClassFields": true,
"lib": ["DOM", "DOM.Iterable", "ESNext"],
Expand Down
6 changes: 6 additions & 0 deletions coral/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import { resolve } from "path";

// https://vitejs.dev/config/
export default defineConfig({
Expand All @@ -16,4 +17,9 @@ export default defineConfig({
EXAMPLE: "",
},
},
resolve: {
alias: {
src: resolve(resolve(__dirname), "./src"),
},
},
});