This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 248906 - Project name not formatted properly in package.json file
Summary: Project name not formatted properly in package.json file
Status: RESOLVED FIXED
Alias: None
Product: javascript
Classification: Unclassified
Component: JSON (show other bugs)
Version: 8.1
Hardware: All All
: P3 normal (vote)
Assignee: Roman Svitanic
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-11-25 21:33 UTC by Vladimir Riha
Modified: 2015-05-22 02:56 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
region to format (17.29 KB, image/png)
2015-05-20 09:26 UTC, Tomas Mysik
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Vladimir Riha 2014-11-25 21:33:03 UTC
If you have package.json that does not contain e.g. name or scripts->start and make changes in project properties that would cause inserting either one of these 2 properties to the JSON file, it is inserted with wrong indentation. 

Thank you


Product Version: NetBeans IDE Dev (Build web-main-1584-on-20141125)
Java: 1.7.0_45; Java HotSpot(TM) 64-Bit Server VM 24.45-b08
Runtime: Java(TM) SE Runtime Environment 1.7.0_45-b18
System: Linux version 3.13.0-37-generic running on amd64; UTF-8; en_US (nb)
Comment 1 Tomas Mysik 2015-04-24 05:38:46 UTC
We run formatter on newly inserted text but apparently it fails - could you please verify it? Perhaps we should widen the region we format.

Thanks.
Comment 2 Vladimir Riha 2015-04-24 08:47:43 UTC
Yes, it is now enough. If you e.g. create AngularMessages sample, remove the line with 

"name" : 

and format file and close it, then if you change project's name in IDE the json file looks like 


{
    "version": "1.0.0",
    "keywords": [
        "NetBeans",
        "node.js",
        "sample"
    ],
    "author": "NetBeans",
    "dependencies": {
        "express": "^4.10.1",
        "body-parser": "^1.4.3",
        "bower": "~1.3.12"
    },
    "devDependencies": {
        "gulp": "^3.8.10",
        "gulp-jshint": "^1.9.0",
        "jshint-stylish": "^1.0.0"
    },
    "scripts": {
        "start": "node server/server.js"
    },
            "name": "MessagesAngularA"
}


Product Version: NetBeans IDE Dev (Build 201504170001)
Java: 1.8.0_40; Java HotSpot(TM) Client VM 25.40-b25
Runtime: Java(TM) SE Runtime Environment 1.8.0_40-b25
System: Linux version 3.13.0-35-generic running on i386; UTF-8; en_US (nb)
Comment 3 Tomas Mysik 2015-05-20 09:26:02 UTC
I just found out that this issue is in fomatter itself.

Try to format just the line with "name" key/field (or even with the preceding comma, see attachment):

{
    "scripts": {
        "start": "node server\/server.js",
        "postinstall": "node node_modules/bower/bin/bower install"
    },
"name": "MessagesKnockout"
}

Thanks.
Comment 4 Tomas Mysik 2015-05-20 09:26:28 UTC
Created attachment 153764 [details]
region to format
Comment 5 Tomas Mysik 2015-05-20 11:29:36 UTC
Reproducible only in package.json, other *.json files work properly.
Comment 6 Roman Svitanic 2015-05-20 13:43:31 UTC
Changeset: ef4d7d321ece
Author:    Roman Svitanic <rsvitanic@netbeans.org>
Date:      2015-05-20 15:43
Message:   #248906: Project name not formatted properly in package.json file - fixed
Comment 7 Quality Engineering 2015-05-22 02:56:47 UTC
Integrated into 'main-silver', will be available in build *201505220001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/ef4d7d321ece
User: Roman Svitanic <rsvitanic@netbeans.org>
Log: #248906: Project name not formatted properly in package.json file - fixed
Task #248906 - Project name not formatted properly in package.json file