ota-meshi / eslint-plugin-yml

This ESLint plugin provides linting rules for YAML.
https://ota-meshi.github.io/eslint-plugin-yml/
MIT License
113 stars 13 forks source link

Inconsistent spacing in `yml/flow-mapping-curly-spacing` #303

Closed MorevM closed 6 months ago

MorevM commented 6 months ago

Good day, First of all, thank you for all your work :)

I believe I found an edge case in the yml/flow-mapping-curly-spacing rule.

Minimal reproduction

Given configuration:

'yml/flow-mapping-curly-spacing': ['warn', 'always', {
  arraysInObjects: false,
  objectsInObjects: true,
}]

YAML file contents

- { foo: bar }
- { foo: [foo, bar]}
#                  ↑
# expected a space before the closing brace, but rule reports (and auto-fixes) to this

It only occurs in scenario "array value is the last element of entry" If it matters, the original ESLint rule object-curly-spacing referenced in the rule description does not have this issue.

I can make a PR to fix this (within 1-2 weeks) if you can confirm this is a bug. :)

ota-meshi commented 6 months ago

I can't reproduce the problem. Could you please create a minimal repository that can reproduce the problem and share it?

MorevM commented 6 months ago

@ota-meshi here is the repository: https://github.com/MorevM/flow-mapping-curly-spacing-reproduction

ota-meshi commented 6 months ago

Hmm. I'm not sure. I think the rule is working as expected. Shouldn't you use arraysInObjects: true if you want to match your preferred style?

MorevM commented 6 months ago

Yes, you are right, I misunderstood the option description. It works exactly as described in the documentation, if read carefully.

I probably thought at the time that it was referring to the array brackets inside a flow entry... Embrassing :) Sorry for the noise and thank you for clarification. I close this. :)