Skip to content

Commit 512e43a

Browse files
committed
refactor(linter/plugins): move assertions into own file (#15945)
Pure refactor. Split up `plugins/utils.ts` into 3 files in `utils` directory. Most importantly, assertion functions are by themselves in an `asserts.ts` file. This paves the way for the next PR (#15946).
1 parent 22e132d commit 512e43a

File tree

16 files changed

+88
-90
lines changed

16 files changed

+88
-90
lines changed

apps/oxlint/src-js/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { assertIsNonNull } from './plugins/utils.js';
1+
import { assertIsNonNull } from './utils/asserts.js';
22

33
import type { Context, FileContext, LanguageOptions } from './plugins/context.ts';
44
import type { CreateOnceRule, Plugin, Rule } from './plugins/load.ts';
55
import type { Settings } from './plugins/settings.ts';
66
import type { SourceCode } from './plugins/source_code.ts';
77
import type { BeforeHook, Visitor, VisitorWithHooks } from './plugins/types.ts';
8-
import type { SetNullable } from './plugins/utils.ts';
8+
import type { SetNullable } from './utils/types.ts';
99

1010
export type * as ESTree from './generated/types.d.ts';
1111
export type { Context, LanguageOptions } from './plugins/context.ts';

apps/oxlint/src-js/plugins/comments.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*/
44

55
import { ast, initAst, sourceText } from './source_code.js';
6-
import { assertIsNonNull } from './utils.js';
6+
import { assertIsNonNull } from '../utils/asserts.js';
77

88
import type { Comment, Node, NodeOrToken } from './types.ts';
99

apps/oxlint/src-js/plugins/context.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
import { ast, initAst, SOURCE_CODE } from './source_code.js';
3030
import { report } from './report.js';
3131
import { settings, initSettings } from './settings.js';
32-
import { assertIsNonNull } from './utils.js';
32+
import { assertIsNonNull } from '../utils/asserts.js';
3333

3434
import type { Options, RuleDetails } from './load.ts';
3535
import type { Diagnostic } from './report.ts';

apps/oxlint/src-js/plugins/fix.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { assertIs } from './utils.js';
1+
import { assertIs } from '../utils/asserts.js';
22

33
import type { RuleDetails } from './load.ts';
44
import type { Range, Ranged } from './location.ts';

apps/oxlint/src-js/plugins/lint.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import { registeredRules } from './load.js';
33
import { diagnostics } from './report.js';
44
import { setSettingsForFile, resetSettings } from './settings.js';
55
import { ast, initAst, resetSourceAndAst, setupSourceForFile } from './source_code.js';
6-
import { assertIs, assertIsNonNull, getErrorMessage } from './utils.js';
6+
import { assertIs, assertIsNonNull } from '../utils/asserts.js';
7+
import { getErrorMessage } from '../utils/utils.js';
78
import { addVisitorToCompiled, compiledVisitor, finalizeCompiledVisitor, initCompiledVisitor } from './visitor.js';
89

910
// Lazy implementation

apps/oxlint/src-js/plugins/load.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import { pathToFileURL } from 'node:url';
22

33
import { createContext } from './context.js';
4-
import { getErrorMessage } from './utils.js';
4+
import { getErrorMessage } from '../utils/utils.js';
55

66
import type { Writable } from 'type-fest';
77
import type { Context } from './context.ts';
88
import type { JsonValue } from './json.ts';
99
import type { RuleMeta } from './rule_meta.ts';
1010
import type { AfterHook, BeforeHook, Visitor, VisitorWithHooks } from './types.ts';
11-
import type { SetNullable } from './utils.ts';
11+
import type { SetNullable } from '../utils/types.ts';
1212

1313
const ObjectKeys = Object.keys;
1414

apps/oxlint/src-js/plugins/location.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*/
55

66
import { initSourceText, sourceText } from './source_code.js';
7-
import { assertIsNonNull } from './utils.js';
7+
import { assertIsNonNull } from '../utils/asserts.js';
88

99
import type { Node } from './types.ts';
1010

apps/oxlint/src-js/plugins/scope.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ import {
88
type ScopeManager as TSESLintScopeManager,
99
} from '@typescript-eslint/scope-manager';
1010
import { ast, initAst } from './source_code.js';
11-
import { assertIs, assertIsNonNull } from './utils.js';
11+
import { assertIs, assertIsNonNull } from '../utils/asserts.js';
1212

1313
import type * as ESTree from '../generated/types.d.ts';
14-
import type { SetNullable } from './utils.ts';
14+
import type { SetNullable } from '../utils/types.ts';
1515

1616
export interface Scope {
1717
type: ScopeType;

apps/oxlint/src-js/plugins/settings.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*/
44

55
import { deepFreezeJsonValue } from './json.js';
6-
import { assertIsNonNull } from './utils.js';
6+
import { assertIsNonNull } from '../utils/asserts.js';
77

88
import type { JsonObject } from './json.ts';
99

apps/oxlint/src-js/plugins/source_code.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {
1818
import { resetScopeManager, SCOPE_MANAGER } from './scope.js';
1919
import * as scopeMethods from './scope.js';
2020
import * as tokenMethods from './tokens.js';
21-
import { assertIsNonNull } from './utils.js';
21+
import { assertIsNonNull } from '../utils/asserts.js';
2222

2323
import type { Program } from '../generated/types.d.ts';
2424
import type { Ranged } from './location.ts';

0 commit comments

Comments
 (0)