Skip to content

Commit df829bc

Browse files
committed
feat: setup import alias
1 parent e5071d6 commit df829bc

File tree

9 files changed

+328
-13
lines changed

9 files changed

+328
-13
lines changed

.eslintrc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"position": "before"
3636
},
3737
{
38-
"pattern": "@src/**",
38+
"pattern": "@/**",
3939
"group": "internal"
4040
}
4141
],
@@ -71,7 +71,8 @@
7171
"import/resolver": {
7272
"node": {
7373
"extensions": [".js", ".ts", ".tsx"]
74-
}
74+
},
75+
"babel-module": {}
7576
}
7677
}
7778
}

babel.config.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
11
module.exports = {
22
presets: ['module:@react-native/babel-preset'],
3+
plugins: [
4+
[
5+
'module-resolver',
6+
{
7+
root: ['./src'],
8+
extensions: ['.tsx', '.ts', '.js', '.json'],
9+
alias: {
10+
'@': './src',
11+
},
12+
},
13+
],
14+
],
315
};

example/babel.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ module.exports = function (api) {
2020
),
2121
// For development, we want to alias the library to the source
2222
[pak.name]: path.join(__dirname, '..', 'src'),
23+
'@': path.join(__dirname, '..', 'src'),
2324
},
2425
},
2526
],

example/tsconfig.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
{
22
"extends": "../tsconfig",
3+
"compilerOptions": {
4+
"paths": {
5+
"@/*": ["../src/*"]
6+
}
7+
}
38
}

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,15 @@
8080
"babel-core": "^7.0.0-bridge.0",
8181
"babel-jest": "^29.6.3",
8282
"babel-loader": "^8.2.3",
83+
"babel-plugin-module-resolver": "^5.0.0",
8384
"babel-test": "^0.1.1",
8485
"chalk": "^4.0.0",
8586
"commitlint": "^8.3.4",
8687
"conventional-changelog-cli": "^2.0.11",
8788
"dedent": "^0.7.0",
8889
"eslint": "8.31.0",
90+
"eslint-import-resolver-babel-module": "^5.3.1",
91+
"eslint-import-resolver-typescript": "^3.5.2",
8992
"eslint-plugin-flowtype": "^8.0.3",
9093
"eslint-plugin-local-rules": "^1.3.2",
9194
"glob": "^7.1.3",

src/components/Appbar/Appbar.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ import {
1111

1212
import color from 'color';
1313

14+
import { useInternalTheme } from '@/core/theming';
15+
import type { MD3Elevation, ThemeProp } from '@/types';
16+
1417
import AppbarContent from './AppbarContent';
1518
import {
1619
AppbarModes,
@@ -21,8 +24,6 @@ import {
2124
filterAppbarActions,
2225
AppbarChildProps,
2326
} from './utils';
24-
import { useInternalTheme } from '../../core/theming';
25-
import type { MD3Elevation, ThemeProp } from '../../types';
2627
import Surface from '../Surface';
2728

2829
export type Props = Omit<

src/components/Button/Button.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,17 @@ import {
1515

1616
import color from 'color';
1717

18+
import { useInternalTheme } from '@/core/theming';
19+
import type { $Omit, ThemeProp } from '@/types';
20+
import { forwardRef } from '@/utils/forwardRef';
21+
import hasTouchHandler from '@/utils/hasTouchHandler';
22+
import { splitStyles } from '@/utils/splitStyles';
23+
1824
import {
1925
ButtonMode,
2026
getButtonColors,
2127
getButtonTouchableRippleStyle,
2228
} from './utils';
23-
import { useInternalTheme } from '../../core/theming';
24-
import type { $Omit, ThemeProp } from '../../types';
25-
import { forwardRef } from '../../utils/forwardRef';
26-
import hasTouchHandler from '../../utils/hasTouchHandler';
27-
import { splitStyles } from '../../utils/splitStyles';
2829
import ActivityIndicator from '../ActivityIndicator';
2930
import Icon, { IconSource } from '../Icon';
3031
import Surface from '../Surface';

tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
],
88
"react-native-paper/react-navigation": [
99
"./src/react-navigation"
10-
]
10+
],
11+
"@/*": ["src/*"]
1112
},
1213
"allowUnreachableCode": false,
1314
"allowUnusedLabels": false,

0 commit comments

Comments
 (0)