Comments (7)
Thank you for posting this issue.
I welcome PR.
from eslint-plugin-jsonc.
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 theprop-one
to before theprop-four
;
2 - Validates the schema;
3 - Schema fails, moves theprop-one
to before theprop-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.
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.
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
:
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.
Any updates on this?
from eslint-plugin-jsonc.
Please open a pull request.
from eslint-plugin-jsonc.
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)
- Adding no-duplicate-values-in-json files rule feature to the plugin HOT 14
- Allow ignoring certain paths from sorting HOT 3
- Error importing this plugin in Vite application HOT 2
- Add only allow flattened/nested keys rule HOT 1
- Request textDocument/codeAction failed. HOT 1
- "jsonc/no-comments" regra - Há um bug que Comentário no início do bloco é igno
- "jsonc/no-comments" rule - [bug] some comments are ignored HOT 2
- Support configuration file eslint.config.js HOT 1
- Conflict with @typescript-eslint/recommended-requiring-type-checking? HOT 1
- vscode-eslint extension cannot validate JSON using the "eslint.probe" configuration HOT 4
- Question: vscode and JSON5 syntax highlight HOT 2
- sort-keys need to run many times to sort big files HOT 4
- sort-keys: Misplaced comments in tsconfig.json HOT 1
- Internal code suggestion: add explicit call signatures for RuleListener node types? HOT 1
- Keep getting "Parsing error: Expected to be an expression, but got empty" HOT 7
- Error: Cannot find module 'espree'
- Struggling to get plugin to work with typescript parser... HOT 2
- Version 3 HOT 1
- typescript gives an error saying `synckit` is an ESM package, but `synckit` can also be used with commonjs. I don't quite understand the correct way to configure typescript 😓
- How config correctly my eslint config with jsonc HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from eslint-plugin-jsonc.