For AI agents: the complete documentation index is available at /byethrow/llms.txt, the full documentation bundle is available at /byethrow/llms-full.txt, and this page is available as Markdown at /byethrow/guide/ecosystem/linter/consistent-namespace.md.
  • English
  • consistent-namespace

    Enforces that imports from @praha/byethrow use a consistent namespace alias — either Result or R.

    Rule details

    When working with @praha/byethrow, you can import the namespace as either Result or R. Mixing both aliases in a project makes code inconsistent and harder to search. This rule enforces a single preferred alias and auto-fixes violations.

    The default preferred namespace is Result.

    Incorrect

    // ❌ mixing Result and R in the same codebase
    import { 
    import Result
    Result
    ,
    import R
    R
    } from '@praha/byethrow';
    const
    const success: Result.Result<42, never>
    success
    =
    import Result
    Result
    .
    const succeed: <42>(value: 42) => Result.Result<42, never> (+1 overload)
    succeed
    (42);
    const
    const failure: Result.Result<never, Error>
    failure
    =
    import R
    R
    .
    const fail: <Error>(error: Error) => Result.Result<never, Error> (+1 overload)
    fail
    (new
    var Error: ErrorConstructor
    new (message?: string, options?: ErrorOptions) => Error (+1 overload)
    Error
    ('Something went wrong'));

    Correct

    // ✅ using Result consistently
    import { 
    import Result
    Result
    } from '@praha/byethrow';
    const
    const success: Result.Result<42, never>
    success
    =
    import Result
    Result
    .
    const succeed: <42>(value: 42) => Result.Result<42, never> (+1 overload)
    succeed
    (42);
    const
    const failure: Result.Result<never, Error>
    failure
    =
    import Result
    Result
    .
    const fail: <Error>(error: Error) => Result.Result<never, Error> (+1 overload)
    fail
    (new
    var Error: ErrorConstructor
    new (message?: string, options?: ErrorOptions) => Error (+1 overload)
    Error
    ('Something went wrong'));
    // ✅ using R consistently (when configured to prefer R)
    import { 
    import R
    R
    } from '@praha/byethrow';
    const
    const success: R.Result<42, never>
    success
    =
    import R
    R
    .
    const succeed: <42>(value: 42) => R.Result<42, never> (+1 overload)
    succeed
    (42);
    const
    const failure: R.Result<never, Error>
    failure
    =
    import R
    R
    .
    const fail: <Error>(error: Error) => R.Result<never, Error> (+1 overload)
    fail
    (new
    var Error: ErrorConstructor
    new (message?: string, options?: ErrorOptions) => Error (+1 overload)
    Error
    ('Something went wrong'));

    Options

    The rule accepts a single string option for the preferred namespace (default: "Result").

    prefer R instead of Result:

    import { 
    function defineConfig<T extends OxlintConfig>(config: T & OxlintConfig): T

    Define an Oxlint configuration with type inference.

    @paramconfig - Oxlint configuration@returnsConfig unchanged
    defineConfig
    } from 'oxlint';
    export default
    defineConfig<{
        rules: {
            'byethrow/consistent-namespace': ["error", "R"];
        };
    }>(config: {
        rules: {
            'byethrow/consistent-namespace': ["error", "R"];
        };
    } & OxlintConfig): {
        rules: {
            'byethrow/consistent-namespace': ["error", "R"];
        };
    }

    Define an Oxlint configuration with type inference.

    @paramconfig - Oxlint configuration@returnsConfig unchanged
    defineConfig
    ({
    rules: {
        'byethrow/consistent-namespace': ["error", "R"];
    } & DummyRuleMap

    Example

    .oxlintrc.json

    {
      "$schema": "./node_modules/oxlint/configuration_schema.json",
      "rules": {
        "eqeqeq": "warn",
        "import/no-cycle": "error",
        "prefer-const": [
          "error",
          {
            "ignoreReadBeforeAssign": true
          }
        ]
      }
    }

    See Oxlint Rules for the list of rules.

    rules
    : {
    'byethrow/consistent-namespace': ['error', 'R'], }, });