or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

analysis-correctness.mdconfigs.mdenvironment-specific.mdindex.mdmodule-systems.mdpath-resolution.mdstatic-analysis.mdstyle-organization.mdtypescript.md
tile.json

static-analysis.mddocs/

Static Analysis Rules

These rules perform advanced static analysis of import/export relationships to detect potential issues, circular dependencies, unused modules, and deprecated imports. They help maintain code quality and prevent runtime issues through deep code analysis.

Dependency Analysis

no-cycle

Forbids a module from importing a module with a dependency path back to itself (circular dependency detection).

const noCycle: RuleModule<'cycle', [
  {
    maxDepth?: number;
    ignoreExternal?: boolean;
    allowUnsafeDynamicCyclicDependency?: boolean;
  }?
]>;

Options:

  • maxDepth (number): Maximum dependency depth to traverse (default: ∞)
  • ignoreExternal (boolean): Ignore dependencies in node_modules (default: false)
  • allowUnsafeDynamicCyclicDependency (boolean): Allow dynamic imports that create cycles (default: false)

Example:

// In a.js
import './b';

// In b.js  
import './c';

// In c.js
import './a'; // ✗ BAD - creates cycle: a → b → c → a

// ✓ GOOD - no circular dependency
// Remove the import in c.js or restructure modules

no-self-import

Forbids a module from importing itself.

const noSelfImport: RuleModule<'self', []>;

Example:

// In utils.js
// ✗ BAD - module importing itself
import { helper } from './utils';

// ✓ GOOD - no self-import
// Move shared code to separate module or restructure

Import Pattern Analysis

no-dynamic-require

Forbids require() calls with expressions (dynamic requires).

const noDynamicRequire: RuleModule<'import' | 'require', []>;

Example:

// ✗ BAD - dynamic require with variable
const moduleName = 'lodash';
const lib = require(moduleName);

// ✗ BAD - dynamic require with expression
const lib = require(`./modules/${name}`);

// ✓ GOOD - static require
const lib = require('lodash');
const utils = require('./utils');

no-useless-path-segments

Forbids unnecessary path segments in import and require statements.

const noUselessPathSegments: RuleModule<'useless', [
  {
    commonjs?: boolean;
    noUselessIndex?: boolean;
  }?
]>;

Options:

  • commonjs (boolean): Check CommonJS requires (default: true)
  • noUselessIndex (boolean): Remove useless index references (default: false)

Example:

// ✗ BAD - unnecessary path segments
import utils from '../foo/../bar/utils';
import config from './config/./settings';
import helper from './utils/index'; // if noUselessIndex: true

// ✓ GOOD - clean paths
import utils from '../bar/utils';
import config from './config/settings';
import helper from './utils';

Module Relationship Analysis

no-relative-packages

Forbids importing packages through relative paths.

const noRelativePackages: RuleModule<'relative', [
  {
    commonjs?: boolean;
    exceptions?: string[];
  }?
]>;

Options:

  • commonjs (boolean): Check CommonJS requires (default: true)
  • exceptions (string[]): Package names to allow relative imports

Example:

// ✗ BAD - relative import of package
import lodash from '../node_modules/lodash';

// ✓ GOOD - direct package import
import lodash from 'lodash';

no-relative-parent-imports

Forbids importing modules from parent directories.

const noRelativeParentImports: RuleModule<'parent', [
  {
    commonjs?: boolean;
    exceptions?: string[];
  }?
]>;

Options:

  • commonjs (boolean): Check CommonJS requires (default: true)
  • exceptions (string[]): Path patterns to allow

Example:

// In src/components/Button.js
// ✗ BAD - importing from parent directory
import utils from '../../utils/helpers';

// ✓ GOOD - importing from same or child directory
import styles from './Button.styles';
import Icon from './Icon/Icon';

Path Analysis

no-restricted-paths

Restricts which files can be imported from certain paths based on configurable rules and zones.

const noRestrictedPaths: RuleModule<'path' | 'zone', [
  {
    zones?: Array<{
      target: string | string[];
      from: string | string[];
      except?: string[];
      message?: string;
    }>;
    basePath?: string;
  }?
]>;

Options:

  • zones (array): Define restricted import zones with target/from patterns
  • basePath (string): Base path for relative pattern matching

Example:

// Configuration: restrict server code from importing client code
// zones: [{ target: './src/server/**/*', from: './src/client/**/*' }]

// ✗ BAD - server importing from client
// In src/server/handler.js
import clientUtils from '../client/utils'; 

// ✓ GOOD - server importing from shared
import sharedUtils from '../shared/utils';

no-internal-modules

Forbids importing the submodules of other modules.

const noInternalModules: RuleModule<'noReachDeep', [
  {
    allow?: string[];
    forbid?: string[];
  }?
]>;

Options:

  • allow (string[]): Patterns for allowed internal module imports
  • forbid (string[]): Patterns for forbidden internal module imports

Example:

// ✗ BAD - importing internal submodules
import Button from 'react-bootstrap/lib/Button';
import { util } from 'some-library/internal/util';

// ✓ GOOD - importing from main module
import { Button } from 'react-bootstrap';
import someLibrary from 'some-library';

no-absolute-path

Forbids imports using absolute paths.

const noAbsolutePath: RuleModule<'absolute', [
  {
    esmodule?: boolean;
    commonjs?: boolean;
    amd?: boolean;
  }?
]>;

Options:

  • esmodule (boolean): Check ES module imports (default: true)
  • commonjs (boolean): Check CommonJS requires (default: true)
  • amd (boolean): Check AMD imports (default: true)

Example:

// ✗ BAD - absolute path imports
import utils from '/home/user/project/src/utils';
import config from 'C:\\Projects\\myapp\\config';

// ✓ GOOD - relative or module imports
import utils from './utils';
import config from '../config';
import lodash from 'lodash';

no-webpack-loader-syntax

Forbids Webpack loader syntax in imports.

const noWebpackLoaderSyntax: RuleModule<'loader', []>;

Example:

// ✗ BAD - webpack loader syntax
import styles from 'css-loader!./styles.css';
import template from 'raw-loader!./template.html';

// ✓ GOOD - standard imports (configure loaders in webpack.config.js)
import styles from './styles.css';
import template from './template.html';

Analysis Types

interface DependencyInfo {
  name: string;
  type: 'import' | 'require';
  source: string;
  isExternal: boolean;
  isTypeOnly?: boolean;
}

interface CycleInfo {
  cycle: string[];
  depth: number;
}

interface UnusedExport {
  name: string;
  module: string;
  line: number;
  column: number;
}

interface DeprecationInfo {
  name: string;
  source: string;
  deprecationMessage?: string;
}