standard / ts-standard

Typescript style guide, linter, and formatter using StandardJS
https://www.npmjs.com/package/ts-standard
MIT License
473 stars 36 forks source link

ts-standard: Unexpected linter output #209

Closed Kikobeats closed 2 years ago

Kikobeats commented 2 years ago

Hello,

I just installed ts-standard and try to run it. The first thing the CLI told me is

$ npx ts-standard
Unable to locate the project file. A project file (tsconfig.json or tsconfig.eslint.json) is required in order to use ts-standard

and that's right. So I add a little tsconfig.json configuration, like:

{
  "compilerOptions": {
    "esModuleInterop": true,
    "forceConsistentCasingInFileNames": true,
    "noFallthroughCasesInSwitch": true,
    "skipLibCheck": true,
    "strict": true,
    "target": "ES2019"
  },
  "include": ["src/"]
}

Now, I try to run the command again, and a weird error is reported:

 npx ts-standard
ts-standard: Unexpected linter output:

--config » eslint-config-standard-with-typescript#overrides[0]:
    Configuration for rule "@typescript-eslint/indent" is invalid:
    Value {"SwitchCase":1,"VariableDeclarator":1,"outerIIFEBody":1,"MemberExpression":1,"FunctionDeclaration":{"parameters":1,"body":1},"FunctionExpression":{"parameters":1,"body":1},"CallExpression":{"arguments":1},"ArrayExpression":1,"ObjectExpression":1,"ImportDeclaration":1,"flatTernaryExpressions":false,"ignoreComments":false,"ignoredNodes":["TemplateLiteral *","JSXElement","JSXElement > *","JSXAttribute","JSXIdentifier","JSXNamespacedName","JSXMemberExpression","JSXSpreadAttribute","JSXExpressionContainer","JSXOpeningElement","JSXClosingElement","JSXFragment","JSXOpeningFragment","JSXClosingFragment","JSXText","JSXEmptyExpression","JSXSpreadChild"],"offsetTernaryExpressions":true} should NOT have additional properties.
: Error: --config » eslint-config-standard-with-typescript#overrides[0]:
    Configuration for rule "@typescript-eslint/indent" is invalid:
    Value {"SwitchCase":1,"VariableDeclarator":1,"outerIIFEBody":1,"MemberExpression":1,"FunctionDeclaration":{"parameters":1,"body":1},"FunctionExpression":{"parameters":1,"body":1},"CallExpression":{"arguments":1},"ArrayExpression":1,"ObjectExpression":1,"ImportDeclaration":1,"flatTernaryExpressions":false,"ignoreComments":false,"ignoredNodes":["TemplateLiteral *","JSXElement","JSXElement > *","JSXAttribute","JSXIdentifier","JSXNamespacedName","JSXMemberExpression","JSXSpreadAttribute","JSXExpressionContainer","JSXOpeningElement","JSXClosingElement","JSXFragment","JSXOpeningFragment","JSXClosingFragment","JSXText","JSXEmptyExpression","JSXSpreadChild"],"offsetTernaryExpressions":true} should NOT have additional properties.

    at ConfigValidator.validateRuleOptions (/Users/kikobeats/vercel/edge-runtime/node_modules/@eslint/eslintrc/lib/shared/config-validator.js:144:23)
    at /Users/kikobeats/vercel/edge-runtime/node_modules/@eslint/eslintrc/lib/shared/config-validator.js:199:18
    at Array.forEach (<anonymous>)
    at ConfigValidator.validateRules (/Users/kikobeats/vercel/edge-runtime/node_modules/@eslint/eslintrc/lib/shared/config-validator.js:196:34)
    at ConfigValidator.validateConfigArray (/Users/kikobeats/vercel/edge-runtime/node_modules/@eslint/eslintrc/lib/shared/config-validator.js:322:18)
    at CascadingConfigArrayFactory._finalizeConfigArray (/Users/kikobeats/vercel/edge-runtime/node_modules/@eslint/eslintrc/lib/cascading-config-array-factory.js:493:23)
    at CascadingConfigArrayFactory.getConfigArrayForFile (/Users/kikobeats/vercel/edge-runtime/node_modules/@eslint/eslintrc/lib/cascading-config-array-factory.js:299:21)
    at FileEnumerator._iterateFilesRecursive (/Users/kikobeats/vercel/edge-runtime/node_modules/ts-standard/node_modules/eslint/lib/cli-engine/file-enumerator.js:445:49)
    at _iterateFilesRecursive.next (<anonymous>)
    at FileEnumerator.iterateFiles (/Users/kikobeats/vercel/edge-runtime/node_modules/ts-standard/node_modules/eslint/lib/cli-engine/file-enumerator.js:296:49)

If you think this is a bug in `ts-standard`, open an issue: https://github.com/standard/ts-standard/issues

I understand ts-standard mess with some rules merging, but not sure why. I tried other tsconfig.json settings but all the time I get this error.

Environment

npx envinfo --binaries --system

  System:
    OS: macOS 12.0.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 5.12 GB / 32.00 GB
    Shell: 3.3.1 - /opt/homebrew/bin/fish
  Binaries:
    Node: 16.13.1 - ~/.local/share/nvm/v16.13.1/bin/node
    Yarn: 1.22.17 - /opt/homebrew/bin/yarn
    npm: 8.1.2 - ~/.local/share/nvm/v16.13.1/bin/npm
Jytesh commented 2 years ago

