如何克服那些更漂亮的错误?

发布于 2025-01-13 07:21:34 字数 6540 浏览 2 评论 0原文

在注释掉并取消注释 YML 文件中的某些行后,由于这些更漂亮的错误,我无法再将我的项目推送到我们的 Gitlab。准确地说,注释掉的块是服务器 8080,未注释的块是服务器 443。

✖ prettier --write:
[error] src/main/resources/config/application-prod.yml: SyntaxError: All collection items must start at the same column (16:1)
[error]        14 | # ===================================================================
[error]        15 |
[error] >    16 | logging:
[error]              | ^^^^^^^^
[error] >    17 |      level:
[error]              | ^^^^^^^^
[error] >    18 |          ROOT: INFO
[error]              | ^^^^^^^^
[error] >    19 |          tech.jhipster: INFO
[error]              | ^^^^^^^^
[error] >    20 |          com.abc.myapp: INFO
[error]              | ^^^^^^^^
[error] >    21 |
[error]              | ^^^^^^^^
[error] >    22 | management:
[error]              | ^^^^^^^^
[error] >    23 |      metrics:
[error]              | ^^^^^^^^
[error] >    24 |          export:
[error]              | ^^^^^^^^
[error] >    25 |              prometheus:
[error]              | ^^^^^^^^
[error] >    26 |                  enabled: false
[error]              | ^^^^^^^^
...
[error] > 129 |
[error]              | ^
husky - pre-commit hook exited with code 1 (error)

错误消息表明

 All collection items must start at the same column (16:1)

我根本没有更改这些行。在 IDE 中对同一文件的编辑前后版本进行比较后,我没有看到第 16 行这些行有任何变化。

如何克服这个问题?

这是原始文件:

# ===================================================================
# Spring Boot configuration for the "prod" profile.
#
# This configuration overrides the application.yml file.
#
# More information on profiles:  https://www.jhipster.tech/profiles/
# More information on configuration properties: https://www.jhipster.tech/common-application-properties/
#   ===================================================================

# ===================================================================
# Standard Spring Boot properties.
# Full reference is available at:
# http://docs.spring.io/spring-boot/docs/current/reference/html/common-application-properties.html
# ===================================================================

logging:
  level:
    ROOT: INFO
    tech.jhipster: INFO
    com.abc.myapp: INFO

management:
  metrics:
    export:
      prometheus:
        enabled: false

spring:
  devtools:
    restart:
      enabled: false
    livereload:
      enabled: false
  datasource:
    type: com.zaxxer.hikari.HikariDataSource
    url: jdbc:postgresql://localhost:5432/myapp
    username: myapp
    password:
    hikari:
      poolName: Hikari
      auto-commit: false
  jpa:
    database-platform: tech.jhipster.domain.util.FixedPostgreSQL10Dialect
  # Replace by 'prod, faker' to add the faker context and have sample data loaded in production
  liquibase:
    contexts: prod
  thymeleaf:
    cache: true
 security:
    oauth2:
      client:
        provider:
          oidc:
            issuer-uri: https://xyz.abc.com/
        registration:
          oidc:
            client-id: 78368cea7-17f90-439b-ac0f8-8a3296b300a50a
            client-secret: gto_ha769wcw4tafye7jrtljcmfe0vrk7k2r7yvaz38rpbkzo63o8s8tggn2pq
            scope: openid,profile,email,offline_access

# ===================================================================
# To enable TLS in production, generate a certificate using:
# keytool -genkey -alias myapp -storetype PKCS12 -keyalg RSA -keysize 2048 -keystore keystore.p12 -validity 3650
#
# You can also use Let's Encrypt:
# https://maximilian-boehm.com/hp2121/Create-a-Java-Keystore-JKS-from-Let-s-Encrypt-Certificates.htm
#
# Then, modify the server.ssl properties so your "server" configuration looks like:

server:
  port: 443
  SSL:
    key-store: classpath:/home/ec12-user/docker/wrwvw/webapp-docker
    key-store-password: sf8*#l9
    key-store-type: PKCS12
    key-alias: myapp
    # The ciphers suite enforce the security by deactivating some old and deprecated SSL cipher, this list was tested against SSL Labs (https://www.ssllabs.com/ssltest/)
    ciphers: TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 ,TLS_DHE_RSA_WITH_AES_128_GCM_SHA256 ,TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 ,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256,TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384,TLS_DHE_RSA_WITH_AES_128_CBC_SHA256,TLS_DHE_RSA_WITH_AES_128_CBC_SHA,TLS_DHE_RSA_WITH_AES_256_CBC_SHA256,TLS_DHE_RSA_WITH_AES_256_CBC_SHA,TLS_RSA_WITH_AES_128_GCM_SHA256,TLS_RSA_WITH_AES_256_GCM_SHA384,TLS_RSA_WITH_AES_128_CBC_SHA256,TLS_RSA_WITH_AES_256_CBC_SHA256,TLS_RSA_WITH_AES_128_CBC_SHA,TLS_RSA_WITH_AES_256_CBC_SHA,TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA,TLS_RSA_WITH_CAMELLIA_256_CBC_SHA,TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA,TLS_RSA_WITH_CAMELLIA_128_CBC_SHA
# ===================================================================
# server:
#  port: 8080
#  shutdown: graceful # see https://docs.spring.io/spring-boot/docs/current/reference/html/spring-boot-features.html#boot-features-graceful-shutdown
#  compression:
#    enabled: true
#    mime-types: text/html,text/xml,text/plain,text/css,application/javascript,application/json,image/svg+xml
# min-response-size: 1024

# ===================================================================
# JHipster specific properties
#
# Full reference is available at: https://www.jhipster.tech/common-application-properties/
# ===================================================================

jhipster:
  HTTP:
    cache: # Used by the CachingHttpHeadersFilter
      timeToLiveInDays: 1461
  cache: # Cache configuration
    ehcache: # Ehcache configuration
      time-to-live-seconds: 3600 # By default objects stay 1 hour in the cache
      max-entries: 1000 # Number of objects in each cache entry
  logging:
    use-json-format: false # By default, logs are not in Json format
    logstash: # Forward logs to logstash over a socket, used by LoggingConfiguration
      enabled: false
      host: localhost
      port: 5000
      queue-size: 512
# ===================================================================
# Application specific properties
# Add your own application properties here, see the ApplicationProperties class
# to have type-safe configuration, like in the JHipsterProperties above
#
# More documentation is available at:
# https://www.jhipster.tech/common-application-properties/
# ===================================================================

# application:

After commenting out and uncommenting some lines in a YML file, I can't get my project pushed to our Gitlab anymore due to those prettier errors. To be precise, the commented out block is the server 8080 and uncommented block is the server 443.

✖ prettier --write:
[error] src/main/resources/config/application-prod.yml: SyntaxError: All collection items must start at the same column (16:1)
[error]        14 | # ===================================================================
[error]        15 |
[error] >    16 | logging:
[error]              | ^^^^^^^^
[error] >    17 |      level:
[error]              | ^^^^^^^^
[error] >    18 |          ROOT: INFO
[error]              | ^^^^^^^^
[error] >    19 |          tech.jhipster: INFO
[error]              | ^^^^^^^^
[error] >    20 |          com.abc.myapp: INFO
[error]              | ^^^^^^^^
[error] >    21 |
[error]              | ^^^^^^^^
[error] >    22 | management:
[error]              | ^^^^^^^^
[error] >    23 |      metrics:
[error]              | ^^^^^^^^
[error] >    24 |          export:
[error]              | ^^^^^^^^
[error] >    25 |              prometheus:
[error]              | ^^^^^^^^
[error] >    26 |                  enabled: false
[error]              | ^^^^^^^^
...
[error] > 129 |
[error]              | ^
husky - pre-commit hook exited with code 1 (error)

The error message says

 All collection items must start at the same column (16:1)

I didn't change those lines at all. After making a comparison of the before and after editing versions of the same file in an IDE, I don't see any changes on those lines say line 16.

How to overcome this problem?

Here is the original file:

# ===================================================================
# Spring Boot configuration for the "prod" profile.
#
# This configuration overrides the application.yml file.
#
# More information on profiles:  https://www.jhipster.tech/profiles/
# More information on configuration properties: https://www.jhipster.tech/common-application-properties/
#   ===================================================================

# ===================================================================
# Standard Spring Boot properties.
# Full reference is available at:
# http://docs.spring.io/spring-boot/docs/current/reference/html/common-application-properties.html
# ===================================================================

logging:
  level:
    ROOT: INFO
    tech.jhipster: INFO
    com.abc.myapp: INFO

management:
  metrics:
    export:
      prometheus:
        enabled: false

spring:
  devtools:
    restart:
      enabled: false
    livereload:
      enabled: false
  datasource:
    type: com.zaxxer.hikari.HikariDataSource
    url: jdbc:postgresql://localhost:5432/myapp
    username: myapp
    password:
    hikari:
      poolName: Hikari
      auto-commit: false
  jpa:
    database-platform: tech.jhipster.domain.util.FixedPostgreSQL10Dialect
  # Replace by 'prod, faker' to add the faker context and have sample data loaded in production
  liquibase:
    contexts: prod
  thymeleaf:
    cache: true
 security:
    oauth2:
      client:
        provider:
          oidc:
            issuer-uri: https://xyz.abc.com/
        registration:
          oidc:
            client-id: 78368cea7-17f90-439b-ac0f8-8a3296b300a50a
            client-secret: gto_ha769wcw4tafye7jrtljcmfe0vrk7k2r7yvaz38rpbkzo63o8s8tggn2pq
            scope: openid,profile,email,offline_access

# ===================================================================
# To enable TLS in production, generate a certificate using:
# keytool -genkey -alias myapp -storetype PKCS12 -keyalg RSA -keysize 2048 -keystore keystore.p12 -validity 3650
#
# You can also use Let's Encrypt:
# https://maximilian-boehm.com/hp2121/Create-a-Java-Keystore-JKS-from-Let-s-Encrypt-Certificates.htm
#
# Then, modify the server.ssl properties so your "server" configuration looks like:

