betterer icon indicating copy to clipboard operation
betterer copied to clipboard

Error: Unexpected token N in JSON at position

Open davidbarratt opened this issue 2 years ago • 1 comments
trafficstars

Describe the bug When I use the eslint plugin, I get this error on the second run of betterer To Reproduce

Here is my .eslint.json file:

{
  "extends": [
    "plugin:@next/next/core-web-vitals",
    "plugin:jsx-a11y/recommended",
    "plugin:react/recommended",
    "plugin:react-hooks/recommended",
    "plugin:jest/recommended",
    "plugin:@typescript-eslint/recommended",
    "plugin:@typescript-eslint/recommended-requiring-type-checking",
    "plugin:@typescript-eslint/strict",
    "plugin:import/recommended",
    "plugin:import/typescript",
    "prettier"
  ],
  "plugins": ["jest"],
  "parserOptions": {
    "project": ["./tsconfig.json"]
  },
  "settings": {
    "import/resolver": {
      "typescript": true,
      "node": true
    },
    "react": {
      "version": "detect"
    }
  },
  "rules": {
    "@typescript-eslint/await-thenable": ["warn"],
    "@typescript-eslint/ban-ts-comment": ["warn"],
    "@typescript-eslint/ban-types": ["warn"],
    "@typescript-eslint/consistent-type-assertions": [
      "warn",
      {
        "assertionStyle": "never"
      }
    ],
    "@typescript-eslint/no-empty-function": ["warn"],
    "@typescript-eslint/no-floating-promises": ["warn"],
    "@typescript-eslint/no-for-in-array": ["warn"],
    "@typescript-eslint/no-implied-eval": ["warn"],
    "@typescript-eslint/no-misused-promises": ["warn"],
    "@typescript-eslint/no-unnecessary-type-assertion": ["warn"],
    "@typescript-eslint/no-unsafe-argument": ["warn"],
    "@typescript-eslint/no-unsafe-assignment": ["warn"],
    "@typescript-eslint/no-unsafe-call": ["warn"],
    "@typescript-eslint/no-unsafe-member-access": ["warn"],
    "@typescript-eslint/no-unsafe-return": ["warn"],
    "@typescript-eslint/no-var-requires": ["warn"],
    "@typescript-eslint/require-await": ["warn"],
    "@typescript-eslint/restrict-plus-operands": ["warn"],
    "@typescript-eslint/restrict-template-expressions": ["warn"],
    "@typescript-eslint/unbound-method": ["warn"],
    "@next/next/no-html-link-for-pages": ["warn"],
    "import/export": ["warn"],
    "import/no-cycle": ["error"],
    "import/namespace": ["warn"],
    "import/no-unresolved": ["warn"],
    "jest/no-alias-methods": ["warn"],
    "jest/no-conditional-expect": ["warn"],
    "jest/no-done-callback": ["warn"],
    "jest/no-focused-tests": ["warn"],
    "jest/no-identical-title": ["warn"],
    "jest/no-standalone-expect": ["warn"],
    "jest/valid-expect": ["warn"],
    "jest/valid-expect-in-promise": ["warn"],
    "jest/valid-title": ["warn"],
    "jsx-a11y/alt-text": ["warn"],
    "jsx-a11y/anchor-is-valid": ["warn"],
    "jsx-a11y/click-events-have-key-events": ["warn"],
    "jsx-a11y/html-has-lang": ["warn"],
    "jsx-a11y/iframe-has-title": ["warn"],
    "jsx-a11y/img-redundant-alt": ["warn"],
    "jsx-a11y/no-autofocus": ["warn"],
    "jsx-a11y/no-noninteractive-element-interactions": ["warn"],
    "jsx-a11y/no-noninteractive-tabindex": ["warn"],
    "jsx-a11y/no-static-element-interactions": ["warn"],
    "react/jsx-key": ["warn"],
    "react/no-unknown-property": ["warn"],
    "react/prop-types": ["warn"],
    "react/jsx-uses-react": "off",
    "react/react-in-jsx-scope": "off"
  },
  "overrides": [
    {
      "files": [
        "**/__tests__/**/*.[jt]s?(x)",
        "**/__mocks__/**/*.[jt]s?(x)",
        "**/?(*.)+(spec|test).[jt]s?(x)",
        "app/javascript/test/**"
      ],
      "rules": {
        "@typescript-eslint/consistent-type-assertions": [
          "error",
          { "assertionStyle": "as" }
        ]
      }
    }
  ]
}

When I run yarn betterer the first time, everything works perfectly, whenever I do it the second time, I get an error like this:

Error: Unexpected token N in JSON at position 67
      at JSON.parse (<anonymous>)
      at Function.create (node_modules/@betterer/betterer/src/run/run.ts:43:65)
      at async node_modules/@betterer/betterer/src/context/context.ts:90:18
      at async Promise.all (index 0)
      at async BettererContextΩ.run (node_modules/@betterer/betterer/src/context/context.ts:88:20)
      at async BettererContextΩ.runOnce (node_modules/@betterer/betterer/src/context/context.ts:111:7)
      at async betterer (node_modules/@betterer/betterer/src/betterer.ts:31:10)
      at async Command.<anonymous> (node_modules/@betterer/cli/src/start.ts:38:28)
      at async Command.parseAsync (node_modules/@betterer/cli/node_modules/commander/lib/command.js:923:5)
      at async Object.cli__ (node_modules/@betterer/cli/src/cli.ts:58:3)

Expected behavior Not throw an error on the second run

Screenshots N/A

Versions (please complete the following information):

  • OS: macOS
  • Betterer Version: v5.4.0
  • Node Version: v16.19.0

Additional context

davidbarratt avatar Mar 13 '23 16:03 davidbarratt

Thanks very much, I’ve seen this in the wild but never had a good repro, I’ll see where this takes me!

phenomnomnominal avatar Mar 13 '23 23:03 phenomnomnominal