Getting the same issue in https://github.com/microlinkhq/keyv/runs/4864500237?check_suite_focus=true But this issue is not reproduced in my machine ( I am using pnpm if that matters, npm in CI ) ts-standard works as intended in my machine with pnpm

Jytesh commented 2 years ago

Error from CI:

Run npm test

> @keyvhq/monorepo@ pretest /home/runner/work/keyv/keyv
> npm run lint

> @keyvhq/monorepo@ lint /home/runner/work/keyv/keyv
> ts-standard

ts-standard: Unexpected linter output:

--config » eslint-config-standard-with-typescript#overrides[0]:
    Configuration for rule "@typescript-eslint/indent" is invalid:
    Value {"SwitchCase":1,"VariableDeclarator":1,"outerIIFEBody":1,"MemberExpression":1,"FunctionDeclaration":{"parameters":1,"body":1},"FunctionExpression":{"parameters":1,"body":1},"CallExpression":{"arguments":1},"ArrayExpression":1,"ObjectExpression":1,"ImportDeclaration":1,"flatTernaryExpressions":false,"ignoreComments":false,"ignoredNodes":["TemplateLiteral *","JSXElement","JSXElement > *","JSXAttribute","JSXIdentifier","JSXNamespacedName","JSXMemberExpression","JSXSpreadAttribute","JSXExpressionContainer","JSXOpeningElement","JSXClosingElement","JSXFragment","JSXOpeningFragment","JSXClosingFragment","JSXText","JSXEmptyExpression","JSXSpreadChild"],"offsetTernaryExpressions":true} should NOT have additional properties.
: Error: --config » eslint-config-standard-with-typescript#overrides[0]:
    Configuration for rule "@typescript-eslint/indent" is invalid:
    Value {"SwitchCase":1,"VariableDeclarator":1,"outerIIFEBody":1,"MemberExpression":1,"FunctionDeclaration":{"parameters":1,"body":1},"FunctionExpression":{"parameters":1,"body":1},"CallExpression":{"arguments":1},"ArrayExpression":1,"ObjectExpression":1,"ImportDeclaration":1,"flatTernaryExpressions":false,"ignoreComments":false,"ignoredNodes":["TemplateLiteral *","JSXElement","JSXElement > *","JSXAttribute","JSXIdentifier","JSXNamespacedName","JSXMemberExpression","JSXSpreadAttribute","JSXExpressionContainer","JSXOpeningElement","JSXClosingElement","JSXFragment","JSXOpeningFragment","JSXClosingFragment","JSXText","JSXEmptyExpression","JSXSpreadChild"],"offsetTernaryExpressions":true} should NOT have additional properties.

    at ConfigValidator.validateRuleOptions (/home/runner/work/keyv/keyv/node_modules/@eslint/eslintrc/lib/shared/config-validator.js:144:23)
    at /home/runner/work/keyv/keyv/node_modules/@eslint/eslintrc/lib/shared/config-validator.js:199:18
    at Array.forEach (<anonymous>)
    at ConfigValidator.validateRules (/home/runner/work/keyv/keyv/node_modules/@eslint/eslintrc/lib/shared/config-validator.js:196:34)
    at ConfigValidator.validateConfigArray (/home/runner/work/keyv/keyv/node_modules/@eslint/eslintrc/lib/shared/config-validator.js:322:18)
    at CascadingConfigArrayFactory._finalizeConfigArray (/home/runner/work/keyv/keyv/node_modules/@eslint/eslintrc/lib/cascading-config-array-factory.js:493:23)
    at CascadingConfigArrayFactory.getConfigArrayForFile (/home/runner/work/keyv/keyv/node_modules/@eslint/eslintrc/lib/cascading-config-array-factory.js:299:21)
    at FileEnumerator._iterateFilesRecursive (/home/runner/work/keyv/keyv/node_modules/ts-standard/node_modules/eslint/lib/cli-engine/file-enumerator.js:445:49)
    at _iterateFilesRecursive.next (<anonymous>)
    at FileEnumerator.iterateFiles (/home/runner/work/keyv/keyv/node_modules/ts-standard/node_modules/eslint/lib/cli-engine/file-enumerator.js:296:49)

If you think this is a bug in `ts-standard`, open an issue: https://github.com/standard/ts-standard/issues
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @keyvhq/monorepo@ lint: `ts-standard`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the @keyvhq/monorepo@ lint script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/runner/.npm/_logs/2022-01-19T07_52_42_416Z-debug.log
npm ERR! Test failed.  See above for more details.

In my machine:

> @keyvhq/monorepo@ lint keyv
> ts-standard

ts-standard: Typescript Standard Style! (https://github.com/standard/ts-standard)
ts-standard: Run `ts-standard --fix` to automatically fix some problems.
  /keyv/packages/core/src/index.js:69:1: Expected indentation of 8 spaces but found 10. (indent)
  /keyv/packages/core/src/index.js:70:1: Expected indentation of 8 spaces but found 10. (indent)
  /keyv/packages/core/src/index.js:71:1: Expected indentation of 8 spaces but found 10. (indent)
  /keyv/packages/sql/src/index.js:73:1: Expected indentation of 10 spaces but found 12. (indent)
  /keyv/packages/sql/src/index.js:74:1: Expected indentation of 10 spaces but found 12. (indent)
  /keyv/packages/sql/src/index.js:75:1: Expected indentation of 10 spaces but found 12. (indent)