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

jshint breaks on experimental feature import * as file_json from 'file.json' assert { 'type': 'json' }; #3639

Open
brunolnetto opened this issue Dec 31, 2022 · 11 comments

Comments

@brunolnetto
Copy link

I use jshint on a pre-commit hook for my repository . I use an experimental import feature for JSON import as on usage:

Repository branch : https://github.com/trouchet/sappio/tree/development

Results : https://results.pre-commit.ci/run/github/554918283/1672518676.9gUppcUFT82pDGGNrmiHew

Usage:

import * as pkg from '../../package.json' assert { 'type': 'json' };

Hook jshint complains

src/config/app_info.js: line 1, col 42, Missing semicolon.
src/config/app_info.js: line 1, col 43, Expected an assignment or function call and instead saw an expression.
src/config/app_info.js: line 1, col 49, Missing semicolon.
src/config/app_info.js: line 1, col 52, Expected an assignment or function call and instead saw an expression.
src/config/app_info.js: line 1, col 58, Missing semicolon.
src/config/app_info.js: line 1, col 58, Expected '}' to match '{' from line 1 and instead saw ':'.
src/config/app_info.js: line 1, col 60, Expected an assignment or function call and instead saw an expression.
src/config/app_info.js: line 1, col 66, Missing semicolon.
src/config/app_info.js: line 1, col 60, Unrecoverable syntax error. (25% scanned).
@prankush-sharma
Copy link

Hii, @brunolnetto may I work on this issue? . Please explain the issue what going wrong. I will try to solve this issue.

@brunolnetto
Copy link
Author

We can work on it together. I will introduce my perspective: NodeJS has the tag --experimental-modules for cases they are trying on different node versions. This is one of those. Since it is experimental, jshint-developers are also skeptical about its incorporation into the tool.

Reproduction steps:

  1. Create a NodeJS project;
  2. Create some JSON file filename.json at root path with content: {"property1": "value_1", "property2": [1, 2, 3, 4]}
  3. On src folder, insert line import * as pkg from '../filename.json' assert { 'type': 'json' };;
  4. Setup jshint on pre-commit file pre-commit-config.yaml:
repos:
  - repo: https://github.com/pre-commit/mirrors-jshint
    rev: 'v2.13.6'
    hooks:
      - id: jshint 
  1. Setup the project on website https://pre-commit.ci/;
  2. Make any change on the local repository and push-commit.

Do you get it?

@prankush-sharma
Copy link

yes, I get it. But I am new to this open source so, I'm not able to setup the project on https://pre-commit.ci/; Do you guide me to set up ?.

@brunolnetto
Copy link
Author

I just did it. Follow the steps and you will be able to do it.

@prankush-sharma
Copy link

ohk I will try.

@brunolnetto
Copy link
Author

In case you are hesitant into how to do it, they require first to setup your github account to receive mobile authentication tokens. Then, you can type the received number when requested on repository webhook sign up

@prankush-sharma
Copy link

I'm going to do it by fork and clone to my local system. Is it ohk ?.

@brunolnetto
Copy link
Author

Sure. Go ahead.

@prankush-sharma
Copy link

ohk I will try my best to fix errors.

@prankush-sharma
Copy link

Sorry, I'm not able to do it. I was tried too much but I'm to get it.

@brunolnetto
Copy link
Author

Sure, no problem. :-)

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

2 participants