Skip to content

Commit

Permalink
BREAKING CHANGE: require node 10 and prettier 2 (#104)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
MichaelDeBoey and azz authored Aug 21, 2020
1 parent 9765d16 commit 9290ae4
Show file tree
Hide file tree
Showing 14 changed files with 2,434 additions and 2,437 deletions.
4 changes: 2 additions & 2 deletions .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
"@babel/preset-env",
{
"targets": {
"node": "6.10"
"node": "10.13"
}
}
]
]
}
}
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ cache:
notifications:
email: false
node_js:
- '12'
- '10'
- '8'
- 10.13
- 12
- node
install:
- yarn
script:
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ Runs [Prettier](https://prettier.io) on your changed files.

Supported source control managers:

* Git
* Mercurial
- Git
- Mercurial

## Install

Expand Down
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: [
Expand Down
8 changes: 4 additions & 4 deletions bin/pretty-quick.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)}.`);
},

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

onExamineFile: file => {
onExamineFile: (file) => {
console.log(`🔍 Examining ${chalk.bold(file)}.`);
},
}),
Expand Down
32 changes: 16 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"bin": "./bin/pretty-quick.js",
"license": "MIT",
"engines": {
"node": ">=8"
"node": ">=10.13"
},
"keywords": [
"git",
Expand All @@ -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": {
Expand All @@ -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
Expand Up @@ -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;
Expand Down
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
Expand Up @@ -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);

Expand All @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion src/isSupportedExtension.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Up @@ -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;
}
Expand All @@ -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 {
Expand Down Expand Up @@ -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);
};

Expand Down
4 changes: 2 additions & 2 deletions src/scms/hg.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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, [
Expand Down
2 changes: 1 addition & 1 deletion src/scms/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Loading

0 comments on commit 9290ae4

Please sign in to comment.