Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Unexpected token N in JSON at position #1130

Open
davidbarratt opened this issue Mar 13, 2023 · 1 comment
Open

Error: Unexpected token N in JSON at position #1130

davidbarratt opened this issue Mar 13, 2023 · 1 comment

Comments

@davidbarratt
Copy link

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

@phenomnomnominal
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants