How to use the eslint-module-utils/ignore.hasValidExtension 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
let exportMap = exportCache.get(cacheKey)

  // return cached ignore
  if (exportMap === null) return null

  const stats = fs.statSync(path)
  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)
github benmosher / eslint-plugin-import / tests / src / core / ignore.js View on Github external
it('assumes only .js as valid by default', function () {
      const testContext = utils.testContext({})

      expect(hasValidExtension('../files/foo.js', testContext)).to.equal(true)

      expect(hasValidExtension('../files/foo.jsx', testContext)).to.equal(false)

      expect(hasValidExtension('../files/foo.css', testContext)).to.equal(false)

      expect(hasValidExtension('../files/foo.invalid.extension', testContext)).to.equal(false)
    })
github benmosher / eslint-plugin-import / tests / src / core / ignore.js View on Github external
it('assumes only .js as valid by default', function () {
      const testContext = utils.testContext({})

      expect(hasValidExtension('../files/foo.js', testContext)).to.equal(true)

      expect(hasValidExtension('../files/foo.jsx', testContext)).to.equal(false)

      expect(hasValidExtension('../files/foo.css', testContext)).to.equal(false)

      expect(hasValidExtension('../files/foo.invalid.extension', testContext)).to.equal(false)
    })
github benmosher / eslint-plugin-import / tests / src / core / ignore.js View on Github external
it('assumes only .js as valid by default', function () {
      const testContext = utils.testContext({})

      expect(hasValidExtension('../files/foo.js', testContext)).to.equal(true)

      expect(hasValidExtension('../files/foo.jsx', testContext)).to.equal(false)

      expect(hasValidExtension('../files/foo.css', testContext)).to.equal(false)

      expect(hasValidExtension('../files/foo.invalid.extension', testContext)).to.equal(false)
    })
github benmosher / eslint-plugin-import / tests / src / core / ignore.js View on Github external
it('can be configured with import/extensions', function () {
      const testContext = utils.testContext({ 'import/extensions': [ '.foo', '.bar' ] })

      expect(hasValidExtension('../files/foo.foo', testContext)).to.equal(true)

      expect(hasValidExtension('../files/foo.bar', testContext)).to.equal(true)

      expect(hasValidExtension('../files/foo.js', testContext)).to.equal(false)
    })
  })
github benmosher / eslint-plugin-import / tests / src / core / ignore.js View on Github external
it('can be configured with import/extensions', function () {
      const testContext = utils.testContext({ 'import/extensions': [ '.foo', '.bar' ] })

      expect(hasValidExtension('../files/foo.foo', testContext)).to.equal(true)

      expect(hasValidExtension('../files/foo.bar', testContext)).to.equal(true)

      expect(hasValidExtension('../files/foo.js', testContext)).to.equal(false)
    })
  })
github benmosher / eslint-plugin-import / tests / src / core / ignore.js View on Github external
it('can be configured with import/extensions', function () {
      const testContext = utils.testContext({ 'import/extensions': [ '.foo', '.bar' ] })

      expect(hasValidExtension('../files/foo.foo', testContext)).to.equal(true)

      expect(hasValidExtension('../files/foo.bar', testContext)).to.equal(true)

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