Skip to content

Commit f20d1a3

Browse files
committed
chore: refactor @src imports
The webpack configuration used to include a weird line, that allowed all non-implicit imports from src/. Such imports were ambiguous, and required modification of the resolve path, which is unconventional. To resolve this, we adopt the same solution as frontend-app-learning: src/ imports are written as `from '@src/...'`. To inform ESLint of this, we again draw inspiration from frontend-app-learning by loading the webpack config from tsconfig.json. This in turn triggers a new set of errors, which we fix in the next commit.
1 parent 5c5ff11 commit f20d1a3

File tree

138 files changed

+404
-286
lines changed

Some content is hidden

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

138 files changed

+404
-286
lines changed

.env

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
NODE_ENV='production'
2-
NODE_PATH=./src
32
BASE_URL=''
43
LMS_BASE_URL=''
54
LOGIN_URL=''

.eslintrc.js

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,13 @@ const config = createConfig('eslint', {
1414
'no-promise-executor-return': 'off',
1515
'import/no-cycle': 'off',
1616
},
17-
});
18-
19-
config.settings = {
20-
"import/resolver": {
21-
node: {
22-
paths: ["src", "node_modules"],
23-
extensions: [".js", ".jsx"],
17+
settings: {
18+
'import/resolver': {
19+
webpack: {
20+
config: 'webpack.prod.config.js',
21+
},
2422
},
25-
},
26-
};
23+
}
24+
});
2725

2826
module.exports = config;

package-lock.json

Lines changed: 113 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
8383
"@openedx/frontend-build": "^14.3.3",
8484
"@testing-library/jest-dom": "^6.0.0",
8585
"@testing-library/react": "12.1.5",
86+
"eslint-import-resolver-webpack": "^0.13.9",
8687
"axios-mock-adapter": "^1.20.0",
8788
"fetch-mock": "^9.11.0",
8889
"husky": "^7.0.0",

src/App.jsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ import { BrowserRouter as Router } from 'react-router-dom';
66
import FooterSlot from '@openedx/frontend-slot-footer';
77
import { LearningHeader as Header } from '@edx/frontend-component-header';
88

9-
import { selectors } from 'data/redux';
9+
import { selectors } from '@src/data/redux';
1010

11-
import DemoWarning from 'containers/DemoWarning';
12-
import NotificationsBanner from 'containers/NotificationsBanner';
13-
import ListView from 'containers/ListView';
11+
import DemoWarning from '@src/containers/DemoWarning';
12+
import NotificationsBanner from '@src/containers/NotificationsBanner';
13+
import ListView from '@src/containers/ListView';
1414

1515
import './App.scss';
1616
import Head from './components/Head';

src/components/ConfirmModal.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from 'react';
22
import PropTypes from 'prop-types';
33

44
import { AlertModal, ActionRow, Button } from '@openedx/paragon';
5-
import { nullMethod } from 'hooks';
5+
import { nullMethod } from '@src/hooks';
66

77
export const ConfirmModal = ({
88
title,

src/components/DemoAlert/index.test.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react';
22
import { shallow } from '@edx/react-unit-test-utils';
33

4-
import { formatMessage } from 'testUtils';
4+
import { formatMessage } from '@src/testUtils';
55
import { DemoAlert } from '.';
66

77
describe('DemoAlert component', () => {

src/components/FilePreview/BaseRenderers/pdfHooks.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import { useState, useRef } from 'react';
22

33
import 'react-pdf/dist/esm/Page/AnnotationLayer.css';
44

5-
import { ErrorStatuses } from 'data/constants/requests';
6-
import { StrictDict } from 'utils';
5+
import { ErrorStatuses } from '@src/data/constants/requests';
6+
import { StrictDict } from '@src/utils';
77
import * as module from './pdfHooks';
88

99
export const errors = StrictDict({

src/components/FilePreview/BaseRenderers/pdfHooks.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import React from 'react';
22

3-
import { MockUseState } from 'testUtils';
4-
import { keyStore } from 'utils';
5-
import { ErrorStatuses } from 'data/constants/requests';
3+
import { MockUseState } from '@src/testUtils';
4+
import { keyStore } from '@src/utils';
5+
import { ErrorStatuses } from '@src/data/constants/requests';
66

77
import * as hooks from './pdfHooks';
88

src/components/FilePreview/BaseRenderers/textHooks.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { useEffect, useState } from 'react';
22
import { get } from 'axios';
33

4-
import { StrictDict } from 'utils';
4+
import { StrictDict } from '@src/utils';
55
import * as module from './textHooks';
66

77
export const state = StrictDict({

0 commit comments

Comments
 (0)