Excluding certain components & files

Need to exclude certain components and files from scans?

Omlet CLI ignores certain files while scanning, such as node modules, Storybook stories, and test files. Here are the patterns ignored in scans by default:

  • **/node_modules/**

  • **/*.d.ts

  • **/stories/**/*

  • **/.storybook/**/*

  • **/*.stories.{jsx,tsx,js,ts}

  • **/*.{spec,test}.{jsx,tsx,js,ts}

  • **/{__test__,tests}/**/*.{jsx,tsx,js,ts}

You can define custom file names and glob patterns to ignore from scans or limit the CLI to scan certain directories and glob patterns. There are two different options you can choose to exclude components and files from scans.

Option 1: Config file

One way of ignoring certain components is to define them in the configuration file. To do this, you can create a .omletrc file in the root directory of your repository. The CLI will automatically detect this file and apply your configuration.

Your config file can have alternative names and locations. Check the Config file page to learn more.

Once the config file is created, you can define the ignore property with an array of filenames or glob patterns that should be excluded from the scan.

.omletrc
{
  "ignore": ["**/test_folder/**", "**/another_test_folder/**"]
}

If you need to narrow and specify where the CLI will look for components, you can define the include property with an array of filenames or glob patterns.

.omletrc
{
  "include": ["glob/one", "glob/two"]
}

The paths and patterns are resolved relative to the root project path, where the -r parameter points to—or to the current working directory if -r is not provided to the CLI.

Option 2: Command line arguments

Alternatively, you can add the --ignore option to the analyze command while scanning your repositories.

npx omlet analyze --ignore 'glob/one'

If you need to ignore multiple directories, you can pass multiple glob patterns to the CLI.

npx omlet analyze --ignore 'glob/one' --ignore 'glob/two'

Similar to the config file, you can use -i / --include option in the analyze command to include only specific components, files, or directories.

npx omlet analyze -i 'glob/one' -i 'glob/two'

If the ignore or include properties are provided both as a command-line argument and defined in the config file, the corresponding values in the config file will be ignored.

Last updated