diff --git a/src/rules/no-unresolved.js b/src/rules/no-unresolved.js index b9dae97c8e..cc1348a1a3 100644 --- a/src/rules/no-unresolved.js +++ b/src/rules/no-unresolved.js @@ -3,7 +3,7 @@ * @author Ben Mosher */ -import resolve, { CASE_SENSITIVE_FS, fileExistsWithCaseSync } from 'eslint-module-utils/resolve'; +import resolve, { fileExistsWithCaseSync } from 'eslint-module-utils/resolve'; import ModuleCache from 'eslint-module-utils/ModuleCache'; import moduleVisitor, { makeOptionsSchema } from 'eslint-module-utils/moduleVisitor'; import docsUrl from '../docsUrl'; @@ -32,8 +32,8 @@ module.exports = { return; } - const caseSensitive = !CASE_SENSITIVE_FS && options.caseSensitive !== false; - const caseSensitiveStrict = !CASE_SENSITIVE_FS && options.caseSensitiveStrict; + const caseSensitive = options.caseSensitive !== false; + const caseSensitiveStrict = options.caseSensitiveStrict; const resolvedPath = resolve(source.value, context); diff --git a/tests/src/core/resolve.js b/tests/src/core/resolve.js index 360d4a2e70..b60f978619 100644 --- a/tests/src/core/resolve.js +++ b/tests/src/core/resolve.js @@ -2,7 +2,7 @@ import { expect } from 'chai'; import eslintPkg from 'eslint/package.json'; import semver from 'semver'; -import resolve, { CASE_SENSITIVE_FS, fileExistsWithCaseSync } from 'eslint-module-utils/resolve'; +import resolve, { fileExistsWithCaseSync } from 'eslint-module-utils/resolve'; import * as path from 'path'; import * as fs from 'fs'; @@ -315,7 +315,8 @@ describe('resolve', function () { }); }); - const caseDescribe = (!CASE_SENSITIVE_FS ? describe : describe.skip); + const caseInsensitive = fs.existsSync(utils.testFilePath('./MyUncoolComponent.jsx')); + const caseDescribe = (caseInsensitive ? describe : describe.skip); caseDescribe('case sensitivity', function () { let file; const testContext = utils.testContext({ diff --git a/tests/src/rules/default.js b/tests/src/rules/default.js index 9eab9a5a35..03e6524f87 100644 --- a/tests/src/rules/default.js +++ b/tests/src/rules/default.js @@ -1,9 +1,8 @@ +import fs from 'fs'; import path from 'path'; -import { test, testVersion, SYNTAX_CASES, getTSParsers, parsers } from '../utils'; +import { test, testFilePath, testVersion, SYNTAX_CASES, getTSParsers, parsers } from '../utils'; import { RuleTester } from 'eslint'; -import { CASE_SENSITIVE_FS } from 'eslint-module-utils/resolve'; - const ruleTester = new RuleTester(); const rule = require('rules/default'); @@ -146,13 +145,19 @@ ruleTester.run('default', rule, { }); // #311: import of mismatched case -if (!CASE_SENSITIVE_FS) { +if (fs.existsSync(testFilePath('./MyUncoolComponent.jsx'))) { ruleTester.run('default (path case-insensitivity)', rule, { valid: [ test({ code: 'import foo from "./jsx/MyUncoolComponent.jsx"', }), ], + }); +} + +if (fs.existsSync(testFilePath('./Named-Exports.js'))) { + ruleTester.run('default (path case-insensitivity)', rule, { + valid: [], invalid: [ test({ code: 'import bar from "./Named-Exports"', diff --git a/tests/src/rules/named.js b/tests/src/rules/named.js index b5500a6d31..22efa53d7c 100644 --- a/tests/src/rules/named.js +++ b/tests/src/rules/named.js @@ -1,9 +1,8 @@ +import fs from 'fs'; + import { test, SYNTAX_CASES, getTSParsers, testFilePath, testVersion, parsers } from '../utils'; import { RuleTester } from 'eslint'; -import { CASE_SENSITIVE_FS } from 'eslint-module-utils/resolve'; - - const ruleTester = new RuleTester(); const rule = require('rules/named'); @@ -349,7 +348,7 @@ ruleTester.run('named', rule, { }); // #311: import of mismatched case -if (!CASE_SENSITIVE_FS) { +if (fs.existsSync(testFilePath('./Named-Exports.js'))) { ruleTester.run('named (path case-insensitivity)', rule, { valid: [ test({ diff --git a/tests/src/rules/no-unresolved.js b/tests/src/rules/no-unresolved.js index c0252ad19d..3b302e598f 100644 --- a/tests/src/rules/no-unresolved.js +++ b/tests/src/rules/no-unresolved.js @@ -1,8 +1,7 @@ +import fs from 'fs'; import path from 'path'; -import { getTSParsers, test, SYNTAX_CASES, testVersion, parsers } from '../utils'; - -import { CASE_SENSITIVE_FS } from 'eslint-module-utils/resolve'; +import { getTSParsers, test, SYNTAX_CASES, testFilePath, testVersion, parsers } from '../utils'; import { RuleTester } from 'eslint'; @@ -226,7 +225,8 @@ function runResolverTests(resolver) { ], }); - if (!CASE_SENSITIVE_FS) { + const caseInsensitive = fs.existsSync(testFilePath('./MyUncoolComponent.jsx')); + if (caseInsensitive) { const relativePath = './tests/files/jsx/MyUnCoolComponent.jsx'; const cwd = process.cwd(); const mismatchedPath = path.join(cwd.toUpperCase(), relativePath).replace(/\\/g, '/'); diff --git a/utils/resolve.js b/utils/resolve.js index 4a35c6a472..a68243e493 100644 --- a/utils/resolve.js +++ b/utils/resolve.js @@ -52,9 +52,6 @@ function tryRequire(target, sourceFile) { // https://stackoverflow.com/a/27382838 exports.fileExistsWithCaseSync = function fileExistsWithCaseSync(filepath, cacheSettings, strict) { - // don't care if the FS is case-sensitive - if (CASE_SENSITIVE_FS) return true; - // null means it resolved to a builtin if (filepath === null) return true; if (filepath.toLowerCase() === process.cwd().toLowerCase() && !strict) return true;