Skip to content

Commit 369ee0a

Browse files
committed
fix: remove detection of case-sensitivity at filesystem level
Note yarn under PnP does not create a `node_modules` directory, so files like `reSOLVE.js` file is served from a virtual filesystem, which is always case sensitive and not representative of the real underlying filesystem.
1 parent 624aa61 commit 369ee0a

File tree

6 files changed

+22
-20
lines changed

6 files changed

+22
-20
lines changed

src/rules/no-unresolved.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* @author Ben Mosher
44
*/
55

6-
import resolve, { CASE_SENSITIVE_FS, fileExistsWithCaseSync } from 'eslint-module-utils/resolve';
6+
import resolve, { fileExistsWithCaseSync } from 'eslint-module-utils/resolve';
77
import ModuleCache from 'eslint-module-utils/ModuleCache';
88
import moduleVisitor, { makeOptionsSchema } from 'eslint-module-utils/moduleVisitor';
99
import docsUrl from '../docsUrl';
@@ -32,8 +32,8 @@ module.exports = {
3232
return;
3333
}
3434

35-
const caseSensitive = !CASE_SENSITIVE_FS && options.caseSensitive !== false;
36-
const caseSensitiveStrict = !CASE_SENSITIVE_FS && options.caseSensitiveStrict;
35+
const caseSensitive = options.caseSensitive !== false;
36+
const caseSensitiveStrict = options.caseSensitiveStrict;
3737

3838
const resolvedPath = resolve(source.value, context);
3939

tests/src/core/resolve.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { expect } from 'chai';
22
import eslintPkg from 'eslint/package.json';
33
import semver from 'semver';
44

5-
import resolve, { CASE_SENSITIVE_FS, fileExistsWithCaseSync } from 'eslint-module-utils/resolve';
5+
import resolve, { fileExistsWithCaseSync } from 'eslint-module-utils/resolve';
66

77
import * as path from 'path';
88
import * as fs from 'fs';
@@ -315,7 +315,8 @@ describe('resolve', function () {
315315
});
316316
});
317317

318-
const caseDescribe = (!CASE_SENSITIVE_FS ? describe : describe.skip);
318+
const caseInsensitive = fs.existsSync(utils.testFilePath('./MyUncoolComponent.jsx'));
319+
const caseDescribe = (caseInsensitive ? describe : describe.skip);
319320
caseDescribe('case sensitivity', function () {
320321
let file;
321322
const testContext = utils.testContext({

tests/src/rules/default.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1+
import fs from 'fs';
12
import path from 'path';
2-
import { test, testVersion, SYNTAX_CASES, getTSParsers, parsers } from '../utils';
3+
import { test, testFilePath, testVersion, SYNTAX_CASES, getTSParsers, parsers } from '../utils';
34
import { RuleTester } from 'eslint';
45

5-
import { CASE_SENSITIVE_FS } from 'eslint-module-utils/resolve';
6-
76
const ruleTester = new RuleTester();
87
const rule = require('rules/default');
98

@@ -146,13 +145,19 @@ ruleTester.run('default', rule, {
146145
});
147146

148147
// #311: import of mismatched case
149-
if (!CASE_SENSITIVE_FS) {
148+
if (fs.existsSync(testFilePath('./MyUncoolComponent.jsx'))) {
150149
ruleTester.run('default (path case-insensitivity)', rule, {
151150
valid: [
152151
test({
153152
code: 'import foo from "./jsx/MyUncoolComponent.jsx"',
154153
}),
155154
],
155+
});
156+
}
157+
158+
if (fs.existsSync(testFilePath('./Named-Exports.js'))) {
159+
ruleTester.run('default (path case-insensitivity)', rule, {
160+
valid: [],
156161
invalid: [
157162
test({
158163
code: 'import bar from "./Named-Exports"',

tests/src/rules/named.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1+
import fs from 'fs';
2+
13
import { test, SYNTAX_CASES, getTSParsers, testFilePath, testVersion, parsers } from '../utils';
24
import { RuleTester } from 'eslint';
35

4-
import { CASE_SENSITIVE_FS } from 'eslint-module-utils/resolve';
5-
6-
76
const ruleTester = new RuleTester();
87
const rule = require('rules/named');
98

@@ -349,7 +348,7 @@ ruleTester.run('named', rule, {
349348
});
350349

351350
// #311: import of mismatched case
352-
if (!CASE_SENSITIVE_FS) {
351+
if (fs.existsSync(testFilePath('./Named-Exports.js'))) {
353352
ruleTester.run('named (path case-insensitivity)', rule, {
354353
valid: [
355354
test({

tests/src/rules/no-unresolved.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1+
import fs from 'fs';
12
import path from 'path';
23

3-
import { getTSParsers, test, SYNTAX_CASES, testVersion, parsers } from '../utils';
4-
5-
import { CASE_SENSITIVE_FS } from 'eslint-module-utils/resolve';
4+
import { getTSParsers, test, SYNTAX_CASES, testFilePath, testVersion, parsers } from '../utils';
65

76
import { RuleTester } from 'eslint';
87

@@ -226,7 +225,8 @@ function runResolverTests(resolver) {
226225
],
227226
});
228227

229-
if (!CASE_SENSITIVE_FS) {
228+
const caseInsensitive = fs.existsSync(testFilePath('./MyUncoolComponent.jsx'));
229+
if (caseInsensitive) {
230230
const relativePath = './tests/files/jsx/MyUnCoolComponent.jsx';
231231
const cwd = process.cwd();
232232
const mismatchedPath = path.join(cwd.toUpperCase(), relativePath).replace(/\\/g, '/');

utils/resolve.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,6 @@ function tryRequire(target, sourceFile) {
5252

5353
// https://stackoverflow.com/a/27382838
5454
exports.fileExistsWithCaseSync = function fileExistsWithCaseSync(filepath, cacheSettings, strict) {
55-
// don't care if the FS is case-sensitive
56-
if (CASE_SENSITIVE_FS) return true;
57-
5855
// null means it resolved to a builtin
5956
if (filepath === null) return true;
6057
if (filepath.toLowerCase() === process.cwd().toLowerCase() && !strict) return true;

0 commit comments

Comments
 (0)