Dvc.org: lint: run prettier on all doc files

Created on 31 Jul 2019  路  15Comments  路  Source: iterative/dvc.org

See https://github.com/iterative/dvc.org/issues/512#issuecomment-518894225


A problem after implementing #372 seems to be that pretty-quick is that some lines inside md fenced code blocks, the ones starting with -, seem to be confused for bullets, and thus indented. E.g. everything starting at path would be indented in the sample below (from static/docs/user-guide/external-dependencies.md):

image

The linter should simply ignore code blocks 馃檪 OK'd by Ivan in https://github.com/iterative/dvc.org/issues/512#issuecomment-518878493

bug doc-engine priority-p1

All 15 comments

Sorry to pick on you @algomaster99... But you may also be the best equipped person to give this one a first look. No worries either way but please lmk.

@jorgeorpinel I tried this but I couldn't reproduce the issue. I think prettier does ignore the indentation inside the code block.
bug

Not sure it's prettier or what. It happens when I try to git commit the file with any other change in it.

@jorgeorpinel I can still not reproduce this. But if it does, please send a screenshot again of the latest code (the above image seems outdated).
To my knowledge, prettier doesn't interfere with the indentation since that will throw errors. Check this playground out.

If the error still persists, we can resort to this method (which I don't prefer to be honest :sweat_smile: ):

<!-- prettier-ignore -->
```js
ugly   ( code ) ;

Just change anything in static/docs/commands-reference/import-url.md (outside of YAML code blocks) and try to git commit your change. It will indent parts of the YAML code block contents:

Screen Recording 2019-08-04 at 01 59 50 2019-08-04 02_08_11

p.s. creating this gif took a long time. What did you make them with again? Thanks

@jorgeorpinel
This is really strange :open_mouth:
weird
Can you check your prettier version in package-lock.json? Mine is 1.17.0.

Creating screencasts

  1. Download this software: https://www.maartenbaert.be/simplescreenrecorder/
  2. Use this link to convert the .mp4 video - created from the above software to a .gif.

It's the same version. In your screenshots the lines in question are already indented as that's the master branch. But the actual DVC-files don't have that indentation so I've un-indented them in my fork. Please un-indent them (or use my fork) to reproduce the issue.

@jorgeorpinel I think both are valid syntaxes. Refer to this link.

Current

md5: 7de90e7de7b432ad972095bc1f2ec0f8
wdir: .
deps:
- path: data/data.xml
  repo:
    url: [email protected]:iterative/example-get-started
    rev_lock: 6c73875a5f5b522f90b5afa9ab12585f64327ca7
outs:
- md5: a304afb96060aad90176268345e10355
  path: data.xml
  cache: true
  metric: false
  persist: false

Prettier formatting

md5: 7de90e7de7b432ad972095bc1f2ec0f8
wdir: .
deps:
  - path: data/data.xml
    repo:
      url: [email protected]:iterative/example-get-started
      rev_lock: 6c73875a5f5b522f90b5afa9ab12585f64327ca7
outs:
  - md5: a304afb96060aad90176268345e10355
    path: data.xml
    cache: true
    metric: false
    persist: false

Please refer to this playground too. Prettier just format it the way it is configured. I couldn't find any option to toggle it.

It's not about whether its valid YAML or not. These are copy-paste of DVC-files so they should not be changed by the linter.

Prettier just format it the way it is configured. I couldn't find any option to toggle it.

So is the only option left is to prepend each block with <!-- prettier-ignore -->?

@jorgeorpinel I think it's fine if it's hard to fix it and if YAML is valid.

Yeah I guess if it can't be fixed with our current linter its better to let it indent those locks instead of having to add a bunch of <!-- prettier-ignore -->s.

BTW weren't we going to run prettier on all the docs? I don't think we ever did that @algomaster99 would you like to try it? And open a PR that closes this issue (notice changed title) if successful 馃檪

@jorgeorpinel I might have done this here. Let me run it again and find if there are changes or not.

@algomaster99 should we run it for docs as well once again like @jorgeorpinel suggested?

Yeah I meant on md files too 馃檪

I see it was done in #530

Was this page helpful?
0 / 5 - 0 ratings