ignore

  • Version 7.0.16
  • Published
  • 134 kB
  • No dependencies
  • MIT license

Install

npm i ignore
yarn add ignore
pnpm add ignore

Overview

Ignore is a manager and filter for .gitignore rules, the one used by eslint, gitbook and many others.

Index

Functions

function ignore

ignore: typeof ignore;
  • Creates new ignore manager.

function isPathValid

isPathValid: (pathname: string) => boolean;

    Interfaces

    interface Ignore

    interface Ignore {}

      method add

      add: (patterns: Pattern | readonly Pattern[]) => this;
      • Adds one or several rules to the current manager.

        Parameter patterns

        A rule or array of rules to add.

        Returns

        The current Ignore instance.

      method checkIgnore

      checkIgnore: (pathname: Pathname) => TestResult;
      • Debugs ignore rules and returns the checking result, which is equivalent to git check-ignore -v.

        Parameter pathname

        A path to check.

        Returns

        The TestResult for pathname.

      method createFilter

      createFilter: () => (pathname: Pathname) => boolean;
      • Creates a filter function which could filter an array of paths with Array.prototype.filter.

      method filter

      filter: (pathnames: readonly Pathname[]) => Pathname[];
      • Filters the given array of pathnames, and returns the filtered array. NOTICE that each path here should be a relative path to the root of your repository.

        Parameter pathnames

        The array of paths to be filtered.

        Returns

        The filtered array of paths.

      method ignores

      ignores: (pathname: Pathname) => boolean;
      • Returns Boolean whether pathname should be ignored.

        Parameter pathname

        A path to check.

        Returns

        Whether pathname is ignored.

      method test

      test: (pathname: Pathname) => TestResult;
      • Tests the pathname against the rules. ignored and unignored can both be false: see TestResult.unignored for the two cases.

        Parameter pathname

        A path to check.

        Returns

        The TestResult for pathname.

      interface IgnoreRule

      interface IgnoreRule {}

        property mark

        mark?: string | undefined;
        • Carried through from PatternParams.mark.

        property negative

        negative: boolean;
        • Whether the pattern is a negative one, such as !foo.

        property pattern

        pattern: string;
        • The original pattern.

        interface Options

        interface Options {}

          property allowRelativePaths

          allowRelativePaths?: boolean | undefined;

            property ignorecase

            ignorecase?: boolean | undefined;

              property ignoreCase

              ignoreCase?: boolean | undefined;

                interface PatternParams

                interface PatternParams {}

                  property mark

                  mark?: string | undefined;
                  • Carried through to IgnoreRule.mark, for packages that build upon ignore.

                  property pattern

                  pattern: string;
                  • A single ignore pattern, not split into multiple rules on newlines.

                  interface TestResult

                  interface TestResult {}

                    property ignored

                    ignored: boolean;
                    • Whether the pathname is ignored, by a rule or because a parent directory of it is.

                    property rule

                    rule?: IgnoreRule;
                    • The rule that ignores the pathname, or the parent directory it is ignored with: the last rule to match, which is the rule git check-ignore -v reports. Present exactly when ignored is true.

                    property unignored

                    unignored: boolean;
                    • True if a negative pattern matched the pathname itself, and no parent directory of it is ignored.

                      Only ignored passes down from a parent directory, so a pathname that is not ignored only because a parent directory was unignored keeps this false, as does one no rule applies to at all. To tell those two apart, test the parent directories, each with a trailing slash.

                    Type Aliases

                    type Pathname

                    type Pathname = string;
                    • A path relative to the directory the rules belong to, as path.relative() returns it.

                    type Pattern

                    type Pattern = string | Ignore | PatternParams;
                    • A single entry accepted by Ignore.add(), either standalone or as an element of an array.

                    Package Files (1)

                    Dependencies (0)

                    No dependencies.

                    Dev Dependencies (16)

                    Peer Dependencies (0)

                    No peer dependencies.

                    Badge

                    To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                    You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/ignore.

                    • Markdown
                      [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/ignore)
                    • HTML
                      <a href="https://www.jsdocs.io/package/ignore"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>