wearerequired / lint-action

✨ GitHub Action for detecting and auto-fixing lint errors
MIT License
571 stars 138 forks source link

Error parsing ESLint JSON output: Unexpected end of JSON input. Output: "" #185

Closed kosiakMD closed 3 years ago

kosiakMD commented 3 years ago

I tried to omit "custom" json files, but no

config

name: Lint
on: push

jobs:
  run-linters:
    name: Run linters
    runs-on: ubuntu-latest

    steps:
      - name: Check out Git repository
        uses: actions/checkout@v2

      - name: Check out Git branch name
        run: |
          chmod=+x .github/scripts/check_branch_naming.sh
          .github/scripts/check_branch_naming.sh
      - name: Set up Node.js
        uses: actions/setup-node@v1
        with:
          node-version: 14

      # ESLint and Prettier must be in `package.json`
      - name: Install Node.js dependencies
        run: npm ci

      - name: Run linters
        uses: wearerequired/lint-action@v1
        with:
          eslint: true
          prettier: true
          eslint_args: "--config .eslintrc.js"

Extended Error Description:

Run wearerequired/lint-action@v1
  with:
    eslint: true
    prettier: true
    eslint_args: --config .eslintrc.js
    github_token: ***
    continue_on_error: true
    auto_fix: false
    git_name: Lint Action
    git_email: lint-action@samuelmeuli.com
    commit_message: Fix code style issues with ${linter}
    check_name: ${linter}
    stylelint: false
    stylelint_extensions: css,sass,scss
    gofmt: false
    gofmt_extensions: go
    golint: false
    golint_extensions: go
    eslint_extensions: js
    prettier_extensions: css,html,js,json,jsx,md,sass,scss,ts,tsx,vue,yaml,yml
    xo: false
    xo_extensions: js
    php_codesniffer: false
    php_codesniffer_extensions: php
    black: false
    black_extensions: py
    flake8: false
    flake8_extensions: py
    mypy: false
    mypy_extensions: py
    rubocop: false
    rubocop_extensions: rb
    swiftformat: false
    swiftformat_extensions: swift
    swift_format_lockwood: false
    swift_format_lockwood_extensions: swift
    swift_format_official: false
    swift_format_official_extensions: swift
    swiftlint: false
    swiftlint_extensions: swift
SHA of last commit is "88543d18f758dbaaf0394cbfd2b7ee16264f273c"
Run ESLint
  Verifying setup for ESLint…
  Verified ESLint setup
  Will use ESLint to check the files with extensions js
  Linting files in /home/runner/work/***/*** with ESLint…

  Oops! Something went wrong! :(

  ESLint: 7.22.0

  You are linting ".", but all of the files matching the glob pattern "." are ignored.

  If you don't want to lint these files, remove the pattern "." from the list of arguments passed to ESLint.

  If you do want to lint these files, try the following solutions:

  * Check your .eslintignore file, or the eslintIgnore property in package.json, to ensure that the files are not configured to be ignored.
  * Explicitly list the files from this glob that you'd like to lint on the command-line, rather than providing a glob as an argument.

  Error: Error parsing ESLint JSON output: Unexpected end of JSON input. Output: ""
ocean90 commented 3 years ago

Hey there, the error is this one:

You are linting ".", but all of the files matching the glob pattern "." are ignored.

Please verify that your ignore rules are correct.

kosiakMD commented 3 years ago

@ocean90 I assumed that config should clarify that --config .eslintrc.js .eslintrc.js:

module.exports = {
    parser: '@typescript-eslint/parser',
    parserOptions: {
        project: 'tsconfig.json',
        sourceType: 'module',
        // Only ESLint 6.2.0 and later support ES2020.
        ecmaVersion: 2020,
    },
    env: {
        es6: true,
        node: true,
        jest: true,
    },
    plugins: ['@typescript-eslint/eslint-plugin', 'prettier'],
    extends: [
        'eslint:recommended',
        'plugin:@typescript-eslint/recommended',
        'plugin:node/recommended-module',
        'plugin:prettier/recommended',
    ],
    root: true,
    ignorePatterns: ['.eslintrc.js', '**/*.js', 'nest-cli.json'],
    rules: {
        quotes: [
            'error',
            'single',
            {
                allowTemplateLiterals: true,
                avoidEscape: true,
            },
        ],
        indent: ['error', 'tab'],
        //
        '@typescript-eslint/interface-name-prefix': 'off',
        '@typescript-eslint/explicit-function-return-type': 'warn',
        '@typescript-eslint/explicit-module-boundary-types': 'off',
        '@typescript-eslint/no-explicit-any': 'off',
        '@typescript-eslint/no-unused-vars': 'error',
        'prettier/prettier': 'error',
        'max-classes-per-file': ['error', 1],
        'no-use-before-define': 'warn',
        'no-console': 'error',
        // node
        'node/exports-style': ['error', 'exports'],
        'node/file-extension-in-import': 'off',
        'node/prefer-global/buffer': ['error', 'always'],
        'node/prefer-global/console': ['error', 'always'],
        'node/prefer-global/process': ['error', 'always'],
        'node/prefer-global/url-search-params': ['error', 'always'],
        'node/prefer-global/url': ['error', 'always'],
        'node/prefer-promises/dns': 'error',
        'node/prefer-promises/fs': 'error',
        'node/no-unsupported-features/es-syntax': 'off',
        'node/no-missing-import': 'off',
        'node/no-unpublished-import': 'off',
        'node/no-extraneous-import': 'off',
        // jest
        // 'jest/no-disabled-tests': 'warn',
        // 'jest/no-focused-tests': 'warn',
        // 'jest/no-identical-title': 'error',
        // 'jest/prefer-to-have-length': 'warn',
        // 'jest/valid-expect': 'off',
    },
};

.eslintignore

.git
.github
.husky
dist
ocean90 commented 3 years ago

So you only want to lint *.ts files? In that case you have to set eslint_extensions: ts in your workflow.

kosiakMD commented 3 years ago

@ocean90 oh, got it, thanks! Does this action support a config file at all?

ocean90 commented 3 years ago

It does, but for the list of extensions you have to use the --ext CLI argument which by default only includes .js, see https://eslint.org/docs/user-guide/command-line-interface#options.

kosiakMD commented 3 years ago

@ocean90 I added eslint_extensions : ts and tried with and without --conig .eslintrc.js but Prettier and seems ESLint too doesn't see my config files and make checks of ignored files and with other rules that I wrote

github-actions[bot] commented 3 years ago

A stale label has been added to this issue because it has been open 15 days with no activity. To keep this issue open, add a comment within 5 days.