Skip to content

Commit

Permalink
Merge pull request #150 from aiven/add-non-relative-imports
Browse files Browse the repository at this point in the history
Add alias for absolute imports in coral.
  • Loading branch information
SmuliS authored Oct 26, 2022
2 parents 65f079e + 7d5eb1d commit ef8e08a
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 8 deletions.
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";
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";
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";
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"),
},
},
});

0 comments on commit ef8e08a

Please sign in to comment.