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

chore: add eslint-remote-tester #335

Merged
merged 4 commits into from
Jan 9, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@ node_modules/
npm-debug.log
yarn.lock
.eslintcache

# eslint-remote-tester
.cache-eslint-remote-tester
bmish marked this conversation as resolved.
Show resolved Hide resolved
eslint-remote-tester-results
52 changes: 52 additions & 0 deletions eslint-remote-tester.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
'use strict';

const { getPathIgnorePattern } = require('eslint-remote-tester-repositories');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As repositories list is a custom one and not coming from eslint-remote-tester-repositories, I think this one could be removed. And the dependency itself.

Suggested change
const { getPathIgnorePattern } = require('eslint-remote-tester-repositories');

The default value of pathIgnorePattern is fine here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we use the repositories from eslint-remote-tester-repositories instead?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently it seems that this setup runs tests against a small set of ESLint plugin repositories, as part of CI. This approach is good, and I think eslint-plugin-unicorn has similar setup. They also use a second smoke test workflow for a ~5 hour test run against randomly picked ~10k repositories.

So which ever approach is ok. Do you want to run these tests quickly for every CI run, or schedule them to run once a week for large set of repositories. Or both?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for explaining both approaches.

I figured we could start by running against a set of ESLint plugins, since those repos are of course more relevant and likely to trigger our rules than any other random repository. The current set is small so it's quick to run during CI.

If there was a desire to run on a very large set of repos but less frequently, I'm fine with that too.


module.exports = {
bmish marked this conversation as resolved.
Show resolved Hide resolved
/** Repositories to scan */
repositories: [
// A few dozen top ESLint plugins.
'Intellicode/eslint-plugin-react-native',
'JoshuaKGoldberg/eslint-plugin-expect-type',
'SonarSource/eslint-plugin-sonarjs',
'avajs/eslint-plugin-ava',
'cypress-io/eslint-plugin-cypress',
'dangreenisrael/eslint-plugin-jest-formatting',
'ember-cli/eslint-plugin-ember',
'emberjs/eslint-plugin-ember-internal',
'eslint-community/eslint-plugin-eslint-plugin',
'eslint-community/eslint-plugin-n',
'eslint-community/eslint-plugin-promise',
'eslint-community/eslint-plugin-security',
'eslint-functional/eslint-plugin-functional',
'eslint/eslint',
'import-js/eslint-plugin-import',
'jest-community/eslint-plugin-jest',
'jest-community/eslint-plugin-jest-extended',
'jsx-eslint/eslint-plugin-jsx-a11y',
'jsx-eslint/eslint-plugin-react',
'lo1tuma/eslint-plugin-mocha',
'ota-meshi/eslint-plugin-regexp',
'platinumazure/eslint-plugin-qunit',
'sindresorhus/eslint-plugin-unicorn',
'square/eslint-plugin-square',
'storybookjs/eslint-plugin-storybook',
'testing-library/eslint-plugin-jest-dom',
'testing-library/eslint-plugin-testing-library',
'typescript-eslint/typescript-eslint',
],

/** Optional pattern used to exclude paths */
pathIgnorePattern: getPathIgnorePattern(),
bmish marked this conversation as resolved.
Show resolved Hide resolved

/** Extensions of files under scanning */
extensions: ['js', 'ts'],

/** Optional boolean flag used to enable caching of cloned repositories. For CIs it's ideal to disable caching. Defaults to true. */
cache: false,
Copy link
Member Author

@bmish bmish Jan 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AriPerkkio I was a bit confused by this cache option. I saw some other repos disabling it. Can I just let it use the default? Or why is the default value not sufficient?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This flag controls whether a cloned repository should be removed from file system after it was linted. The default value true is ideal for local development, where developer may have 100s of repositories cached in file system, and they keep linting against them after modifying rule implementation frequently. Cloning repositories is slow, so caching them makes testing fast. Default values of this tool are good for local development, so some changes may be required when targeting CIs.

In this case, as there are not that many repositories listed, it might be OK to leave this as true. Github CIs have 15-20GB file systems on free tier. When linting ~10K repositories, the caching must be disabled so that we don't run out of disk space after couple of hours.


/** ESLint configuration */
eslintrc: {
bmish marked this conversation as resolved.
Show resolved Hide resolved
extends: ['plugin:eslint-plugin/all'],
},
};
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"lint:js": "eslint --cache --ignore-pattern \"**/*.md\" .",
"lint:js-docs": "eslint --no-inline-config \"**/*.md\"",
"lint:package-json": "npmPkgJsonLint .",
"lint:remote": "eslint-remote-tester",
"release": "release-it",
"test": "nyc --all --check-coverage --include lib mocha tests --recursive",
"update:eslint-docs": "eslint-doc-generator"
Expand Down Expand Up @@ -63,6 +64,8 @@
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-unicorn": "^44.0.0",
"eslint-remote-tester": "^3.0.0",
"eslint-remote-tester-repositories": "^1.0.0",
bmish marked this conversation as resolved.
Show resolved Hide resolved
"eslint-scope": "^7.1.1",
"espree": "^9.4.0",
"husky": "^8.0.1",
Expand Down