Files
ai-course/node_modules/eslint-plugin-import/docs/rules/no-relative-packages.md
KQL ce6aa207e9 fix: 修复图片路径以适配GitHub Pages base path
- 将所有图片路径从绝对路径改为使用 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>
2025-11-04 09:24:45 +08:00

1.5 KiB

import/no-relative-packages

🔧 This rule is automatically fixable by the --fix CLI option.

Use this rule to prevent importing packages through relative paths.

It's useful in Yarn/Lerna workspaces, where it's possible to import a sibling package using ../package relative path, while direct package is the correct one.

Examples

Given the following folder structure:

my-project
├── packages
│   ├── foo
│   │   ├── index.js
│   │   └── package.json
│   └── bar
│       ├── index.js
│       └── package.json
└── entry.js

And the .eslintrc file:

{
  ...
  "rules": {
    "import/no-relative-packages": "error"
  }
}

The following patterns are considered problems:

/**
 *  in my-project/packages/foo.js
 */

import bar from '../bar'; // Import sibling package using relative path
import entry from '../../entry.js'; // Import from parent package using relative path

/**
 *  in my-project/entry.js
 */

import bar from './packages/bar'; // Import child package using relative path

The following patterns are NOT considered problems:

/**
 *  in my-project/packages/foo.js
 */

import bar from 'bar'; // Import sibling package using package name

/**
 *  in my-project/entry.js
 */

import bar from 'bar'; // Import sibling package using package name