-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
require-statement-match rule is broken #1079
Comments
From @samreid in #1060 (comment): perhaps use import-js/eslint-plugin-import#325 |
I looked through that issue, and didn't see that anything has been implemented into the main ruleset yet. I did see https://github.com/minseoksuh/eslint-plugin-consistent-default-export-name, but it doesn't seem very used, popular, though seems a bit maintained. I applied this patch, npm updated, and ran grunt lint in friction and found:
Index: eslint/.eslintrc.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/eslint/.eslintrc.js b/eslint/.eslintrc.js
--- a/eslint/.eslintrc.js (revision f2e651ea5830b168f4b8c9ee5ad4fde0916ab853)
+++ b/eslint/.eslintrc.js (date 1630079184011)
@@ -13,6 +13,8 @@
// in a parent dir
root: true,
+ extends: [ "plugin:consistent-default-export-name/fixed" ],
+
// The rules are organized like they are in the list at https://eslint.org/docs/rules/
// First by type, then alphabetically within type
// Explicitly list all rules so it is easy to see what's here and to keep organized
Index: package.json
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/package.json b/package.json
--- a/package.json (revision f2e651ea5830b168f4b8c9ee5ad4fde0916ab853)
+++ b/package.json (date 1630079038788)
@@ -33,7 +33,8 @@
"terser": "~4.6.4",
"webpack": "^5.47.1",
"webpack-cli": "^4.7.0",
- "webpack-dev-server": "^3.11.2"
+ "webpack-dev-server": "^3.11.2",
+ "eslint-plugin-consistent-default-export-name": "^0.0.6"
},
"eslintConfig": {
"extends": "../chipper/eslint/sim_eslintrc.js",
|
That looks promising, but if we are concerned about the resolve error, or whether it may be maintained, writing our own rule may not be too complicated, and would give us flexibility if we want to adjust or tinker with it. Not advocating strongly one way or the other, just brainstorming options. |
@jessegreenberg and @samreid, this feels like a step in the right direction. I'm unsure what the "Resolve error: . . ." is, but perhaps it doesn't matter. When we fix the actual error, we solve the node resolve error. Index: js/friction/view/MoleculeMotionSoundGenerator.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/js/friction/view/MoleculeMotionSoundGenerator.js b/js/friction/view/MoleculeMotionSoundGenerator.js
--- a/js/friction/view/MoleculeMotionSoundGenerator.js (revision cf117e5f215eb53100ce1d8da8f0c3ea0b892ea5)
+++ b/js/friction/view/MoleculeMotionSoundGenerator.js (date 1630079957023)
@@ -19,7 +19,7 @@
import merge from '../../../../phet-core/js/merge.js';
import SoundClip from '../../../../tambo/js/sound-generators/SoundClip.js';
import SoundGenerator from '../../../../tambo/js/sound-generators/SoundGenerator.js';
-import bounceMarimbaSound from '../../../sounds/bounce-marimba_mp3.js';
+import bounceMarimba_mp3 from '../../../sounds/bounce-marimba_mp3.js'; // eslint-disable-line import-resource-variable-suffix
import friction from '../../friction.js';
import FrictionConstants from '../FrictionConstants.js';
import FrictionModel from '../model/FrictionModel.js';
@@ -41,10 +41,10 @@
// create several instances of the sound clip at different volume levels to allow more variation in the sound
const motionSoundClips = [
- new SoundClip( bounceMarimbaSound, { initialOutputLevel: 1, rateChangesAffectPlayingSounds: false } ),
- new SoundClip( bounceMarimbaSound, { initialOutputLevel: 0.75, rateChangesAffectPlayingSounds: false } ),
- new SoundClip( bounceMarimbaSound, { initialOutputLevel: 0.5, rateChangesAffectPlayingSounds: false } ),
- new SoundClip( bounceMarimbaSound, { initialOutputLevel: 0.25, rateChangesAffectPlayingSounds: false } )
+ new SoundClip( bounceMarimba_mp3, { initialOutputLevel: 1, rateChangesAffectPlayingSounds: false } ),
+ new SoundClip( bounceMarimba_mp3, { initialOutputLevel: 0.75, rateChangesAffectPlayingSounds: false } ),
+ new SoundClip( bounceMarimba_mp3, { initialOutputLevel: 0.5, rateChangesAffectPlayingSounds: false } ),
+ new SoundClip( bounceMarimba_mp3, { initialOutputLevel: 0.25, rateChangesAffectPlayingSounds: false } )
];
// connect up the sound clips
Next I'll take a brief look at their rule to see if there is an easy or obvious pull request we could do to get rid of that error. |
I had good luck finding the small bug that was causing that weird error in the package. I created an issue pull request for the fix over in minseoksuh/eslint-plugin-consistent-default-export-name#7. Given the success I had with bug-fixing their project, I think we should go all in on this package. I'm going to add this dependency, and add it to the eslintrc file turned off (since there will be many, many errors). I'll report back soon to see how it goes. |
I ran grunt lint-everything, and found 1272 errors, they looked something like this. I'm very pleased! I'll go ahead and commit this rule turned off.
Here are the repos that this effects:
I'm not really sure how hard it would be to come up with a |
Ok, commented out above. |
I think it is time to check in with @jessegreenberg. Please let me know what you would like to do in combination with #1060 |
I don't see a good way to support this, and I'm unsure how to debug it. With that in mind and the feedback over in minseoksuh/eslint-plugin-consistent-default-export-name#7, I think that spinning up our own, similar rule with fewer features makes the most sense. I have something pretty good going in my working copy. Commit coming soon. |
Ok. @jessegreenberg, please review our own implementation of Using this patch + Index: eslint/.eslintrc.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/eslint/.eslintrc.js b/eslint/.eslintrc.js
--- a/eslint/.eslintrc.js (revision ceb0be752cff3809647289ea1b6dfe90decd8657)
+++ b/eslint/.eslintrc.js (date 1630522948197)
@@ -943,10 +943,10 @@
'no-spaced-func': 'error',
// import variables for sounds and images must have the conventional suffix
- 'import-resource-variable-suffix': 'error'
+ 'import-resource-variable-suffix': 'error',
// TODO: comment back in when >1200 errors are fixed, see https://github.com/phetsims/chipper/issues/1079
- // 'default-import-match-filename': 'error'
+ 'default-import-match-filename': 'error'
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
},
env: {
What are you feeling about this? |
This lint rule is working well, thanks @zepumph. I just removed a console.log, but I tested it and it is working well. |
Excellent. I'm going to close this issue, and pick this up over in #1060 |
Should
Similarly |
Nevermind, I see now that |
Discussed during discussion in #1060.
The text was updated successfully, but these errors were encountered: