docs(linter): Improve the documentation for the import/extensions rule.#17162
Merged
graphite-app[bot] merged 1 commit intomainfrom Dec 20, 2025
Merged
docs(linter): Improve the documentation for the import/extensions rule.#17162graphite-app[bot] merged 1 commit intomainfrom
graphite-app[bot] merged 1 commit intomainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves the documentation for the import/extensions linter rule by adding comprehensive configuration examples with proper severity levels and reorganizing the documentation structure.
Key Changes:
- Added a dedicated "Configuration" section with three detailed JSON examples showing different configuration approaches
- Updated all configuration examples throughout the documentation to include the severity level (e.g.,
"error") - Moved high-level configuration documentation from the
ExtensionsConfigstruct to the main rule documentation
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
CodSpeed Performance ReportMerging #17162 will not alter performanceComparing Summary
Footnotes
|
camc314
approved these changes
Dec 20, 2025
Contributor
Merge activity
|
…e. (#17162) Include configuration examples for clarity, and ensure the severity level is included in the examples to make it easier to understand for the end-user. I also used Claude Opus to fix a bug in the `sanitize` method, where it crashed when you had a json code block on a non-indented doc comment, which was hilarious. Generated docs: ```md ## Configuration This rule accepts three types of configuration: 1. **Global rule** (string): `"always"`, `"never"`, or `"ignorePackages"` \```json { "rules": { // this would require extensions for all imports "import/extensions": ["error", "always"] } } \``` 2. **Per-extension rules** (object): `{ "js": "always", "jsx": "never", ... }` \```json { "rules": { "import/extensions": [ "error", // per-extension rules: // require extensions for .js imports and disallow them for .ts imports { "js": "always", "ts": "never" } ] } } \``` 3. **Combined** (array): `["error", "always", { "js": "never" }]` or `["error", { "js": "always" }]` \```json { "rules": { "import/extensions": [ "error", "always", // by default, require extensions for all imports { "ts": "never" } // override the global value and disallow extensions on imports for specific file types ] } } \``` **Default behavior (no configuration)**: All imports pass. Unconfigured file extensions are ignored, to avoid false positives. This rule accepts a configuration object with the following properties: ### checkTypeImports type: `boolean` default: `false` Whether to check type imports when enforcing extension rules. ### extensions type: `Record<string, string>` default: `{}` Map from file extension (without dot) to its configured rule. ### ignorePackages type: `boolean` default: `false` Whether to ignore package imports when enforcing extension rules. A boolean option (not per-extension) that exempts package imports from the "always" rule. Can be set in the config object: `["error", "always", { "ignorePackages": true }]` Legacy shorthand: `["error", "ignorePackages"]` is equivalent to `["error", "always", { "ignorePackages": true }]` - **With "always"**: When `true`, package imports (e.g., `lodash`, `@babel/core`) don't require extensions - **With "never"**: This option has no effect; extensions are still forbidden on package imports Example: `["error", "always", { "ignorePackages": true }]` allows `import foo from "lodash"` but requires `import bar from "./bar.js"` ### pathGroupOverrides type: `array` default: `[]` Path group overrides for bespoke import specifiers. Array of pattern-action pairs for custom import protocols (monorepo tools, custom resolvers). Each override has: `{ "pattern": "<glob-pattern>", "action": "enforce" | "ignore" }` **Pattern matching**: Uses glob patterns (`*`, `**`, `{a,b}`) to match import specifiers. **Actions**: - `"enforce"`: Apply normal extension validation (respect global/per-extension rules) - `"ignore"`: Skip all extension validation for matching imports **Precedence**: First matching pattern wins. Example: `["error", "always", { "pathGroupOverrides": [{ "pattern": "rootverse{*,*/**}", "action": "ignore" }] }]` - Allows `import { x } from 'rootverse+debug:src'` without extension - Still requires extensions for standard imports #### pathGroupOverrides[n] type: `object` Path group override configuration for bespoke import specifiers. Allows fine-grained control over extension validation for custom import protocols (e.g., monorepo tools, custom resolvers, framework-specific imports). **Pattern matching:** Uses fast-glob patterns to match import specifiers: - `*`: Match any characters except `/` - `**`: Match any characters including `/` (recursive) - `{a,b}`: Match alternatives **Examples:** \```json { "pattern": "rootverse{*,*/**}", "action": "enforce" } \``` Matches: `rootverse+debug:src`, `rootverse+bfe:src/symbols` ##### pathGroupOverrides[n].action type: `"enforce" | "ignore"` Action to take for path group overrides. Determines how import extensions are validated for matching bespoke import specifiers. ###### `"enforce"` Enforce extension validation for matching imports (require extensions based on config) ###### `"ignore"` Ignore matching imports entirely (skip all extension validation) ##### pathGroupOverrides[n].pattern type: `string` Glob pattern to match import specifiers ```
4e74583 to
c7cbe69
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Include configuration examples for clarity, and ensure the severity level is included in the examples to make it easier to understand for the end-user.
I also used Claude Opus to fix a bug in the
sanitizemethod, where it crashed when you had a json code block on a non-indented doc comment, which was hilarious.Generated docs: