tslint.yaml anchor expand treated as rule

Created on 7 Apr 2018  Â·  5Comments  Â·  Source: palantir/tslint

Bug Report

I'm trying to leverage yaml anchors for common settings in between ts and js lint rules, and encounter following error:

zzzz[~/../../../zzzz/client/ (develop *% u=)]$ yarn lint_tsjs
yarn run v1.5.1
$ tslint -c tslint.yml "!(node_modules)/**/*.js?(x)"

Could not find implementations for the following rules specified in the configuration:
    <<
Try upgrading TSLint and/or ensuring that you have all necessary custom rules installed.
If TSLint was recently upgraded, you may have old rules configured which need to be cleaned up.

I tested [email protected] and it will expand tslint.yaml into json as expected with default settings.

with tslint.yaml configuration:

defaultSeverity: error
linterOptions:
  exclude:
    - "coverage/**/*"
    - "dist/**/*"
    - "config/utils/**/*.js"
    - "src/common/components/forms/**/*.js"
    - "**/mockData.js"
    - "**/reactCountDownTimer/**/*.js"
extends:
  - tslint:recommended
  - tslint-react
rules: &TS_RULES
  semicolon:
    - true
    - never
  quotemark:
    - true
    - single
    - jsx-double
  indent:
    - true
    - spaces
    - 2
  ordered-imports: false
  interface-name: false
  member-access: false
  object-literal-sort-keys: false
  trailing-comma: false
  space-before-function-paren: true
  arrow-parens: false
  jsx-no-lambda: true
jsRules:
  # common rules with ts
  <<: *TS_RULES
  # semicolon:
  #   - true
  #   - never
  # quotemark:
  #   - true
  #   - single
  #   - jsx-double
  # indent:
  #   - true
  #   - spaces
  #   - 2
  # ordered-imports: false
  # interface-name: false
  # member-access: false
  # object-literal-sort-keys: false
  # trailing-comma: false
  # space-before-function-paren: true
  # arrow-parens: false
  # jsx-no-lambda: true
  # specific rules for js
  jsdoc-format: false
  curly:
    - true
    - ignore-same-line
  max-line-length:
    - true
    - 180
rulesDirectory: []

Actual behavior

zzzz[~/../../../zzzz/client/ (develop *% u=)]$ yarn lint_tsjs
yarn run v1.5.1
$ tslint -c tslint.yml "!(node_modules)/**/*.js?(x)"

Could not find implementations for the following rules specified in the configuration:
    <<
Try upgrading TSLint and/or ensuring that you have all necessary custom rules installed.
If TSLint was recently upgraded, you may have old rules configured which need to be cleaned up.

Expected behavior

anchor expended to the actual rules

Thank you

Needs Investigation Bug

Most helpful comment

As far as I can tell, there shouldn't be any harm in using the default schema for js-yaml, it just adds support for some extra YAML types. Here is a codepen showcasing everything it adds over the JSON schema: https://codepen.io/anon/pen/rQXdbm?editors=0012

I just made a pull request which makes the change. I've been using it locally and haven't had any issues.

Also, in regards to @JoshuaKGoldberg's question about Cosmiconfig above, it should also fix this, as Cosmiconfig uses js-yaml's default schema, so it would support this.

All 5 comments

Apparently this design question of schema selection, not sure how safe/unsafe would be to change it. Can confirm changing it to DEFAULT_FULL_SCHEMA would make anchor to expand.

Or even DEFAULT_SAFE_SCHEMA would work.

@dmi3y would #1071: Cosmiconfig support fix this?

As far as I can tell, there shouldn't be any harm in using the default schema for js-yaml, it just adds support for some extra YAML types. Here is a codepen showcasing everything it adds over the JSON schema: https://codepen.io/anon/pen/rQXdbm?editors=0012

I just made a pull request which makes the change. I've been using it locally and haven't had any issues.

Also, in regards to @JoshuaKGoldberg's question about Cosmiconfig above, it should also fix this, as Cosmiconfig uses js-yaml's default schema, so it would support this.

Great! Thanks guys.

Fixed by #4350 ✨

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mrand01 picture mrand01  Â·  3Comments

DanielKucal picture DanielKucal  Â·  3Comments

ghost picture ghost  Â·  3Comments

ypresto picture ypresto  Â·  3Comments

Ne-Ne picture Ne-Ne  Â·  3Comments