Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ignore

Package Overview
Dependencies
Maintainers
1
Versions
92
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ignore

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

  • 6.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is ignore?

The ignore npm package is a utility for filtering files and directories according to the particular rules specified in .gitignore files. It can be used to create ignore patterns similar to how git handles .gitignore files, allowing developers to programmatically determine which files should be ignored based on these patterns.

What are ignore's main functionalities?

Add ignore rules

This feature allows you to add ignore rules, which can be a single string or an array of strings representing the patterns to ignore. The example demonstrates adding rules to ignore the .git directory and any files ending with .test.js.

const ignore = require('ignore');
const ig = ignore().add(['.git', '*.test.js']);
console.log(ig.ignores('example.test.js')); // true

Filter file paths

This feature provides a way to filter an array of file paths, removing any that match the ignore patterns. The code sample filters out 'example.test.js' because it matches the '*.test.js' pattern.

const ignore = require('ignore');
const ig = ignore().add('*.test.js');
const files = ['test.js', 'example.test.js', 'README.md'];
const filtered = files.filter(ig.createFilter());
console.log(filtered); // ['test.js', 'README.md']

Check if a file is ignored

This feature checks if a particular file would be ignored based on the current ignore rules. The code sample checks if 'example.test.js' is ignored (true) and if 'README.md' is ignored (false).

const ignore = require('ignore');
const ig = ignore().add('*.test.js');
console.log(ig.ignores('example.test.js')); // true
console.log(ig.ignores('README.md')); // false

Other packages similar to ignore

Keywords

FAQs

Package last updated on 17 Sep 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc