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

How to overcome those prettier errors?

在注释掉和取消注释 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:

我在尝试执行 git 提交时遇到了与 husky 解析错误类似的问题。我在这个 answer 之后“解决”了它,它说你需要添加一个 --no-verify 标志:

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

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