Skip to content
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

Simplify getGruntConfig in how it retrieves the files to lint #565

Closed
zepumph opened this issue Apr 14, 2017 · 15 comments
Closed

Simplify getGruntConfig in how it retrieves the files to lint #565

zepumph opened this issue Apr 14, 2017 · 15 comments
Assignees

Comments

@zepumph
Copy link
Member

zepumph commented Apr 14, 2017

Currently there is a ton of conditional logic to determine whether or not a file should be linted for specific tasks. @samreid and I were talking in regards to #1095 and we think that this can be improved.

Shouldn't we just be able to lint all files in the correct repos for the task, and have the built in eslint directives ( like `// eslint-disable') decide on a per file basis if we want to lint it.

@zepumph
Copy link
Member Author

zepumph commented Apr 14, 2017

Maybe rather than using the grunt plugin, we could just use npm's eslint modules. See here http://eslint.org/docs/developer-guide/nodejs-api#getformatter. This could be very similar to how we got boxed in with grunt's requirejs plugin.

@samreid
Copy link
Member

samreid commented Apr 14, 2017

I added a new linter above which is simpler in its implementation and more flexible:

  • helped catch lint errors the other process was missing
  • automatically hits all *.js files instead of just cherry picking some of the js/ directories
  • replaced 170 lines of somewhat complicated getGruntConfig.js with 89 lines of more straightforward lint.js
  • we need to put 'eslint' in package.json instead of 'grunt-eslint' (seems better to not rely on a plugin being maintained)
  • one cache file per target
  • doesn't enumerate the "everything" unless you ask for it (speeds up builds)

To use it, replace the lint tasks in Gruntfile.js with these lines:

var lint = require( '../../../chipper/js/grunt/lint' ); // and this import
//...
  /**
   * Returns a function that lints the specified target.
   * @param {string} target 'dir'|'all'|'everything'
   * @returns {function}
   */
  var runLint = function( target ) {
    return function() {
      lint( grunt, target, buildConfig );
    };
  };
  grunt.registerTask( 'lint', 'lint js files that are specific to this repository', runLint( 'dir' ) );

  grunt.registerTask( 'lint-all', 'lint all js files that are required to build this repository', runLint( 'all' ) );

  grunt.registerTask( 'lint-everything', 'lint all js files that are required to build this repository', runLint( 'everything' ) );

You may also need "eslint" in a node_modules, perhaps from chipper/package.json + npm install (somehow I already had one).

After code review and testing is complete, we will need to do the following steps:

  1. remove grunt-eslint from package.json
  2. add eslint to package.json
  3. delete getGruntConfig.js and its usages.
  4. add the grunt.registerTasks to master

@pixelzoom, @jonathanolson or @zepumph are you available to review?

@jonathanolson jonathanolson assigned samreid and unassigned pixelzoom and zepumph Apr 16, 2017
@jonathanolson
Copy link
Contributor

Initial review of the code looks good.

Testing this in each repo would be next. I don't see information about what eslint version to use in package.json/etc.

@samreid, could we collaborate on this sometime by changing master working copies, running tests in each repository, and then pushing?

@samreid
Copy link
Member

samreid commented Apr 17, 2017

@jonathanolson I'm available today, let me know when is a good time for you to collaborate.

@jonathanolson
Copy link
Contributor

Whenever, also available today. Message me on Skype?

@samreid
Copy link
Member

samreid commented Apr 17, 2017

@jonathanolson and I looked into this today, and found the new process seems like it is working well. We tested grunt lint on active runnables and didn't see any new errors (though a few repos were missed because I didn't have npm install already). Next steps:

I'll take it from here.

@samreid
Copy link
Member

samreid commented Apr 17, 2017

I also realized grunt.initConfig( gruntConfig ); would now be passing in an empty object, so perhaps we don't need to call it any more.

@samreid
Copy link
Member

samreid commented Apr 17, 2017

Find duplicates didn't "just work" with the new paths, so I inlined getGruntConfig into it (so it will only be called when needed) and created #566.

@samreid
Copy link
Member

samreid commented Apr 17, 2017

I commented in the skype channel:

Brace yourself for a mega commit, 100+ repos

