- 将所有图片路径从绝对路径改为使用 process.env.PUBLIC_URL - 修复 HomePage.tsx 中所有图片引用 - 修复 CoursePage.tsx 中所有图片引用 - 确保图片在 GitHub Pages 上正确加载 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
28 lines
731 B
Markdown
28 lines
731 B
Markdown
# Disallow manually importing from `__mocks__` (`no-mocks-import`)
|
|
|
|
When using `jest.mock`, your tests (just like the code being tested) should
|
|
import from `./x`, not `./__mocks__/x`. Not following this rule can lead to
|
|
confusion, because you will have multiple instances of the mocked module:
|
|
|
|
```js
|
|
jest.mock('./x');
|
|
const x1 = require('./x');
|
|
const x2 = require('./__mocks__/x');
|
|
|
|
test('x', () => {
|
|
expect(x1).toBe(x2); // fails! They are both instances of `./__mocks__/x`, but not referentially equal
|
|
});
|
|
```
|
|
|
|
### Rule details
|
|
|
|
This rule reports imports from a path containing a `__mocks__` component.
|
|
|
|
Example violations:
|
|
|
|
```js
|
|
import thing from './__mocks__/index';
|
|
require('./__mocks__/index');
|
|
require('__mocks__');
|
|
```
|