Skip to content

Commit 2ded588

Browse files
committed
chore(sync): cascade fleet template@ae5e5c7
Auto-applied by socket-wheelhouse sync-scaffolding into vscode-socket-security. 2 file(s) touched: - .config/oxlint-plugin/lib/fleet-paths.mts - .config/oxlint-plugin/rules/no-file-scope-oxlint-disable.mts
1 parent ce21241 commit 2ded588

2 files changed

Lines changed: 58 additions & 13 deletions

File tree

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/**
2+
* @file Shared path-suffix constants for fleet-canonical files that any
3+
* plugin rule may need to recognize. Centralizing these out of individual
4+
* rule files lets multiple rules share the same opt-in / opt-out list
5+
* without duplicating the path string + its rationale comment.
6+
*
7+
* Examples of consumers:
8+
*
9+
* - `no-file-scope-oxlint-disable` exempts `scripts/paths.mts` (deliberate
10+
* flow-ordered exports, see PATHS_FILE constant below).
11+
* - `socket/prefer-cached-for-loop` and `socket/no-cached-for-on-iterable`
12+
* share `lib/iterable-kind.mts` for the binding-kind heuristic — sibling
13+
* pattern.
14+
*
15+
* When a new rule needs to recognize one of these path patterns, add the
16+
* import here and use the constant, not a re-spelled literal.
17+
*/
18+
19+
/**
20+
* The fleet's "1 path, 1 reference" source-of-truth file. Each fleet repo has
21+
* one. Its exports are ordered by path-resolution flow (REPO_ROOT → primary
22+
* roots → build paths → helpers) — deliberately not alphabetical, and the
23+
* order is load-bearing for code review. Anything keyed on per-file behavior
24+
* that recognizes `paths.mts` should match by suffix.
25+
*/
26+
export const PATHS_FILE = 'scripts/paths.mts'
27+
28+
/**
29+
* Plugin-internal rule + test directories. Rule files often contain the
30+
* banned shape they ban as lookup-table data (e.g. `no-status-emoji.mts`
31+
* literally contains the emoji it bans). Same for the matching test files,
32+
* which intentionally exercise the banned shape.
33+
*/
34+
export const PLUGIN_RULE_DIR = '.config/oxlint-plugin/rules/'
35+
export const PLUGIN_TEST_DIR = '.config/oxlint-plugin/test/'
36+
37+
/**
38+
* True when `filename` is inside the plugin's own rules / test directory.
39+
*/
40+
export function isPluginInternalPath(filename: string): boolean {
41+
return (
42+
filename.includes(PLUGIN_RULE_DIR) || filename.includes(PLUGIN_TEST_DIR)
43+
)
44+
}
45+
46+
/**
47+
* True when `filename` points at the fleet-canonical `scripts/paths.mts`.
48+
*/
49+
export function isPathsModule(filename: string): boolean {
50+
return filename.endsWith(PATHS_FILE)
51+
}

.config/oxlint-plugin/rules/no-file-scope-oxlint-disable.mts

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,17 @@
2626
* rule).
2727
*/
2828

29+
// Path-recognition helpers shared with sibling rules. See
30+
// `../lib/fleet-paths.mts` for the rationale behind each exemption.
31+
import {
32+
isPathsModule,
33+
isPluginInternalPath,
34+
} from '../lib/fleet-paths.mts'
2935
import type { AstNode, RuleContext } from '../lib/rule-types.mts'
3036

3137
const FILE_SCOPE_DISABLE_RE =
3238
/^\s*(?:\/\*|\/\/)\s*oxlint-disable(?!-next-line)\s+/
3339

34-
// Plugin-internal rule files are allowed to file-scope-disable their
35-
// own rule (the banned shape is lookup-table data in the rule
36-
// definition). Match by suffix on the path.
37-
const PLUGIN_RULE_DIR = '.config/oxlint-plugin/rules/'
38-
const PLUGIN_TEST_DIR = '.config/oxlint-plugin/test/'
39-
40-
function isPluginInternalPath(filename: string): boolean {
41-
return (
42-
filename.includes(PLUGIN_RULE_DIR) || filename.includes(PLUGIN_TEST_DIR)
43-
)
44-
}
45-
4640
const rule = {
4741
meta: {
4842
type: 'suggestion',
@@ -62,7 +56,7 @@ const rule = {
6256

6357
create(context: RuleContext) {
6458
const filename = context.filename ?? context.getFilename?.() ?? ''
65-
if (isPluginInternalPath(filename)) {
59+
if (isPluginInternalPath(filename) || isPathsModule(filename)) {
6660
return {}
6761
}
6862
const sourceCode = context.getSourceCode

0 commit comments

Comments
 (0)