Skip to content

Commit d8bf1e3

Browse files
authored
feat: ✨ Support ESLint 8 (#696)
1 parent c62769e commit d8bf1e3

File tree

12 files changed

+177
-151
lines changed

12 files changed

+177
-151
lines changed

.all-contributorsrc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,15 @@
301301
"contributions": [
302302
"maintenance"
303303
]
304+
},
305+
{
306+
"login": "idahogurl",
307+
"name": "Rebecca Vest",
308+
"avatar_url": "https://avatars.githubusercontent.com/u/10620169?v=4",
309+
"profile": "https://campcode.dev/",
310+
"contributions": [
311+
"code"
312+
]
304313
}
305314
],
306315
"repoType": "github",

.eslintrc.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
const config = {
2-
extends: ["kentcdodds", "kentcdodds/jest"],
2+
extends: ['kentcdodds', 'kentcdodds/jest'],
33
rules: {
4-
"valid-jsdoc": "off",
5-
"max-len": "off",
6-
"space-before-function-paren": [
7-
"error",
4+
'valid-jsdoc': 'off',
5+
'max-len': 'off',
6+
'space-before-function-paren': [
7+
'error',
88
{
9-
anonymous: "never",
10-
named: "never",
11-
asyncArrow: "always"
9+
anonymous: 'never',
10+
named: 'never',
11+
asyncArrow: 'always'
1212
}
13-
]
13+
],
14+
'import/no-import-module-exports': 'off'
1415
}
1516
};
1617

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: CI
22

3-
on: [push]
3+
on: [push, pull_request]
44

55
jobs:
66
ci:

.prettierrc.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = {
2+
arrowParens: 'avoid',
3+
singleQuote: true
4+
}

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ const options = {
7272
},
7373
};
7474

75-
const formatted = format(options);
75+
const formatted = await format(options);
7676

7777
// notice no semicolon in the formatted text
7878
formatted; // const { foo } = bar
@@ -304,6 +304,7 @@ Thanks goes to these people ([emoji key][emojis]):
304304
</tr>
305305
<tr>
306306
<td align="center"><a href="https://github.com/cy6erskunk"><img src="https://avatars3.githubusercontent.com/u/754849?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Igor</b></sub></a><br /><a href="#maintenance-cy6erskunk" title="Maintenance">🚧</a></td>
307+
<td align="center"><a href="https://campcode.dev/"><img src="https://avatars.githubusercontent.com/u/10620169?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Rebecca Vest</b></sub></a><br /><a href="https://github.com/prettier/prettier-eslint/commits?author=idahogurl" title="Code">💻</a></td>
307308
</tr>
308309
</table>
309310

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,18 @@
1818
],
1919
"license": "MIT",
2020
"dependencies": {
21-
"@typescript-eslint/parser": "^3.0.0",
21+
"@typescript-eslint/parser": "^5.10.0",
2222
"common-tags": "^1.4.0",
2323
"dlv": "^1.1.0",
24-
"eslint": "^7.9.0",
24+
"eslint": "^8.7.0",
2525
"indent-string": "^4.0.0",
2626
"lodash.merge": "^4.6.0",
2727
"loglevel-colored-level-prefix": "^1.0.0",
28-
"prettier": "^2.0.0",
28+
"prettier": "^2.5.1",
2929
"pretty-format": "^23.0.1",
3030
"require-relative": "^0.8.7",
31-
"typescript": "^3.9.3",
32-
"vue-eslint-parser": "~7.1.0"
31+
"typescript": "^4.5.4",
32+
"vue-eslint-parser": "^8.0.1"
3333
},
3434
"devDependencies": {
3535
"@babel/cli": "^7.4.4",
@@ -40,7 +40,7 @@
4040
"all-contributors-cli": "^6.7.0",
4141
"babel-jest": "^25.0.0",
4242
"chalk": "^2.1.0",
43-
"eslint-config-kentcdodds": "~16.0.1",
43+
"eslint-config-kentcdodds": "^20.0.1",
4444
"husky": "^2.4.1",
4545
"jest": "^25.0.0",
4646
"jest-cli": "^25.0.0",

src/__mocks__/eslint.js

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,35 @@
22
// search around the file system for stuff
33

44
const eslint = jest.requireActual('eslint');
5-
const { CLIEngine } = eslint;
5+
const { ESLint } = eslint;
66

7-
const mockGetConfigForFileSpy = jest.fn(mockGetConfigForFile);
8-
mockGetConfigForFileSpy.overrides = {};
9-
const mockExecuteOnTextSpy = jest.fn(mockExecuteOnText);
7+
const mockCalculateConfigForFileSpy = jest.fn(mockCalculateConfigForFile);
8+
mockCalculateConfigForFileSpy.overrides = {};
9+
const mockLintTextSpy = jest.fn(mockLintText);
1010

1111
module.exports = Object.assign(eslint, {
12-
CLIEngine: jest.fn(MockCLIEngine),
12+
ESLint: jest.fn(MockESLint),
1313
mock: {
14-
getConfigForFile: mockGetConfigForFileSpy,
15-
executeOnText: mockExecuteOnTextSpy
14+
calculateConfigForFile: mockCalculateConfigForFileSpy,
15+
lintText: mockLintTextSpy
1616
}
1717
});
1818

19-
function MockCLIEngine(...args) {
19+
function MockESLint(...args) {
2020
global.__PRETTIER_ESLINT_TEST_STATE__.eslintPath = __filename;
21-
const cliEngine = new CLIEngine(...args);
22-
cliEngine.getConfigForFile = mockGetConfigForFileSpy;
23-
cliEngine._originalExecuteOnText = cliEngine.executeOnText;
24-
cliEngine.executeOnText = mockExecuteOnTextSpy;
25-
return cliEngine;
21+
const eslintInstance = new ESLint(...args);
22+
eslintInstance.calculateConfigForFile = mockCalculateConfigForFileSpy;
23+
eslintInstance._originalLintText = eslintInstance.lintText;
24+
eslintInstance.lintText = mockLintTextSpy;
25+
return eslintInstance;
2626
}
2727

28-
MockCLIEngine.prototype = Object.create(CLIEngine.prototype);
28+
MockESLint.prototype = Object.create(ESLint.prototype);
2929

3030
// eslint-disable-next-line complexity
31-
function mockGetConfigForFile(filePath) {
32-
if (mockGetConfigForFileSpy.throwError) {
33-
throw mockGetConfigForFileSpy.throwError;
31+
function mockCalculateConfigForFile(filePath) {
32+
if (mockCalculateConfigForFileSpy.throwError) {
33+
throw mockCalculateConfigForFileSpy.throwError;
3434
}
3535
if (!filePath) {
3636
return {
@@ -71,10 +71,10 @@ function mockGetConfigForFile(filePath) {
7171
}
7272
}
7373

74-
function mockExecuteOnText(...args) {
75-
/* eslint babel/no-invalid-this:0 */
76-
if (mockExecuteOnTextSpy.throwError) {
77-
throw mockExecuteOnTextSpy.throwError;
74+
function mockLintText(...args) {
75+
/* eslint no-invalid-this:0 */
76+
if (mockLintTextSpy.throwError) {
77+
throw mockLintTextSpy.throwError;
7878
}
79-
return this._originalExecuteOnText(...args);
79+
return this._originalLintText(...args);
8080
}

0 commit comments

Comments
 (0)