Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: prettier/pretty-quick
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v2.0.2
Choose a base ref
...
head repository: prettier/pretty-quick
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v3.0.0
Choose a head ref
  • 2 commits
  • 14 files changed
  • 2 contributors

Commits on Aug 21, 2020

  1. chore: update semantic-release

    azz authored Aug 21, 2020
    Copy the full SHA
    9765d16 View commit details
  2. BREAKING CHANGE: require node 10 and prettier 2 (#104)

    * chore: Update dependencies
    * BREAKING CHANGE: Node >=10.13.0 is required
    * BREAKING CHANGE: Prettier ^2.0.0 is required
    * Run Prettier on full codebase
    
    If you are still on an older version of Node, or using Prettier v1, please stay on `pretty-quick@2`.
    
    Co-authored-by: Lucas Azzola <lucas@azzola.dev>
    MichaelDeBoey and azz authored Aug 21, 2020
    Copy the full SHA
    9290ae4 View commit details
Showing with 2,442 additions and 2,440 deletions.
  1. +2 −2 .babelrc
  2. +11 −6 .travis.yml
  3. +2 −2 README.md
  4. +2 −2 __mocks__/prettier.js
  5. +4 −4 bin/pretty-quick.js
  6. +16 −16 package.json
  7. +2 −4 src/createIgnorer.js
  8. +2 −2 src/createMatcher.js
  9. +2 −2 src/index.js
  10. +1 −1 src/isSupportedExtension.js
  11. +3 −3 src/scms/git.js
  12. +2 −2 src/scms/hg.js
  13. +1 −1 src/scms/index.js
  14. +2,392 −2,393 yarn.lock
4 changes: 2 additions & 2 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -4,9 +4,9 @@
"@babel/preset-env",
{
"targets": {
"node": "6.10"
"node": "10.13"
}
}
]
]
}
}
17 changes: 11 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -6,18 +6,23 @@ cache:
notifications:
email: false
node_js:
- '12'
- '10'
- '8'
- 10.13
- 12
- node
install:
- yarn
script:
- yarn lint
- yarn build
- yarn test
after_success:
- npm install -g semantic-release@11 travis-deploy-once@4
- travis-deploy-once "yarn semantic-release"
deploy:
provider: script
skip_cleanup: true
script:
- npx semantic-release@15
on:
branch: master
node_js: '12'
branches:
except:
- /^v\d+\.\d+\.\d+$/
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -14,8 +14,8 @@ Runs [Prettier](https://prettier.io) on your changed files.

Supported source control managers:

* Git
* Mercurial
- Git
- Mercurial

## Install

4 changes: 2 additions & 2 deletions __mocks__/prettier.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const prettierMock = {
format: jest.fn().mockImplementation(input => 'formatted:' + input),
format: jest.fn().mockImplementation((input) => 'formatted:' + input),
resolveConfig: {
sync: jest.fn().mockImplementation(file => ({ file })),
sync: jest.fn().mockImplementation((file) => ({ file })),
},
getSupportInfo: jest.fn().mockReturnValue({
languages: [
8 changes: 4 additions & 4 deletions bin/pretty-quick.js
Original file line number Diff line number Diff line change
@@ -20,19 +20,19 @@ const prettyQuickResult = prettyQuick(
);
},

onFoundChangedFiles: changedFiles => {
onFoundChangedFiles: (changedFiles) => {
console.log(
`🎯 Found ${chalk.bold(changedFiles.length)} changed ${
changedFiles.length === 1 ? 'file' : 'files'
}.`,
);
},

onPartiallyStagedFile: file => {
onPartiallyStagedFile: (file) => {
console.log(`✗ Found ${chalk.bold('partially')} staged file ${file}.`);
},

onWriteFile: file => {
onWriteFile: (file) => {
console.log(`✍️ Fixing up ${chalk.bold(file)}.`);
},

@@ -42,7 +42,7 @@ const prettyQuickResult = prettyQuick(
}
},

onExamineFile: file => {
onExamineFile: (file) => {
console.log(`🔍 Examining ${chalk.bold(file)}.`);
},
}),
32 changes: 16 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@
"bin": "./bin/pretty-quick.js",
"license": "MIT",
"engines": {
"node": ">=8"
"node": ">=10.13"
},
"keywords": [
"git",
@@ -27,11 +27,11 @@
"img"
],
"dependencies": {
"chalk": "^2.4.2",
"execa": "^2.1.0",
"chalk": "^3.0.0",
"execa": "^4.0.0",
"find-up": "^4.1.0",
"ignore": "^5.1.4",
"mri": "^1.1.4",
"mri": "^1.1.5",
"multimatch": "^4.0.0"
},
"scripts": {
@@ -49,20 +49,20 @@
},
"prettier": "@azz/prettier-config",
"peerDependencies": {
"prettier": ">=1.8.0"
"prettier": ">=2.0.0"
},
"devDependencies": {
"@azz/prettier-config": "^1.0.0",
"@babel/cli": "^7.6.4",
"@babel/core": "^7.6.4",
"@babel/preset-env": "^7.6.3",
"eslint": "^5.16.0",
"eslint-config-prettier": "^6.4.0",
"eslint-plugin-jest": "^22.19.0",
"eslint-plugin-prettier": "^3.1.1",
"husky": "^3.0.9",
"jest": "^24.9.0",
"mock-fs": "^4.10.1",
"prettier": "1.18.2"
"@babel/cli": "^7.8.4",
"@babel/core": "^7.9.0",
"@babel/preset-env": "^7.9.0",
"eslint": "^6.8.0",
"eslint-config-prettier": "^6.10.1",
"eslint-plugin-jest": "^23.8.2",
"eslint-plugin-prettier": "^3.1.2",
"husky": "^4.2.3",
"jest": "^25.2.3",
"mock-fs": "^4.11.0",
"prettier": "2.0.2"
}
}
6 changes: 2 additions & 4 deletions src/createIgnorer.js
Original file line number Diff line number Diff line change
@@ -6,10 +6,8 @@ export default (directory, filename = '.prettierignore') => {
const file = join(directory, filename);
if (existsSync(file)) {
const text = readFileSync(file, 'utf8');
const filter = ignore()
.add(text)
.createFilter();
return path => filter(join(path));
const filter = ignore().add(text).createFilter();
return (path) => filter(join(path));
}

return () => true;
4 changes: 2 additions & 2 deletions src/createMatcher.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import multimatch from 'multimatch';
const path = require('path');

export default pattern => {
export default (pattern) => {
// Match everything if no pattern was given
if (typeof pattern !== 'string' && !Array.isArray(pattern)) {
return () => true;
}
const patterns = Array.isArray(pattern) ? pattern : [pattern];
return file =>
return (file) =>
multimatch(path.normalize(file), patterns, { dot: true }).length > 0;
};
4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -56,7 +56,7 @@ export default (
.filter(cwdIgnorer)
: [];

const wasFullyStaged = f => unstagedFiles.indexOf(f) < 0;
const wasFullyStaged = (f) => unstagedFiles.indexOf(f) < 0;

onFoundChangedFiles && onFoundChangedFiles(changedFiles);

@@ -65,7 +65,7 @@ export default (
processFiles(directory, changedFiles, {
check,
config,
onWriteFile: file => {
onWriteFile: (file) => {
onWriteFile && onWriteFile(file);
if (bail) {
failReasons.add('BAIL_ON_WRITE');
2 changes: 1 addition & 1 deletion src/isSupportedExtension.js
Original file line number Diff line number Diff line change
@@ -5,4 +5,4 @@ const extensions = getSupportInfo().languages.reduce(
[],
);

export default file => extensions.some(ext => file.endsWith(ext));
export default (file) => extensions.some((ext) => file.endsWith(ext));
6 changes: 3 additions & 3 deletions src/scms/git.js
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ import * as fs from 'fs';

export const name = 'git';

export const detect = directory => {
export const detect = (directory) => {
if (fs.existsSync(join(directory, '.git'))) {
return directory;
}
@@ -24,7 +24,7 @@ const runGit = (directory, args) =>
cwd: directory,
});

const getLines = execaResult => execaResult.stdout.split('\n');
const getLines = (execaResult) => execaResult.stdout.split('\n');

export const getSinceRevision = (directory, { staged, branch }) => {
try {
@@ -69,7 +69,7 @@ export const getChangedFiles = (directory, revision, staged) => {
].filter(Boolean);
};

export const getUnstagedChangedFiles = directory => {
export const getUnstagedChangedFiles = (directory) => {
return getChangedFiles(directory, null, false);
};

4 changes: 2 additions & 2 deletions src/scms/hg.js
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ import { dirname } from 'path';

export const name = 'hg';

export const detect = directory => {
export const detect = (directory) => {
const hgDirectory = findUp.sync('.hg', {
cwd: directory,
type: 'directory',
@@ -19,7 +19,7 @@ const runHg = (directory, args) =>
cwd: directory,
});

const getLines = execaResult => execaResult.stdout.split('\n');
const getLines = (execaResult) => execaResult.stdout.split('\n');

export const getSinceRevision = (directory, { branch }) => {
const revision = runHg(directory, [
2 changes: 1 addition & 1 deletion src/scms/index.js
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ import * as hgScm from './hg';

const scms = [gitScm, hgScm];

export default directory => {
export default (directory) => {
for (const scm of scms) {
const rootDirectory = scm.detect(directory);
if (rootDirectory) {
4,785 changes: 2,392 additions & 2,393 deletions yarn.lock

Large diffs are not rendered by default.