samreid added a commit to phetsims/states-of-matter-basics that referenced this issue Apr 17, 2017
samreid added a commit to phetsims/simula-rasa that referenced this issue Apr 17, 2017
samreid added a commit to phetsims/charges-and-fields that referenced this issue Apr 17, 2017
samreid added a commit to samreid/ludum-dare-35-shapeshift that referenced this issue Apr 17, 2017
samreid added a commit to phetsims/scenery that referenced this issue Apr 17, 2017
samreid added a commit to phetsims/seasons that referenced this issue Apr 17, 2017
samreid added a commit to phetsims/scenery-phet that referenced this issue Apr 17, 2017
samreid added a commit to phetsims/rutherford-scattering that referenced this issue Apr 17, 2017
samreid added a commit to phetsims/reactants-products-and-leftovers that referenced this issue Apr 17, 2017
samreid added a commit to phetsims/resistance-in-a-wire that referenced this issue Apr 17, 2017
samreid added a commit to phetsims/protein-synthesis that referenced this issue Apr 17, 2017
samreid added a commit to phetsims/projectile-motion that referenced this issue Apr 17, 2017
samreid added a commit to phetsims/proportion-playground that referenced this issue Apr 17, 2017
samreid added a commit to phetsims/plinko-probability that referenced this issue Apr 17, 2017
samreid added a commit to phetsims/capacitor-lab-basics that referenced this issue Apr 17, 2017
samreid added a commit to phetsims/ph-scale-basics that referenced this issue Apr 17, 2017
samreid added a commit to phetsims/ph-scale that referenced this issue Apr 17, 2017
samreid added a commit to phetsims/pendulum-lab that referenced this issue Apr 17, 2017
samreid added a commit to phetsims/ohms-law that referenced this issue Apr 17, 2017
samreid added a commit to phetsims/molecules-and-light that referenced this issue Apr 17, 2017
samreid added a commit to phetsims/neuron that referenced this issue Apr 17, 2017
@samreid
Copy link
Member

samreid commented Apr 17, 2017

I commented in skype:

pushes complete, JO and I tested locally and all seemed well, but I recommend you wait for bayes to take a closer look before you pull

@samreid
Copy link
Member

samreid commented Apr 17, 2017

I commented in skype:

After pulling the 100+ repo changes, you (everyone) will need to npm prune + npm update in all your repos.

samreid added a commit to phetsims/masses-and-springs that referenced this issue Apr 17, 2017
samreid added a commit that referenced this issue Apr 17, 2017
@samreid
Copy link
Member

samreid commented Apr 17, 2017

Bayes helped catch 3 errors, everything else seems OK. We should also keep our eyes peeled for perennial issues since perennial/package.json changed.

@samreid
Copy link
Member

samreid commented Apr 17, 2017

I wrote in on skype:

[4/17/17, 11:08:46 AM] Sam Reid: Dear next deployer, perennial/package.json changed and the next RC or production deploy will help us understand whether it is OK
[4/17/17, 11:08:53 AM] Sam Reid: So keep you eyes peeled!

@samreid
Copy link
Member

samreid commented Apr 17, 2017

I added:

[4/17/17, 11:10:37 AM] Sam Reid: I have no idea if/how perennial updates itself. Do we have to pull it manually? Or does it always self-pull?
[4/17/17, 11:10:50 AM] Sam Reid: Does it know how to npm prune + npm update itself?

@samreid
Copy link
Member

samreid commented Apr 17, 2017

It sounds like perennial update is manual, and dev release was made with no trouble. I'll close this until we run into problems.

@samreid samreid closed this as completed Apr 17, 2017
zepumph pushed a commit to phetsims/perennial that referenced this issue Jul 21, 2022
zepumph pushed a commit to phetsims/perennial that referenced this issue Jul 21, 2022
zepumph pushed a commit to phetsims/perennial that referenced this issue Jul 21, 2022
samreid added a commit to phetsims/perennial that referenced this issue Oct 17, 2024
samreid added a commit to phetsims/perennial that referenced this issue Oct 17, 2024
samreid added a commit to phetsims/perennial that referenced this issue Oct 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants