Git Product home page Git Product logo

Comments (13)

blefnk avatar blefnk commented on September 28, 2024 1

@coderaiser Thanks for your response! Yes, of course, I plan to do it on Tuesday. I also plan to try to build Putout on my own. I will also try to run it on my other laptop with Windows 11. I will get back to you once I manage to explore a bit more details. Thank you for the search link πŸ‘

from putout.

coderaiser avatar coderaiser commented on September 28, 2024 1

Just fixed similar bug in 🐊Putout v35.35.5. Could you please tell me if it works for you?

from putout.

coderaiser avatar coderaiser commented on September 28, 2024 1

Could you please try to pass β€”-raw flag when running 🐊Putout and check ~/.putout.json in your home directory, looks like issue with configuration file, but I’m not sure what exactly issue is.

from putout.

coderaiser avatar coderaiser commented on September 28, 2024 1

Looks like picomatch works differently on win and unix. I don't know what the problem with name.startsWith but 🐊 No processors found for test.js fixed in v35.35.6 πŸŽ‰ and should work good. Is it works for you?

from putout.

coderaiser avatar coderaiser commented on September 28, 2024 1

Looks like name.startsWith is not a function is pnpm-specific issue. Try to use bun to install dependencies. Also you can create issue in pnpm repository.

from putout.

coderaiser avatar coderaiser commented on September 28, 2024 1

I cannot reproduce this with pnpm:

coderaiser@localcmd:~/putout$ cat > 1.js
const a = 'hello';
^C
coderaiser@localcmd:~/putout$ pnpm dlx putout@latest 1.js
1.js
 1:6  error   'a' is defined but never used  remove-unused-variables

βœ– 1 errors in 1 files
  fixable with the `--fix` option

If you have any ideas how to reproduce - you can send PR with test, I'll merge so it work for your case.

from putout.

coderaiser avatar coderaiser commented on September 28, 2024 1

Could you please provide an example of broken config? Just copied putout.json from monorepo and still cannot reproduce. Maybe link to minimal repository can help.

from putout.

coderaiser avatar coderaiser commented on September 28, 2024 1

I suggest you to always install 🐊Putout as devDependency, if you install it as global, and run it as global, additional processors (like @putout/processor-typescript) should be also installed globally. devDependency is convinient and recommended way to install and run 🐊Putout.

from putout.

coderaiser avatar coderaiser commented on September 28, 2024

Hi, thank you!

I cannot reproduce this:

coderaiser@localcmd:~/Amber$ cat > 1.js
var a = 5;
^C
coderaiser@localcmd:~/Amber$ npx putout 1.js
1.js
 1:4  error   'a' is defined but never used  remove-unused-variables

βœ– 1 errors in 1 files
  fixable with the `--fix` option

but there is a couple places where bug can occur: https://github.com/search?q=repo%3Acoderaiser%2Fputout%20name.startsWith&type=code.

Could you please provide more details? Maybe you can add console.log to identify problem place?

from putout.

blefnk avatar blefnk commented on September 28, 2024
devDependencies:
- putout 35.35.4
+ putout 35.35.5
> pnpm putout test.js
🐊 name.startsWith is not a function
> pnpm dlx putout@latest test.js
🐊 name.startsWith is not a function
> npm run putout test.js
🐊 name.startsWith is not a function
> npx putout@latest test.js
🐊 name.startsWith is not a function

// without .putout.json
npx putout@latest test.js
🐊 No processors found for test.js
bun add -D putout@latest
installed [email protected] with binaries: putout
> bun putout index.js      
$ putout index.js
🐊 name.startsWith is not a function
error: script "putout" exited with code 9

bun without .putout.json

bun add -D putout@latest
installed [email protected] with binaries: putout
> bun putout index.js
$ putout index.js
node:internal/event_target:1094
  process.nextTick(() => { throw err; });
                           ^
Error: Cannot find module './url'
Require stack:
- C:\B\S\putout-minimal-repro\node_modules\source-map\lib\util.js
- C:\B\S\putout-minimal-repro\node_modules\source-map\lib\source-map-generator.js
- C:\B\S\putout-minimal-repro\node_modules\source-map\source-map.js
- C:\B\S\putout-minimal-repro\node_modules\recast\lib\util.js
- C:\B\S\putout-minimal-repro\node_modules\recast\lib\options.js
- C:\B\S\putout-minimal-repro\node_modules\recast\lib\parser.js
- C:\B\S\putout-minimal-repro\node_modules\recast\main.js
- C:\B\S\putout-minimal-repro\node_modules\@putout\engine-parser\lib\print.js
- C:\B\S\putout-minimal-repro\node_modules\@putout\engine-parser\lib\parser.js
- C:\B\S\putout-minimal-repro\node_modules\putout\lib\putout.js
- C:\B\S\putout-minimal-repro\node_modules\putout\lib\cli\process-file.js
- C:\B\S\putout-minimal-repro\node_modules\putout\lib\cli\runner\runner.js
- C:\B\S\putout-minimal-repro\node_modules\putout\lib\cli\index.js
    at Function._resolveFilename (node:internal/modules/cjs/loader:1145:15)
    at Function._load (node:internal/modules/cjs/loader:986:27)
    at Module.require (node:internal/modules/cjs/loader:1233:19)
    at require (node:internal/modules/helpers:179:18)
    at Object.<anonymous> (C:\B\S\putout-minimal-repro\node_modules\source-map\lib\util.js:8:13)
    at Module._compile (node:internal/modules/cjs/loader:1358:14)
    at Object..js (node:internal/modules/cjs/loader:1416:10)
    at Module.load (node:internal/modules/cjs/loader:1208:32)
    at Function._load (node:internal/modules/cjs/loader:1024:12)
    at Module.require (node:internal/modules/cjs/loader:1233:19)
Emitted 'error' event on Worker instance at:
    at [kOnErrorMessage] (node:internal/worker:326:10)
    at [kOnMessage] (node:internal/worker:337:37)
    at MessagePort.<anonymous> (node:internal/worker:232:57)
    at [nodejs.internal.kHybridDispatch] (node:internal/event_target:820:20)
    at MessagePort.<anonymous> (node:internal/per_context/messageport:23:28) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    'C:\\B\\S\\putout-minimal-repro\\node_modules\\source-map\\lib\\util.js',
    'C:\\B\\S\\putout-minimal-repro\\node_modules\\source-map\\lib\\source-map-generator.js',
    'C:\\B\\S\\putout-minimal-repro\\node_modules\\source-map\\source-map.js',
    'C:\\B\\S\\putout-minimal-repro\\node_modules\\recast\\lib\\util.js',
    'C:\\B\\S\\putout-minimal-repro\\node_modules\\recast\\lib\\options.js',
    'C:\\B\\S\\putout-minimal-repro\\node_modules\\recast\\lib\\parser.js',
    'C:\\B\\S\\putout-minimal-repro\\node_modules\\recast\\main.js',
    'C:\\B\\S\\putout-minimal-repro\\node_modules\\@putout\\engine-parser\\lib\\print.js',
    'C:\\B\\S\\putout-minimal-repro\\node_modules\\@putout\\engine-parser\\lib\\parser.js',
    'C:\\B\\S\\putout-minimal-repro\\node_modules\\putout\\lib\\putout.js',
    'C:\\B\\S\\putout-minimal-repro\\node_modules\\putout\\lib\\cli\\process-file.js',
    'C:\\B\\S\\putout-minimal-repro\\node_modules\\putout\\lib\\cli\\runner\\runner.js',
    'C:\\B\\S\\putout-minimal-repro\\node_modules\\putout\\lib\\cli\\index.js'
  ]
}
Node.js v20.15.0
error: script "putout" exited with code 1

from putout.

blefnk avatar blefnk commented on September 28, 2024

I couldn't find .putout.json in my C:\Users\blefn home folder, subfolders there doesn't has this file as well. I just tried to create such a file myself, but unfortunately, the result is the same, with and without --raw flag.

> pnpm putout test.js --raw || pnpm dlx putout test.js --raw || npx putout test.js --raw
🐊 name.startsWith is not a function
error: "putout.cmd" exited with code 9

from putout.

blefnk avatar blefnk commented on September 28, 2024

Yeah, hooray! This almost resolved the issue! πŸŽ‰

Now putout works successfully as long as the putout dependency is not installed.

devDependencies:
- putout 35.35.6

However, if it is installed, it seems to "think" that it is part of the original monorepo and expects all its dependencies to be in the project, and since they are not, we get 🐊 No processors found for test.js (or also 🐊 name.startsWith is not a function).

So, theoretically, if all the necessary dependencies are installed, it should work. Maybe it’s necessary to add some peer dependencies to package.json binaries for putout? I mean, so that all the necessary dependencies of putout are installed together with putout. Or, is this already being done?

So currently, as a temporary solution, I added the following to scripts of package.json file: "putout": "pnpm dlx putout@latest", which makes pnpm putout test.js work successfully. This works both with and without a config.

upd. It turned out 🐊 name.startsWith is not a function is still present if .putout.json contains "formatter": [{ "minCount": 10 }, "progress-bar" ]. This happens even with pnpm dlx putout@latest.

It also turned out that when using pnpm dlx putout@latest, it is impossible to install custom processors. For example, when using "processors": ["javascript", "typescript"], I get 🐊 Cannot find package 'putout-processor-typescript', even though @putout/processor-typescript is installed. I have a theory that the config tries to refer to the putout library first, but it is not installed locally. Or maybe the problem is that it searches for the dependency "putout-processor-typescript" while the actual package is named @putout/processor-typescript? Hmm... πŸ€”

p.s. I also tried testing putout on Linux Mint, and to my great surprise, it turned out that 🐊 name.startsWith is not a function is not a Windows-specific issue; it is also present on Linux (and presumably on macOS, I guess).

upd. So strange, but it seems that everything works now when "formatter": [{ "minCount": 10 }, "progress-bar" ] is set. So this specific issue may be was solved.

from putout.

blefnk avatar blefnk commented on September 28, 2024

I have completed the investigation. It turned out that the latest issues were due to the fact that if there is a key-value pair in .putout.json that expects the presence of another key-value pair but does not find it, a problem occurs. That's why the formatter worked for me in the end, as I copy-pasted the entire putout.json from your monorepo. This issue also arises if there is incorrect sorting of key-value pairs. As a solution, a .js/.ts/.mjs config could be implemented in addition to json. So issue is not related to specific package manager or OS.

from putout.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.