Giter Club home page Giter Club logo

Comments (7)

ota-meshi avatar ota-meshi commented on June 2, 2024

Thank you for posting this issue.
I welcome PR.

from eslint-plugin-jsonc.

joseh29 avatar joseh29 commented on June 2, 2024

Thank you for replying.

I forked the repository and used debug to try and find an approach to solve this problem. Here are my conclusions (which may or may not be right):

  • Inside a specific rule there is no information whatsoever about what schema was defined. This means that, there is no access to the order defined by the user in the schema.
  • From what I saw, the auto-fix function just keeps shifting the property and validating over and over until the property is in the right place. In the case presented above, it:
    1 - Moves the prop-one to before the prop-four;
    2 - Validates the schema;
    3 - Schema fails, moves the prop-one to before the prop-three;
    4 - Validates the schema;
    5 - ...

Are my conclusions about right?
My solution would be to pass the schema information to each script rule, in order to see what was defined by the user and have direct access to the order array. Is this possible? 🙏

from eslint-plugin-jsonc.

ota-meshi avatar ota-meshi commented on June 2, 2024

I'm still not quite sure what you're trying to do. So I'm not sure if your changes are right or not. Can you open a PR and share your code?

from eslint-plugin-jsonc.

joseh29 avatar joseh29 commented on June 2, 2024

I don't know what changes to make in order to open a PR.
I'll try to rephrase it.
On the file lib/rules/sort-keys.ts, I wanted to change the function verifyProperty to have access to the User defined schema. In the previous example, I wanted to have access to this object, inside the verifyProperty:
image
So that I can extrapolate the correct order in which the properties should be in and use this context in the error message.
For e.g (this would then be possible, not necessary, but possible):

> (...) 'prop-one' should be before 'prop-two' (...) The order should be 'prop-one' > 'prop-two' > 'prop-three' > 'prop-four'  jsonc/sort-keys

Does this make sense? 🤔

(I believe that, with this type of information, the *fix would be much easier to implement)

from eslint-plugin-jsonc.

joseh29 avatar joseh29 commented on June 2, 2024

Any updates on this?

from eslint-plugin-jsonc.

ota-meshi avatar ota-meshi commented on June 2, 2024

Please open a pull request.

from eslint-plugin-jsonc.

Hisioni avatar Hisioni commented on June 2, 2024

I aslo had same situation,then i try typing some config to settings.json

"eslint.validate": [
    "javascript",
    "javascriptreact",
    "typescript",
    "typescriptreact",
    "html",
    "vue",
    "markdown",
    "json",
    "jsonc",
    "json5"
  ]

then it's work now!

from eslint-plugin-jsonc.

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.