{"size": 1016, "ext": "js", "max_stars_repo_path": "packages/eslint-config-sea/__tests__/react/hook.test.js", "max_stars_repo_name": "MrSeaWave/lint-config", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "packages/eslint-config-sea/__tests__/react/hook.test.js", "max_issues_repo_name": "MrSeaWave/lint-config", "max_issues_repo_issues_event_min_datetime": "2021-12-09T02:41:52.000Z", "max_issues_repo_issues_event_max_datetime": "2021-12-14T03:26:27.000Z", "max_forks_repo_path": "packages/eslint-config-sea/__tests__/react/hook.test.js", "max_forks_repo_name": "MrSeaWave/lint-config", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": 6, "max_forks_count": null, "avg_line_length": 29.0285714286, "max_line_length": 82, "alphanum_fraction": 0.6594488189}
const path = require('path');
const { ESLint } = require('eslint');
const baseConfig = require('./hook.eslintrc');

describe('eslint-config-sea react-hook', () => {
  it('rules snapshot', async () => {
    // 创建一个实例。
    const eslint = new ESLint({ cwd: __dirname, baseConfig, useEslintrc: false });
    // 计算给定文件的config配置
    const result = await eslint.calculateConfigForFile(__filename);

    delete result.parser;

    delete result.parserOptions.babelOptions;
    // 比对快照文件，第一次会生成snap,jest --updateSnapshot 可以重新生成快照文件
    expect(result).toMatchSnapshot();
  });

  it('lint react hook files', async () => {
    // 创建一个实例。
    const eslint = new ESLint({ cwd: __dirname, baseConfig, useEslintrc: false });
    // Lint 文件
    const results = await eslint.lintFiles(['./hook.jsx']);

    // 格式化结果。
    const formatter = await eslint.loadFormatter('stylish');
    const resultText = formatter.format(results);

    //  输出到控制台。
    console.log(resultText);

    expect(results[0].errorCount).toBeTruthy();
  });
});
