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

[WIP]tools: simply eslint tasks #26054

Closed
wants to merge 2 commits into from

Conversation

gengjiawen
Copy link
Member

@gengjiawen gengjiawen commented Feb 12, 2019

This is subtask of #25908.

Main Changes made

  • delete all tools/node_modules/eslint, tools/node_modules/babel-eslint
  • create package.json with lint task
  • rewrite Makefile and vcbuild.bat
  • related change to .eslintrc.js and tools/lint-js.js

Process

I am not fluent in bash or bat, nor familiar with the whole lint process.
Any help would be very welcome.

cc @Trott @refack @joyeecheung

Checklist

  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • commit message follows commit guidelines

@nodejs-github-bot nodejs-github-bot added build Issues and PRs related to build files or the CI. meta Issues and PRs related to the general management of the project. tools Issues and PRs related to the tools directory. labels Feb 12, 2019
@gengjiawen gengjiawen changed the title tools: simply eslint tasks [WIP]tools: simply eslint tasks Feb 12, 2019
@gengjiawen gengjiawen force-pushed the feature/simple branch 3 times, most recently from fc4d3e4 to c0ca7f4 Compare February 12, 2019 13:20
@Trott Trott added the wip Issues and PRs that are still a work in progress. label Feb 12, 2019
@Trott
Copy link
Member

Trott commented Feb 12, 2019

Current process for updating ESLint is to run tools/update-eslint.sh. There's also a tools/update-babel-eslint.sh. You'll want to either modify those so that they still work or else remove them if they are now unnecessary.

@refack
Copy link
Contributor

refack commented Feb 12, 2019

@gengjiawen did you try to ncc the tool like #24813. IMHO that would be optimal to just removing.

I'm not in favor of having an npm call as part of regular make targets.
A alternative could be to ifneq around it similar to:

node/Makefile

Lines 1300 to 1312 in 43dd49c

