Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit880ab8c

Browse files
JounQinljharb
authored andcommitted
[Fix] version detection: support recursive processor virtual filename
1 parentf0e6700 commit880ab8c

File tree

3 files changed

+18
-9
lines changed

3 files changed

+18
-9
lines changed

‎CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ This change log adheres to standards from [Keep a CHANGELOG](http://keepachangel
88
###Added
99
* component detection: add componentWrapperFunctions setting ([#2713][] @@jzabala@LandonSchropp)
1010
*[`no-unused-prop-types`]: add ignore option ([#2972][]@grit96)
11+
* version detection: support recursive processor virtual filename ([#2965][]@JounQin)
1112

1213
###Fixed
1314
*[`jsx-handler-names`]: properly substitute value into message ([#2975][]@G-Rath)
@@ -32,6 +33,7 @@ This change log adheres to standards from [Keep a CHANGELOG](http://keepachangel
3233
[#2975]:https://github.com/yannickcr/eslint-plugin-react/pull/2975
3334
[#2974]:https://github.com/yannickcr/eslint-plugin-react/pull/2974
3435
[#2972]:https://github.com/yannickcr/eslint-plugin-react/pull/2972
36+
[#2965]:https://github.com/yannickcr/eslint-plugin-react/pull/2965
3537
[#2713]:https://github.com/yannickcr/eslint-plugin-react/pull/2713
3638

3739
##[7.23.2] - 2021.04.08
@@ -3366,4 +3368,4 @@ If you're still not using React 15 you can keep the old behavior by setting the
33663368
[`function-component-definition`]:docs/rules/function-component-definition.md
33673369
[`jsx-newline`]:docs/rules/jsx-newline.md
33683370
[`jsx-no-constructed-context-values`]:docs/rules/jsx-no-constructed-context-values.md
3369-
[`no-unstable-nested-components`]:docs/rules/no-unstable-nested-components.md
3371+
[`no-unstable-nested-components`]:docs/rules/no-unstable-nested-components.md

‎lib/util/version.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,25 +22,24 @@ function resetDetectedVersion() {
2222
cachedDetectedReactVersion=undefined;
2323
}
2424

25-
functionresolveBasedir(context){
26-
letbasedir=process.cwd();
27-
if(context){
28-
constfilename=context.getFilename();
25+
functionresolveBasedir(contextOrFilename){
26+
if(contextOrFilename){
27+
constfilename=typeofcontextOrFilename==='string' ?contextOrFilename :contextOrFilename.getFilename();
2928
constdirname=path.dirname(filename);
3029
try{
3130
if(fs.statSync(filename).isFile()){
3231
// dirname must be dir here
33-
basedir=dirname;
32+
returndirname;
3433
}
3534
}catch(err){
3635
// https://github.com/eslint/eslint/issues/11989
3736
if(err.code==='ENOTDIR'){
38-
//the error code alreay indicates that dirname is a file
39-
basedir=path.dirname(dirname);
37+
//virtual filename could be recursive
38+
returnresolveBasedir(dirname);
4039
}
4140
}
4241
}
43-
returnbasedir;
42+
returnprocess.cwd();
4443
}
4544

4645
// TODO, semver-major: remove context fallback

‎tests/util/version.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,14 @@ describe('Version', () => {
8787
assert.equal(versionUtil.testReactVersion(context,'2.3.5'),false);
8888
assert.equal(versionUtil.testFlowVersion(context,'2.92.0'),true);
8989
});
90+
91+
it('works with recursive virtual filename',()=>{
92+
sinon.stub(context,'getFilename').callsFake(()=>path.resolve(base,'detect-version-sibling','test.js/0_fake.md/1_fake.js'));
93+
94+
assert.equal(versionUtil.testReactVersion(context,'2.3.4'),true);
95+
assert.equal(versionUtil.testReactVersion(context,'2.3.5'),false);
96+
assert.equal(versionUtil.testFlowVersion(context,'2.92.0'),true);
97+
});
9098
});
9199

92100
describe('string version',()=>{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp