Skip to content

Commit

Permalink
feat!: bump all (dev)Dependencies, drop node < 16 (#449)
Browse files Browse the repository at this point in the history
  • Loading branch information
JounQin authored Oct 14, 2023
1 parent c4b5aa1 commit 5fd8eea
Show file tree
Hide file tree
Showing 11 changed files with 102 additions and 105 deletions.
5 changes: 5 additions & 0 deletions .changeset/new-years-design.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"prettier-eslint-cli": major
---

feat!: bump all (dev)Dependencies, drop node < 16
97 changes: 59 additions & 38 deletions __mocks__/glob.js
Original file line number Diff line number Diff line change
@@ -1,73 +1,94 @@
module.exports = jest.fn(function mockGlob(globString, options, callback) {
const glob = jest.fn(async function mockGlob(globString) {
/* eslint complexity:0 */
if (globString.includes('1')) {
callback(null, [
return [
fredProject('index.js'),
fredProject('start.js'),
fredProject('stop/index.js'),
fredProject('stop/log.js')
]);
} else if (globString.includes('2')) {
callback(null, [
];
}

if (globString.includes('2')) {
return [
fredProject('index.js'),
fredProject('start.js'),
fredProject('continue/index.js'),
fredProject('continue/forever.js')
]);
} else if (globString.includes('node_modules')) {
callback(null, [
];
}

if (globString.includes('node_modules')) {
return [
fredProject('foo/node_modules/stuff1.js'),
fredProject('foo/node_modules/stuff2.js'),
fredProject('foo/node_modules/stuff3.js')
]);
} else if (globString.includes('files-with-syntax-errors')) {
callback(null, [
fredProject('syntax-error1.js'),
fredProject('syntax-error2.js')
]);
} else if (globString.includes('no-match')) {
callback(null, []);
} else if (globString.includes('throw-error')) {
callback(new Error('something weird happened'));
} else if (globString.includes('no-change')) {
callback(null, [
];
}

if (globString.includes('files-with-syntax-errors')) {
return [fredProject('syntax-error1.js'), fredProject('syntax-error2.js')];
}

if (globString.includes('no-match')) {
return [];
}

if (globString.includes('throw-error')) {
throw new Error('something weird happened');
}

if (globString.includes('no-change')) {
return [
fredProject('no-change/1.js'),
fredProject('no-change/2.js'),
fredProject('no-change/3.js')
]);
} else if (globString.includes('eslintignored')) {
callback(null, [
];
}

if (globString.includes('eslintignored')) {
return [
fredProject('eslintignored1.js'),
fredProject('eslintignored2.js'),
fredProject('eslintignored3.js'),
fredProject('applied4.js')
]);
} else if (globString.includes('prettierignored')) {
callback(null, [
];
}

if (globString.includes('prettierignored')) {
return [
fredProject('prettierignored1.js'),
fredProject('prettierignored2.js'),
fredProject('prettierignored3.js'),
fredProject('applied4.js')
]);
} else if (globString.includes('no-ignore')) {
callback(null, [
];
}

if (globString.includes('no-ignore')) {
return [
barneyProject('no-ignore/1.js'),
barneyProject('no-ignore/2.js'),
barneyProject('no-ignore/3.js')
]);
} else if (globString.includes('eslint-config-error')) {
callback(null, [
];
}

if (globString.includes('eslint-config-error')) {
return [
fredProject('eslint-config-error/1.js'),
fredProject('eslint-config-error/2.js')
]);
} else {
throw new Error(
`Your test globString: "${globString}"` +
" doesn't have associated mock data."
);
];
}

throw new Error(
`Your test globString: "${globString}"` +
" doesn't have associated mock data."
);
});

glob.glob = glob;

exports.glob = glob;

function fredProject(path) {
return `/Users/fredFlintstone/Developer/top-secret/footless-carriage/${path}`;
}
Expand Down
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = {
testEnvironment: 'node',
// TODO: test all the files...
// collectCoverageFrom: ['src/**/*.js'],
testPathIgnorePatterns: ['/node_modules/', '/fixtures/'],
testPathIgnorePatterns: ['/node_modules/', '/fixtures/', '/dist/'],
coveragePathIgnorePatterns: ['/node_modules/', '/fixtures/', '/dist/'],
coverageThreshold: {
global: {
Expand Down
50 changes: 25 additions & 25 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "CLI for prettier-eslint",
"main": "dist/no-main.js",
"engines": {
"node": ">=12.22"
"node": ">=16.0.0"
},
"bin": {
"prettier-eslint": "dist/index.js"
Expand Down Expand Up @@ -39,44 +39,44 @@
}
},
"dependencies": {
"@messageformat/core": "^3.0.1",
"@prettier/eslint": "npm:prettier-eslint@^15.0.1",
"@messageformat/core": "^3.2.0",
"@prettier/eslint": "npm:prettier-eslint@^16.0.0",
"arrify": "^2.0.1",
"boolify": "^1.0.1",
"camelcase-keys": "^7.0.2",
"camelcase-keys": "^9.1.0",
"chalk": "^4.1.2",
"common-tags": "^1.8.2",
"core-js": "^3.24.1",
"eslint": "^8.21.0",
"core-js": "^3.33.0",
"eslint": "^8.51.0",
"find-up": "^5.0.0",
"get-stdin": "^8.0.0",
"glob": "^7.2.3",
"ignore": "^5.2.0",
"glob": "^10.3.10",
"ignore": "^5.2.4",
"indent-string": "^4.0.0",
"lodash.memoize": "^4.1.2",
"loglevel-colored-level-prefix": "^1.0.0",
"rxjs": "^7.5.6",
"yargs": "^13.1.1"
"rxjs": "^7.8.1",
"yargs": "^17.7.2"
},
"devDependencies": {
"@babel/cli": "^7.18.10",
"@babel/core": "^7.18.10",
"@babel/node": "^7.18.10",
"@babel/preset-env": "^7.18.10",
"@changesets/changelog-github": "^0.4.6",
"@changesets/cli": "^2.24.3",
"all-contributors-cli": "^6.20.0",
"clean-pkg-json": "^1.0.1",
"eslint-config-kentcdodds": "^20.3.1",
"eslint-plugin-node-dependencies": "^0.8.0",
"jest": "^28.1.3",
"lint-staged": "^12.5.0",
"@babel/cli": "^7.23.0",
"@babel/core": "^7.23.2",
"@babel/node": "^7.22.19",
"@babel/preset-env": "^7.23.2",
"@changesets/changelog-github": "^0.4.8",
"@changesets/cli": "^2.26.2",
"all-contributors-cli": "^6.26.1",
"clean-pkg-json": "^1.2.0",
"eslint-config-kentcdodds": "^20.5.0",
"eslint-plugin-node-dependencies": "^0.11.0",
"jest": "^29.7.0",
"lint-staged": "^14.0.1",
"nps": "^5.10.0",
"nps-utils": "^1.7.0",
"patch-package": "^6.4.7",
"patch-package": "^8.0.0",
"pify": "^5.0.0",
"rimraf": "^3.0.2",
"simple-git-hooks": "^2.8.0",
"rimraf": "^5.0.5",
"simple-git-hooks": "^2.9.0",
"spawn-command": "0.0.2-1",
"strip-indent": "^3.0.0",
"yargs-parser": "^21.1.1"
Expand Down
13 changes: 0 additions & 13 deletions patches/@rushstack+eslint-patch+1.1.4.patch

This file was deleted.

13 changes: 0 additions & 13 deletions patches/eslint-config-kentcdodds+20.3.1.patch

This file was deleted.

4 changes: 2 additions & 2 deletions src/__snapshots__/uncaught-exception-handler.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

exports[`logs a check for trace 1`] = `
"There has been an unknown error when running the prettier-eslint CLI. If it's unclear to you what went wrong, then try this:
✅ Run the script again with the LOG_LEVEL environment variable set to \\"trace\\"
✅ Run the script again with the LOG_LEVEL environment variable set to "trace"
2. Search existing issues on GitHub: https://github.com/prettier/prettier-eslint-cli/issues?utf8=%E2%9C%93&q=my%20error
3. Make a minimal reproduction in a totally separate repository. You can fork this one: https://github.com/kentcdodds/prettier-eslint-cli-repro
4. Post an issue with a link to your reproduction to the issues on GitHub: https://github.com/prettier/prettier-eslint-cli/issues/new"
`;

exports[`logs all options 1`] = `
"There has been an unknown error when running the prettier-eslint CLI. If it's unclear to you what went wrong, then try this:
1. Run the script again with the LOG_LEVEL environment variable set to \\"trace\\"
1. Run the script again with the LOG_LEVEL environment variable set to "trace"
2. Search existing issues on GitHub: https://github.com/prettier/prettier-eslint-cli/issues?utf8=%E2%9C%93&q=my%20error
3. Make a minimal reproduction in a totally separate repository. You can fork this one: https://github.com/kentcdodds/prettier-eslint-cli-repro
4. Post an issue with a link to your reproduction to the issues on GitHub: https://github.com/prettier/prettier-eslint-cli/issues/new"
Expand Down
8 changes: 4 additions & 4 deletions src/format-files.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/* eslint complexity:[1, 7] */
import path from 'path';
import fs from 'fs';
import glob from 'glob';
import { glob } from 'glob';
import { bindNodeCallback, from, of } from 'rxjs';
import { catchError, concatAll, distinct, map, mergeMap } from 'rxjs/operators';
import chalk from 'chalk';
Expand All @@ -16,7 +16,6 @@ import format from './prettier-eslint';
import * as messages from './messages';

const LINE_SEPERATOR_REGEX = /(\r|\n|\r\n)/;
const rxGlob = bindNodeCallback(glob);
const rxReadFile = bindNodeCallback(fs.readFile);
const rxWriteFile = bindNodeCallback(fs.writeFile);
const findUpEslintignoreSyncMemoized = memoize(
Expand Down Expand Up @@ -165,7 +164,8 @@ function formatFilesFromGlobs({
}

function onComplete() {
const isSilent = logger.getLevel() === logger.levels.SILENT || cliOptions.listDifferent;
const isSilent =
logger.getLevel() === logger.levels.SILENT || cliOptions.listDifferent;

/* use console.error directly here because
* - we don't want these messages prefixed
Expand Down Expand Up @@ -219,7 +219,7 @@ function getFilesFromGlob(
// not smart unless you explicitly include it in your glob
globOptions.ignore.push('**/node_modules/**');
}
return rxGlob(fileGlob, globOptions).pipe(
return from(glob(fileGlob, globOptions)).pipe(
map(filePaths => {
return filePaths.filter(filePath => {
if (applyEslintIgnore && isFilePathMatchedByEslintignore(filePath)) {
Expand Down
11 changes: 4 additions & 7 deletions src/format-files.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint no-console:0 */
import fsMock from 'fs';
import findUpMock from 'find-up';
import globMock from 'glob';
import { glob as globMock } from 'glob';
import mockGetStdin from 'get-stdin';
import getLogger from 'loglevel-colored-level-prefix';
import formatMock from './prettier-eslint';
Expand Down Expand Up @@ -43,8 +43,7 @@ test('glob call inclues an ignore of node_modules', async () => {
const globOptions = expect.objectContaining({
ignore: expect.arrayContaining(['**/node_modules/**'])
});
const callback = expect.any(Function);
expect(globMock).toHaveBeenCalledWith(fileGlob, globOptions, callback);
expect(globMock).toHaveBeenCalledWith(fileGlob, globOptions);
});

test('glob call excludes an ignore of node_modules', async () => {
Expand All @@ -55,8 +54,7 @@ test('glob call excludes an ignore of node_modules', async () => {
expect.objectContaining({
// should not have an ignore with **/node_modules/**
ignore: expect.arrayContaining(['**/node_modules/**'])
}),
expect.any
})
);
});

Expand Down Expand Up @@ -189,8 +187,7 @@ test('allows you to specify an ignore glob', async () => {
const globOptions = expect.objectContaining({
ignore: [...ignore, '**/node_modules/**']
});
const callback = expect.any(Function);
expect(globMock).toHaveBeenCalledWith(fileGlob, globOptions, callback);
expect(globMock).toHaveBeenCalledWith(fileGlob, globOptions);
});

test('wont modify a file if it is eslint ignored', async () => {
Expand Down
2 changes: 1 addition & 1 deletion src/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ const parser = yargs
// TODO: support range-start and range-end
// would require changes in prettier-eslint
})
.strict();
.strictOptions();

export default parser;

Expand Down
2 changes: 1 addition & 1 deletion test/tests/__snapshots__/cli.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ exports[`prettier-eslint --version: stdout: --version 1`] = `
`;

exports[`prettier-eslint test/fixtures/example*.js --write --no-eslint-ignore --no-prettier-ignore: file contents: prettier-eslint test/fixtures/example*.js --write --no-eslint-ignore --no-prettier-ignore 1`] = `
Object {
{
"example1Result": "const { example1 } = baz.bar;
",
"example2Result": "function example2(thing) {
Expand Down

0 comments on commit 5fd8eea

Please sign in to comment.