How to use the eslint-module-utils/ignore function in eslint-module-utils

To help you get started, we’ve selected a few eslint-module-utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github benmosher / eslint-plugin-import / src / ExportMap.js View on Github external
if (exportMap != null) {
    // date equality check
    if (exportMap.mtime - stats.mtime === 0) {
      return exportMap
    }
    // future: check content equality?
  }

  // check valid extensions first
  if (!hasValidExtension(path, context)) {
    exportCache.set(cacheKey, null)
    return null
  }

  // check for and cache ignore
  if (isIgnored(path, context)) {
    log('ignored path due to ignore settings:', path)
    exportCache.set(cacheKey, null)
    return null
  }

  const content = fs.readFileSync(path, { encoding: 'utf8' })

  // check for and cache unambigious modules
  if (!unambiguous.test(content)) {
    log('ignored path due to unambiguous regex:', path)
    exportCache.set(cacheKey, null)
    return null
  }

  log('cache miss', cacheKey, 'for path', path)
  exportMap = ExportMap.parse(path, content, context)
github benmosher / eslint-plugin-import / tests / src / core / ignore.js View on Github external
it('ignores paths with invalid extensions when configured with import/extensions', function () {
      const testContext = utils.testContext({ 'import/extensions': [ '.js', '.jsx', '.ts' ] })

      expect(isIgnored('../files/foo.js', testContext)).to.equal(false)

      expect(isIgnored('../files/bar.jsx', testContext)).to.equal(false)

      expect(isIgnored('../files/typescript.ts', testContext)).to.equal(false)

      expect(isIgnored('../files/ignore.invalid.extension', testContext)).to.equal(true)
    })
  })
github benmosher / eslint-plugin-import / tests / src / core / ignore.js View on Github external
it('ignores paths with extensions other than .js', function () {
      const testContext = utils.testContext({})

      expect(isIgnored('../files/foo.js', testContext)).to.equal(false)

      expect(isIgnored('../files/bar.jsx', testContext)).to.equal(true)

      expect(isIgnored('../files/typescript.ts', testContext)).to.equal(true)

      expect(isIgnored('../files/ignore.invalid.extension', testContext)).to.equal(true)
    })
github benmosher / eslint-plugin-import / tests / src / core / ignore.js View on Github external
it('ignores paths with extensions other than .js', function () {
      const testContext = utils.testContext({})

      expect(isIgnored('../files/foo.js', testContext)).to.equal(false)

      expect(isIgnored('../files/bar.jsx', testContext)).to.equal(true)

      expect(isIgnored('../files/typescript.ts', testContext)).to.equal(true)

      expect(isIgnored('../files/ignore.invalid.extension', testContext)).to.equal(true)
    })
github benmosher / eslint-plugin-import / tests / src / core / ignore.js View on Github external
it('ignores paths with invalid extensions when configured with import/extensions', function () {
      const testContext = utils.testContext({ 'import/extensions': [ '.js', '.jsx', '.ts' ] })

      expect(isIgnored('../files/foo.js', testContext)).to.equal(false)

      expect(isIgnored('../files/bar.jsx', testContext)).to.equal(false)

      expect(isIgnored('../files/typescript.ts', testContext)).to.equal(false)

      expect(isIgnored('../files/ignore.invalid.extension', testContext)).to.equal(true)
    })
  })