Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: ✨ Support ESLint 8 #696

Merged
merged 7 commits into from
Apr 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,15 @@
"contributions": [
"maintenance"
]
},
{
"login": "idahogurl",
"name": "Rebecca Vest",
"avatar_url": "https://avatars.githubusercontent.com/u/10620169?v=4",
"profile": "https://campcode.dev/",
"contributions": [
"code"
]
}
],
"repoType": "github",
Expand Down
19 changes: 10 additions & 9 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
const config = {
extends: ["kentcdodds", "kentcdodds/jest"],
extends: ['kentcdodds', 'kentcdodds/jest'],
rules: {
"valid-jsdoc": "off",
"max-len": "off",
"space-before-function-paren": [
"error",
'valid-jsdoc': 'off',
'max-len': 'off',
'space-before-function-paren': [
'error',
{
anonymous: "never",
named: "never",
asyncArrow: "always"
anonymous: 'never',
named: 'never',
asyncArrow: 'always'
}
]
],
'import/no-import-module-exports': 'off'
}
};

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: CI

on: [push]
on: [push, pull_request]

jobs:
ci:
Expand Down
4 changes: 4 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The eslint-config-kentcdodds update changed some rules including removing the quotes and arrow parenthesis rules.

arrowParens: 'avoid',
singleQuote: true
}
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ const options = {
},
};

const formatted = format(options);
const formatted = await format(options);

// notice no semicolon in the formatted text
formatted; // const { foo } = bar
Expand Down Expand Up @@ -304,6 +304,7 @@ Thanks goes to these people ([emoji key][emojis]):
</tr>
<tr>
<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>
<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>
</tr>
</table>

Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@
],
"license": "MIT",
"dependencies": {
"@typescript-eslint/parser": "^3.0.0",
"@typescript-eslint/parser": "^5.10.0",
"common-tags": "^1.4.0",
"dlv": "^1.1.0",
"eslint": "^7.9.0",
"eslint": "^8.7.0",
"indent-string": "^4.0.0",
"lodash.merge": "^4.6.0",
"loglevel-colored-level-prefix": "^1.0.0",
"prettier": "^2.0.0",
"prettier": "^2.5.1",
"pretty-format": "^23.0.1",
"require-relative": "^0.8.7",
"typescript": "^3.9.3",
"vue-eslint-parser": "~7.1.0"
"typescript": "^4.5.4",
"vue-eslint-parser": "^8.0.1"
},
"devDependencies": {
"@babel/cli": "^7.4.4",
Expand All @@ -40,7 +40,7 @@
"all-contributors-cli": "^6.7.0",
"babel-jest": "^25.0.0",
"chalk": "^2.1.0",
"eslint-config-kentcdodds": "~16.0.1",
"eslint-config-kentcdodds": "^20.0.1",
"husky": "^2.4.1",
"jest": "^25.0.0",
"jest-cli": "^25.0.0",
Expand Down
44 changes: 22 additions & 22 deletions src/__mocks__/eslint.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,35 @@
// search around the file system for stuff

const eslint = jest.requireActual('eslint');
const { CLIEngine } = eslint;
const { ESLint } = eslint;

const mockGetConfigForFileSpy = jest.fn(mockGetConfigForFile);
mockGetConfigForFileSpy.overrides = {};
const mockExecuteOnTextSpy = jest.fn(mockExecuteOnText);
const mockCalculateConfigForFileSpy = jest.fn(mockCalculateConfigForFile);
mockCalculateConfigForFileSpy.overrides = {};
const mockLintTextSpy = jest.fn(mockLintText);

module.exports = Object.assign(eslint, {
CLIEngine: jest.fn(MockCLIEngine),
ESLint: jest.fn(MockESLint),
mock: {
getConfigForFile: mockGetConfigForFileSpy,
executeOnText: mockExecuteOnTextSpy
calculateConfigForFile: mockCalculateConfigForFileSpy,
lintText: mockLintTextSpy
}
});

function MockCLIEngine(...args) {
function MockESLint(...args) {
global.__PRETTIER_ESLINT_TEST_STATE__.eslintPath = __filename;
const cliEngine = new CLIEngine(...args);
cliEngine.getConfigForFile = mockGetConfigForFileSpy;
cliEngine._originalExecuteOnText = cliEngine.executeOnText;
cliEngine.executeOnText = mockExecuteOnTextSpy;
return cliEngine;
const eslintInstance = new ESLint(...args);
eslintInstance.calculateConfigForFile = mockCalculateConfigForFileSpy;
eslintInstance._originalLintText = eslintInstance.lintText;
eslintInstance.lintText = mockLintTextSpy;
return eslintInstance;
}

MockCLIEngine.prototype = Object.create(CLIEngine.prototype);
MockESLint.prototype = Object.create(ESLint.prototype);

// eslint-disable-next-line complexity
function mockGetConfigForFile(filePath) {
if (mockGetConfigForFileSpy.throwError) {
throw mockGetConfigForFileSpy.throwError;
function mockCalculateConfigForFile(filePath) {
if (mockCalculateConfigForFileSpy.throwError) {
throw mockCalculateConfigForFileSpy.throwError;
}
if (!filePath) {
return {
Expand Down Expand Up @@ -71,10 +71,10 @@ function mockGetConfigForFile(filePath) {
}
}

function mockExecuteOnText(...args) {
/* eslint babel/no-invalid-this:0 */
if (mockExecuteOnTextSpy.throwError) {
throw mockExecuteOnTextSpy.throwError;
function mockLintText(...args) {
/* eslint no-invalid-this:0 */
if (mockLintTextSpy.throwError) {
throw mockLintTextSpy.throwError;
}
return this._originalExecuteOnText(...args);
return this._originalLintText(...args);
}
Loading