server:
  port: 443
  SSL:
    key-store: classpath:/home/ec12-user/docker/wrwvw/webapp-docker
    key-store-password: sf8*#l9
    key-store-type: PKCS12
    key-alias: myapp
    # The ciphers suite enforce the security by deactivating some old and deprecated SSL cipher, this list was tested against SSL Labs (https://www.ssllabs.com/ssltest/)
    ciphers: TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 ,TLS_DHE_RSA_WITH_AES_128_GCM_SHA256 ,TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 ,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256,TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384,TLS_DHE_RSA_WITH_AES_128_CBC_SHA256,TLS_DHE_RSA_WITH_AES_128_CBC_SHA,TLS_DHE_RSA_WITH_AES_256_CBC_SHA256,TLS_DHE_RSA_WITH_AES_256_CBC_SHA,TLS_RSA_WITH_AES_128_GCM_SHA256,TLS_RSA_WITH_AES_256_GCM_SHA384,TLS_RSA_WITH_AES_128_CBC_SHA256,TLS_RSA_WITH_AES_256_CBC_SHA256,TLS_RSA_WITH_AES_128_CBC_SHA,TLS_RSA_WITH_AES_256_CBC_SHA,TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA,TLS_RSA_WITH_CAMELLIA_256_CBC_SHA,TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA,TLS_RSA_WITH_CAMELLIA_128_CBC_SHA
# ===================================================================
# server:
#  port: 8080
#  shutdown: graceful # see https://docs.spring.io/spring-boot/docs/current/reference/html/spring-boot-features.html#boot-features-graceful-shutdown
#  compression:
#    enabled: true
#    mime-types: text/html,text/xml,text/plain,text/css,application/javascript,application/json,image/svg+xml
# min-response-size: 1024

# ===================================================================
# JHipster specific properties
#
# Full reference is available at: https://www.jhipster.tech/common-application-properties/
# ===================================================================

jhipster:
  HTTP:
    cache: # Used by the CachingHttpHeadersFilter
      timeToLiveInDays: 1461
  cache: # Cache configuration
    ehcache: # Ehcache configuration
      time-to-live-seconds: 3600 # By default objects stay 1 hour in the cache
      max-entries: 1000 # Number of objects in each cache entry
  logging:
    use-json-format: false # By default, logs are not in Json format
    logstash: # Forward logs to logstash over a socket, used by LoggingConfiguration
      enabled: false
      host: localhost
      port: 5000
      queue-size: 512
# ===================================================================
# Application specific properties
# Add your own application properties here, see the ApplicationProperties class
# to have type-safe configuration, like in the JHipsterProperties above
#
# More documentation is available at:
# https://www.jhipster.tech/common-application-properties/
# ===================================================================

# application:

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

你如我软肋 2025-01-20 07:21:36

pnpm-lock.yaml 添加到 .prettierignore 文件

add pnpm-lock.yaml to the .prettierignore file

唔猫 2025-01-20 07:21:35

在尝试进行 git 提交时,我遇到了与 husky 解析错误类似的问题。我按照此“解决”了它 answer 表示您需要添加--no-verify 标志:

git commit -m "message for the commit" --no-verify

免责声明: 这克服了更漂亮的错误但没有解决它。在超越代码之前,请务必检查您的代码是否正常工作并遵循相应的代码指南。成功完成此操作后,您将不需要再次使用 --no-verify ,除非您修改该文件。

I am having similar issues with parsing errors with husky when trying to do a git commit. I "solved" it following this answer which says that you need to add a --no-verify flag:

git commit -m "message for the commit" --no-verify

Disclaimer: this overcomes the prettier errors but does not solve it. Be sure to check that your code works properly and follows the respective code guidelines before overpassing it. After you succesfully have done that, you will not need to use the --no-verify again unless you modify that file.

不语却知心 2025-01-20 07:21:35

在我看来,勾选的答案并不是很好的建议。 --no-verify 将绕过所有预提交检查。如果您遇到不应在预提交时解析的文件的问题,则需要修改解析器的忽略文件。

在这种情况下,它将添加或修改 .prettierignore 文件。

https://prettier.io/docs/en/ignore.html

或者如果您需要忽略一系列代码,然后适当地注释以允许忽略该范围:

https://prettier.io/docs/en/ignore.html#range-ignore

https://prettier.io/docs/en/ignore.html#yaml

如果在这种情况下您的代码由于样式问题而无法工作,请考虑运行 prettier write控制台中的

https://prettier.io/docs/en/cli.html

The checkmarked answer is not great advice, in my opinion. --no-verify will bypass all pre-commit checks. If you're having issues with files that shouldn't be parsed on a pre-commit you need to modify the ignore file of your parser.

In this case it would be adding or modifying the .prettierignore file.

https://prettier.io/docs/en/ignore.html

Or if you need to ignore a range of code then comment appropriately to allow that range to be ignored:

https://prettier.io/docs/en/ignore.html#range-ignore

https://prettier.io/docs/en/ignore.html#yaml

If this is a situation where your code is not working due to a styling issue consider running prettier write <FILE> in your console.

https://prettier.io/docs/en/cli.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文