Skip to content

Commit

Permalink
Merge branch 'master' into add/rna-components
Browse files Browse the repository at this point in the history
  • Loading branch information
sergeymitr authored Jun 24, 2021
2 parents eadf9f9 + a6da953 commit 51c7fc2
Show file tree
Hide file tree
Showing 53 changed files with 2,201 additions and 58 deletions.
35 changes: 35 additions & 0 deletions .github/ISSUE_TEMPLATE/plugin_jetpack-backup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
name: Plugin - Jetpack Backup
about: Create an issue report focused on the Jetpack Backup plugin
title: 'Backup [Plugin]: ADD_YOUR_TITLE_HERE'
labels: '[Plugin] Backup'
assignees: ''

---

<!-- Thanks for contributing!
Pick a clear title (e.g. "Backup: backups failing with latest update") and proceed. -->

#### Steps to reproduce the issue

1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See issue '....'

#### What I expected
<!-- A clear and concise description of what you expected to happen. -->

#### What happened instead


#### Screenshots
<!-- If applicable, add screenshots to help explain the issue. -->

<!--
PLEASE NOTE
- Everything is optional, but try to add as many details as possible.
- If requesting a new feature, explain why you'd like to see it added.
- This issue tracker is not for support. If you have questions about Jetpack, you can [start a new thread in the Jetpack support forums](https://wordpress.org/support/plugin/jetpack#new-post), or [send us an email](http://jetpack.com/contact-support/).
- Do not report potential security vulnerabilities here. For responsible disclosure of security issues and to be eligible for our bug bounty program, please review the [Security Policy guidelines](https://github.com/Automattic/jetpack/security/policy).
-->
1 change: 1 addition & 0 deletions .github/renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
{
"groupName": "Monorepo packages",
"matchPackageNames": [
"@automattic/eslint-changed",
"@automattic/jetpack-components",
"@automattic/jetpack-connection",
"automattic/jetpack-a8c-mc-stats",
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"docker:wp": "printf '\\e[30;43m`pnpm run docker:wp` is deprected. Use the Jetpack CLI instead.\\e[0m\\n'; jetpack docker wp",
"install-if-deps-outdated": "pnpm install --no-prod --frozen-lockfile",
"lint": "pnpm run lint-file -- .",
"lint-changed": "tools/eslint-changed.js --ext .js,.jsx --git",
"lint-changed": "eslint-changed --ext .js,.jsx --git",
"lint-file": "eslint --ext .js,.jsx",
"lint-required": "node -e \"const fs = require('fs'); fs.copyFileSync('.eslintignore','.eslintignore-required'); const w=fs.createWriteStream('.eslintignore-required',{flags:'a'}); w.write('\\n# tools/eslint-excludelist.json\\n'); w.end(JSON.parse(fs.readFileSync('tools/eslint-excludelist.json','utf8')).join('\\n')+'\\n')\" && pnpm run lint -- --max-warnings=0 --ignore-path .eslintignore-required",
"php:autofix": "composer phpcs:fix",
Expand All @@ -84,9 +84,9 @@
"chalk": "4.1.1"
},
"devDependencies": {
"@automattic/eslint-changed": "workspace:1.0.1-alpha",
"@wordpress/eslint-plugin": "7.4.0",
"babel-eslint": "10.1.0",
"commander": "7.2.0",
"eslint": "7.25.0",
"eslint-config-prettier": "8.3.0",
"eslint-config-wpcalypso": "6.1.0",
Expand Down
22 changes: 19 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions projects/js-packages/eslint-changed/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/changelog/** production-exclude
/.gitattributes production-exclude
/.gitignore production-exclude
/.nycrc production-exclude
/tests/** production-exclude
1 change: 1 addition & 0 deletions projects/js-packages/eslint-changed/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/.nyc_output/
5 changes: 5 additions & 0 deletions projects/js-packages/eslint-changed/.nycrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"extensions": [".js"],
"exclude": "tests/",
"reporter": "clover"
}
10 changes: 10 additions & 0 deletions projects/js-packages/eslint-changed/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 1.0.0 - unreleased

* Created as a tool within the monorepo.
87 changes: 87 additions & 0 deletions projects/js-packages/eslint-changed/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# ESLint Changed

Run [ESLint] on files and only report new warnings and errors.

## Installation

Install via your favorite JS package manager. Note the peer dependency on eslint.

For example,
```
npm install eslint-changed eslint
```

## Usage

To identify the changes, `eslint-changed` needs the ESLint output for both the old and new versions of the file, as well as the diff between them.
If you use git, it can determine this automatically. Otherwise, you can supply the necessary information manually.

Options used in both modes are:

* `--debug`: Enable debug output.
* `--ext <list>`: Comma-separated list of JavaScript file extensions. Ignored if files are listed. (default: ".js")
* `--format <name>`: ESLint format to use for output. (default: "stylish")
* `--in-diff-only`: Only include messages on lines changed in the diff. This may miss things like deleting a `var` that leads to a new `no-undef` elsewhere.

### Manual diff

The following options are used with manual mode:

* `--diff <file>`: A file containing the unified diff of the changes.
* `--diff-base <dir>`: Base directory the diff is relative to. Defaults to the current directory.
* `--eslint-orig <file>`: A file containing the JSON output of eslint on the unchanged files.
* `--eslint-new <file>`: A file containing the JSON output of eslint on the changed files.

### With git

In git mode, `eslint-changed` needs to be able to run `git` and `eslint`. If these are not available by those names in the shell path,
set environment variables `GIT` and/or `ESLINT` as appropriate.

The following options are used with manual mode:

* `--git`: Signify that you're using git mode.
* `--git-staged`: Compare the staged version to the HEAD version (this is the default).
* `--git-unstaged`: Compare the working copy version to the staged (or HEAD) version.
* `--git-base <ref>`: Compare the HEAD version to the HEAD of a different base (e.g. branch).

## Examples

This will compare the staged changes with HEAD.
```bash
npx eslint-changed --git
```

This will compare HEAD with origin/master.
```bash
npx eslint-changed --git --git-base origin/master
```

This does much the same as the previous example, but manually. If you're using something other than git, you might do something like this.
```bash
# Produce a diff.
git diff origin/master...HEAD > /tmp/diff

# Check out the merge-base of origin/master and HEAD.
git checkout origin/master...HEAD

# Run ESLint.
npx eslint --format=json . > /tmp/eslint.orig.json

# Go back to HEAD.
git checkout -

# Run ESLint again.
npx eslint --format=json . > /tmp/eslint.new.json

# Run eslint-changed.
npx eslint-changed --diff /tmp/diff --eslint-orig /tmp/eslint.orig.json --eslint=new /tmp/eslint.new.json
```
Note that, to be exactly the same as the above, you'd want to extract the list of files from the diff instead of linting everything. But this will work.

## Inspiration

We had been using [phpcs-changed] for a while, and wanted the same thing for ESLint.


[ESLint]: https://www.npmjs.com/package/eslint
[phpcs-changed]: https://packagist.org/packages/sirbrillig/phpcs-changed
Loading

0 comments on commit 51c7fc2

Please sign in to comment.