ifneq ("","$(wildcard tools/pip/site-packages)")
.PHONY: lint-py
# Lints the Python code with flake8.
# Flag the build if there are Python syntax errors or undefined names
lint-py:
PYTHONPATH=tools/pip $(PYTHON) -m flake8 . \
--count --show-source --statistics --select=E901,E999,F821,F822,F823 \
--exclude=.git,deps,lib,src,test/fixtures,tools/*_macros.py,tools/gyp,tools/inspector_protocol,tools/jinja2,tools/markupsafe,tools/pip
else
lint-py:
@echo "Python linting with flake8 is not avalible"
@echo "Run 'make lint-py-build'"
endif

P.S. could you split the PR to two commits; 1 with all the tool changes, and a second with the deletions? It's very difficult to review this PR with the GitHub GUI.

@gengjiawen
Copy link
Member Author

gengjiawen commented Feb 12, 2019

@Trott I have remove the sh files.

@refack I have split with two commit.

@Trott
Copy link
Member

Trott commented Feb 12, 2019

I'd like to better understand the motivation here. Honestly, this may be a solution in search of a problem?

From #25908:

  • Upgrade toolchain like eslint cumbersome.

I don't know about other toolchains, but upgrading ESLint in core has become trivial. /ping @cjihrig

  • Lint fix
    Node community is more familiar with nodejs tools like npm or yarn instead of bash or bat file.

If it were a part of the code base that lots of people were touching or that we wanted more help with, sure. But that's decidedly not the case with ESLint-tooling-for-core.

@cjihrig
Copy link
Contributor

cjihrig commented Feb 12, 2019

I agree with @Trott. Personally, I'm content with the status quo when it comes to core's current ESLint setup.

@Trott
Copy link
Member

Trott commented Feb 12, 2019

I'd like to better understand the motivation here. Honestly, this may be a solution in search of a problem?

Answering my own comment a little: One argument is to put ESLint in line with the other tools that already use npm-ci in Makefile, thus streamlining things a bit.

Anyway, I don't actually have an opinion on this one way or the other yet. I'm trying to understand the motivation more completely so that I have a better-informed opinion. :-D

@gengjiawen
Copy link
Member Author

gengjiawen commented Feb 12, 2019

I don't know about other toolchains, but upgrading ESLint in core has become trivial

There are other reason I don't like copy all eslint and babel-eslint and all its dependency code to this repo. It's just a tool. Also with this review eslint upgrade will be much easier.

But that's decidedly not the case with ESLint-tooling-for-core.

Also I think we have same lint logic in both Makefile and vcbuild.bat. Unify it in package.json will remove redundant code. Second, with this I want gradually move other tools like clang-format to similar approach too (You can't use clang-format on windows easily for now since they only introduced in Makefile).

@Trott
Copy link
Member

Trott commented Feb 12, 2019

@nodejs/linting

@richardlau
Copy link
Member

richardlau commented Feb 12, 2019

I'd lean towards the status quo as well. If we do switch, however, I'd prefer to keep the tools (the new package.json and node_modules) installed into a subdirectory of tools and not in the root of the source tree.

@Trott
Copy link
Member

Trott commented Feb 12, 2019

FWIW, if I'm not mistaken, I think the commits here are in the reverse order to how they should be. You want to simplify the process first, then remove the existing tools. Otherwise, if these land as separate commits, the build will be broken with the first commit.

Makefile Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
@gengjiawen
Copy link
Member Author

gengjiawen commented Feb 12, 2019

FWIW, if I'm not mistaken, I think the commits here are in the reverse order to how they should be.

Yeap, but the ci still fails. When we fix all issue and I will rebase the commits.

@gengjiawen gengjiawen force-pushed the feature/simple branch 2 times, most recently from f81b443 to 1f4c339 Compare February 12, 2019 14:49
"lint": "eslint --cache --report-unused-disable-directives --ext=.js,.mjs,.md .eslintrc.js benchmark doc lib test tools"
},
"dependencies": {
"babel-eslint": "8.2.1",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I stay on the old version since it's currently used in node core.

'eslint-plugin-node-core',
'eslint-plugin-markdown',
'babel-eslint',
'eslint-plugin-node-core'
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The other two on npm, so I installed them using internal npm.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://www.npmjs.com/package/eslint-plugin-node-core has not been updated properly (though it's probably just a matter of running the update script again)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found that too. Perhaps just leave this plugin in this repo for now.

@gengjiawen
Copy link
Member Author

gengjiawen commented Feb 12, 2019

@refack

did you try to ncc the tool like #24813. IMHO that would be optimal to just removing.

I still want to delete it from sources, see #26054 (comment).

I'm not in favor of having an npm call as part of regular make targets.

Actually it's already using in Makefile. It's only used in lint task and it's very simple.

@devsnek
Copy link
Member

devsnek commented Feb 12, 2019

echoing above, i'm also content with the current system.

@gengjiawen
Copy link
Member Author

gengjiawen commented Feb 12, 2019

@richardlau

I'd prefer to keep the tools (the new package.json and node_modules) installed into a subdirectory of tools and not in the root of the source tree.

Any strong reason for this ? With your suggested change, many script need to be changed. like package.json task.

  "scripts": {
    "lint": "eslint --cache --report-unused-disable-directives --ext=.js,.mjs,.md .eslintrc.js benchmark doc lib test tools"
  },

@gengjiawen
Copy link
Member Author

echoing above, i'm also content with the current system.

If most members of the node team don't like the idea. Fine with me. Just want to share my idea :)

@richardlau
Copy link
Member

@richardlau

I'd prefer to keep the tools (the new package.json and node_modules) installed into a subdirectory of tools and not in the root of the source tree.

Any strong reason for this ? With your suggested change, many script need to be changed. like package.json task.

  "scripts": {
    "lint": "eslint --cache --report-unused-disable-directives --ext=.js,.mjs,.md .eslintrc.js benchmark doc lib test tools"
  },

My reasoning being "tools go in... tools"? 😆

Putting a package.json in the root of the Node.js source tree feels like a hack.

@gengjiawen
Copy link
Member Author

gengjiawen commented Feb 13, 2019

I want to explain more what I think we can benefit from this:

Remove eslint sources will make repo cleaner and slimer

Add all its files to this repo will increase repo size though not much. It also not very good when you find file in this repo since they also will be included in search path. Also IDE will index them but I don't think you will want to change the source in this repo. Currently we have 7327 files for eslint.

Review eslint upgrade pr or backport will be easier.

we often keep eslint up to date, but review them is quite easy. They usually has hundreds or thousands file in changing. You can search it here https://github.com/nodejs/node/pulls?q=is%3Apr+eslint+is%3Aclosed.

Make the dependency transparent

When I am working on this pr I realized we are not just use eslint and babel-eslint, we also use eslint-plugin-markdown, glob, js-yaml. They install stayed in node_modules. In the future, we may need more eslint plugins. Making it explicit will make it clear which community tools we are using.

Easier cross-platform

On unix-like OS, you can run run-lint-js-fix to auto fix your issue. But this not available on windows, you have too add the --fix to vcbuild.bat to get what you want. With the change, you don't need to remember the task name or make the change, you can just run npm run lint --fix.

@gengjiawen
Copy link
Member Author

gengjiawen commented Feb 17, 2019

Anyone know why npm install failed ? The first two check failed due to this issue.
image

https://travis-ci.com/nodejs/node/jobs/177139705

npm WARN deprecated circular-json@0.3.3: CircularJSON is in maintenance only, flatted is its successor.
> node-core@1.0.0 install /home/travis/build/nodejs/node
> node-gyp rebuild
gyp: binding.gyp not found (cwd: /home/travis/build/nodejs/node) while trying to load binding.gyp
gyp ERR! configure error 
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/home/travis/.nvm/versions/node/v11.9.0/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:345:16)
gyp ERR! stack     at ChildProcess.emit (events.js:197:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:254:12)
gyp ERR! System Linux 4.4.0-101-generic
gyp ERR! command "/home/travis/.nvm/versions/node/v11.9.0/bin/node" "/home/travis/.nvm/versions/node/v11.9.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/travis/build/nodejs/node
gyp ERR! node -v v11.9.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok 
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-core@1.0.0 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the node-core@1.0.0 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR!     /home/travis/.npm/_logs/2019-02-12T15_12_53_402Z-debug.log
The command "eval npm install  " failed. Retrying, 2 of 3.

@gengjiawen
Copy link
Member Author

gengjiawen commented Feb 17, 2019

I tried yarn locally, it works ...

Report to npm: https://npm.community/t/npm-install-failed-on-node-core/5438.

@gengjiawen gengjiawen force-pushed the feature/simple branch 5 times, most recently from f04884e to bd085b9 Compare February 17, 2019 12:15
@HarshithaKP
Copy link
Member

ping @gengjiawen, this needs a rebase.

@BridgeAR BridgeAR force-pushed the master branch 2 times, most recently from 8ae28ff to 2935f72 Compare May 31, 2020 12:19
@jasnell jasnell added the stalled Issues and PRs that are stalled. label Jun 25, 2020
@jasnell
Copy link
Member

jasnell commented Jun 25, 2020

Ping @gengjiawen ... is this still something you'd like to do?

@jasnell jasnell marked this pull request as draft June 25, 2020 22:51
@gengjiawen
Copy link
Member Author

Ping @gengjiawen ... is this still something you'd like to do?

I would like to. But seems no time for time being, close it :(

@gengjiawen gengjiawen closed this Jun 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build Issues and PRs related to build files or the CI. meta Issues and PRs related to the general management of the project. stalled Issues and PRs that are stalled. tools Issues and PRs related to the tools directory. wip Issues and PRs that are still a work in progress.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants