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.x #903

Closed
wants to merge 1 commit into from
Closed
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
8 changes: 8 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
'use strict';

const { version } = require('eslint/package.json');
const semver = require('semver');
const globals = require('./src/globals.json');

module.exports = {
Expand Down Expand Up @@ -28,12 +30,18 @@ module.exports = {
es6: true,
},
rules: {
// eslint-plugin-prettier removed ESLint v6 support
...(semver.gte(version, '7.28.0') ? {} : { 'prettier/prettier': 'off' }),
Copy link
Member

Choose a reason for hiding this comment

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

just keep using eslint-plugin-prettier@3, no reason to upgrade it

'@typescript-eslint/array-type': ['error', { default: 'array-simple' }],
'@typescript-eslint/no-require-imports': 'error',
'@typescript-eslint/ban-ts-comment': 'warn',
'@typescript-eslint/ban-types': 'error',
'@typescript-eslint/no-unused-vars': 'error',
'eslint-comments/no-unused-disable': 'error',
'eslint-plugin/require-meta-fixable': [
MichaelDeBoey marked this conversation as resolved.
Show resolved Hide resolved
'error',
{ catchNoFixerButFixableProperty: true },
],
'eslint-plugin/test-case-property-ordering': 'error',
'no-else-return': 'error',
'no-negated-condition': 'error',
Expand Down
19 changes: 11 additions & 8 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:

- uses: actions/setup-node@v2
with:
node-version: 14.x
node-version: 16
cache: yarn

- name: Validate cache
Expand All @@ -38,7 +38,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 14.x
node-version: 16
cache: yarn
- name: install
run: yarn
Expand All @@ -52,7 +52,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 14.x
node-version: 16
cache: yarn
- name: install
run: yarn
Expand All @@ -67,9 +67,12 @@ jobs:
strategy:
fail-fast: false
matrix:
node-version: [12.x, 14.x, 16.x]
eslint-version: [6, 7]
node-version: [12, 14, 16]
eslint-version: [6, 7, 8]
ts-eslint-plugin-version: [4, 5]
exclude:
- eslint-version: 8
ts-eslint-plugin-version: 4
runs-on: ubuntu-latest

steps:
Expand Down Expand Up @@ -104,7 +107,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 14.x
node-version: 16
cache: yarn
- name: install
run: yarn
Expand All @@ -123,7 +126,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 14.x
node-version: 16
cache: yarn
- name: install
run: yarn
Expand All @@ -146,7 +149,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 14.x
node-version: 16
cache: yarn
- name: install
run: yarn
Expand Down
20 changes: 13 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@
"projects": [
{
"displayName": "test",
"moduleNameMapper": {
"@eslint/eslintrc/universal": "@eslint/eslintrc/dist/eslintrc-universal.cjs"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
"@eslint/eslintrc/universal": "@eslint/eslintrc/dist/eslintrc-universal.cjs"
"eslint/use-at-your-own-risk": "eslint/lib/unsupported-api.js"

This is whats giving unbound-method trouble

(you can replace the existing map since we'll update to v8.0.1)

},
"testPathIgnorePatterns": [
"<rootDir>/lib/.*",
"<rootDir>/src/rules/__tests__/fixtures/*",
Expand Down Expand Up @@ -100,14 +103,14 @@
"babel-jest": "^27.0.0",
"babel-plugin-replace-ts-export-assignment": "^0.0.2",
"dedent": "^0.7.0",
"eslint": "^6.0.0 || ^7.0.0",
"eslint": "^6.0.0 || ^7.0.0 || ^8.0.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-eslint-comments": "^3.1.2",
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-eslint-config": "^2.0.0",
"eslint-plugin-eslint-plugin": "^3.5.3",
"eslint-plugin-import": "^2.25.1",
"eslint-plugin-node": "^11.0.0",
"eslint-plugin-prettier": "^3.4.1",
"eslint-plugin-eslint-plugin": "^4.0.0-0",
"eslint-plugin-import": "^2.25.2",
"eslint-plugin-node": "^11.1.0",
MichaelDeBoey marked this conversation as resolved.
Show resolved Hide resolved
"eslint-plugin-prettier": "^4.0.0",
"husky": "^7.0.2",
"is-ci": "^3.0.0",
"jest": "^27.0.0",
Expand All @@ -123,7 +126,7 @@
},
"peerDependencies": {
"@typescript-eslint/eslint-plugin": "^4.0.0 || ^5.0.0",
"eslint": "^6.0.0 || ^7.0.0"
"eslint": "^6.0.0 || ^7.0.0 || ^8.0.0"
},
"peerDependenciesMeta": {
"@typescript-eslint/eslint-plugin": {
Expand All @@ -149,5 +152,8 @@
"@semantic-release/git",
"@semantic-release/github"
]
},
"resolutions": {
"@typescript-eslint/experimental-utils": "^5.0.0"
}
}
7 changes: 0 additions & 7 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,6 @@ type RuleModule = TSESLint.RuleModule<string, unknown[]> & {
meta: Required<Pick<TSESLint.RuleMetaData<string>, 'docs'>>;
};

// v5 of `@typescript-eslint/experimental-utils` removed this
declare module '@typescript-eslint/experimental-utils/dist/ts-eslint/Rule' {
export interface RuleMetaDataDocs {
category: 'Best Practices' | 'Possible Errors';
}
}

// copied from https://github.com/babel/babel/blob/d8da63c929f2d28c401571e2a43166678c555bc4/packages/babel-helpers/src/helpers.js#L602-L606
/* istanbul ignore next */
const interopRequireDefault = (obj: any): { default: any } =>
Expand Down
14 changes: 14 additions & 0 deletions src/rules/__tests__/no-jasmine-globals.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ ruleTester.run('no-jasmine-globals', rule, {
invalid: [
{
code: 'spyOn(some, "object")',
output: null,
errors: [
{
messageId: 'illegalGlobal',
Expand All @@ -32,6 +33,7 @@ ruleTester.run('no-jasmine-globals', rule, {
},
{
code: 'spyOnProperty(some, "object")',
output: null,
errors: [
{
messageId: 'illegalGlobal',
Expand All @@ -43,10 +45,12 @@ ruleTester.run('no-jasmine-globals', rule, {
},
{
code: 'fail()',
output: null,
errors: [{ messageId: 'illegalFail', column: 1, line: 1 }],
},
{
code: 'pending()',
output: null,
errors: [{ messageId: 'illegalPending', column: 1, line: 1 }],
},
{
Expand All @@ -56,10 +60,12 @@ ruleTester.run('no-jasmine-globals', rule, {
},
{
code: 'jasmine.DEFAULT_TIMEOUT_INTERVAL = function() {}',
output: null,
errors: [{ messageId: 'illegalJasmine', column: 1, line: 1 }],
},
{
code: 'jasmine.addMatchers(matchers)',
output: null,
errors: [
{
messageId: 'illegalMethod',
Expand All @@ -71,6 +77,7 @@ ruleTester.run('no-jasmine-globals', rule, {
},
{
code: 'jasmine.createSpy()',
output: null,
errors: [
{
messageId: 'illegalMethod',
Expand Down Expand Up @@ -151,30 +158,37 @@ ruleTester.run('no-jasmine-globals', rule, {
},
{
code: 'jasmine.getEnv()',
output: null,
errors: [{ messageId: 'illegalJasmine', column: 1, line: 1 }],
},
{
code: 'jasmine.empty()',
output: null,
errors: [{ messageId: 'illegalJasmine', column: 1, line: 1 }],
},
{
code: 'jasmine.falsy()',
output: null,
errors: [{ messageId: 'illegalJasmine', column: 1, line: 1 }],
},
{
code: 'jasmine.truthy()',
output: null,
errors: [{ messageId: 'illegalJasmine', column: 1, line: 1 }],
},
{
code: 'jasmine.arrayWithExactContents()',
output: null,
errors: [{ messageId: 'illegalJasmine', column: 1, line: 1 }],
},
{
code: 'jasmine.clock()',
output: null,
errors: [{ messageId: 'illegalJasmine', column: 1, line: 1 }],
},
{
code: 'jasmine.MAX_PRETTY_PRINT_ARRAY_LENGTH = 42',
output: null,
errors: [{ messageId: 'illegalJasmine', column: 1, line: 1 }],
},
],
Expand Down
1 change: 0 additions & 1 deletion src/rules/__tests__/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ const rule = createRule({
name: __filename,
meta: {
docs: {
category: 'Possible Errors',
MichaelDeBoey marked this conversation as resolved.
Show resolved Hide resolved
description: 'Fake rule for testing AST guards',
recommended: false,
},
Expand Down
1 change: 0 additions & 1 deletion src/rules/consistent-test-it.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ export default createRule<
name: __filename,
meta: {
docs: {
category: 'Best Practices',
description: 'Have control over `test` and `it` usages',
recommended: false,
},
Expand Down
1 change: 0 additions & 1 deletion src/rules/expect-expect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ export default createRule<
name: __filename,
meta: {
docs: {
category: 'Best Practices',
description: 'Enforce assertion to be made in a test body',
recommended: 'warn',
},
Expand Down
1 change: 0 additions & 1 deletion src/rules/max-nested-describe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export default createRule({
name: __filename,
meta: {
docs: {
category: 'Best Practices',
description: 'Enforces a maximum depth to nested describe calls',
recommended: false,
},
Expand Down
1 change: 0 additions & 1 deletion src/rules/no-alias-methods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ export default createRule({
name: __filename,
meta: {
docs: {
category: 'Best Practices',
description: 'Disallow alias methods',
recommended: false,
},
Expand Down
1 change: 0 additions & 1 deletion src/rules/no-commented-out-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export default createRule({
name: __filename,
meta: {
docs: {
category: 'Best Practices',
description: 'Disallow commented out tests',
recommended: 'warn',
},
Expand Down
1 change: 0 additions & 1 deletion src/rules/no-conditional-expect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export default createRule({
meta: {
docs: {
description: 'Prevent calling `expect` conditionally',
category: 'Best Practices',
recommended: 'error',
},
messages: {
Expand Down
1 change: 0 additions & 1 deletion src/rules/no-deprecated-functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ export default createRule({
name: __filename,
meta: {
docs: {
category: 'Best Practices',
description: 'Disallow use of deprecated functions',
recommended: 'error',
},
Expand Down
1 change: 0 additions & 1 deletion src/rules/no-disabled-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ export default createRule({
name: __filename,
meta: {
docs: {
category: 'Best Practices',
description: 'Disallow disabled tests',
recommended: 'warn',
},
Expand Down
1 change: 0 additions & 1 deletion src/rules/no-done-callback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ export default createRule({
name: __filename,
meta: {
docs: {
category: 'Best Practices',
description: 'Avoid using a callback in asynchronous tests and hooks',
recommended: 'error',
suggestion: true,
Expand Down
1 change: 0 additions & 1 deletion src/rules/no-duplicate-hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export default createRule({
name: __filename,
meta: {
docs: {
category: 'Best Practices',
description: 'Disallow duplicate setup and teardown hooks',
recommended: false,
},
Expand Down
1 change: 0 additions & 1 deletion src/rules/no-export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export default createRule({
name: __filename,
meta: {
docs: {
category: 'Best Practices',
description: 'Disallow using `exports` in files containing tests',
recommended: 'error',
},
Expand Down
1 change: 0 additions & 1 deletion src/rules/no-focused-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ export default createRule({
name: __filename,
meta: {
docs: {
category: 'Best Practices',
description: 'Disallow focused tests',
recommended: 'error',
suggestion: true,
Expand Down
1 change: 0 additions & 1 deletion src/rules/no-hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ export default createRule<
name: __filename,
meta: {
docs: {
category: 'Best Practices',
description: 'Disallow setup and teardown hooks',
recommended: false,
},
Expand Down
1 change: 0 additions & 1 deletion src/rules/no-identical-title.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export default createRule({
name: __filename,
meta: {
docs: {
category: 'Best Practices',
description: 'Disallow identical titles',
recommended: 'error',
},
Expand Down
1 change: 0 additions & 1 deletion src/rules/no-if.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ export default createRule({
meta: {
docs: {
description: 'Disallow conditional logic',
category: 'Best Practices',
recommended: false,
},
messages: {
Expand Down
1 change: 0 additions & 1 deletion src/rules/no-interpolation-in-snapshots.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ export default createRule({
name: __filename,
meta: {
docs: {
category: 'Best Practices',
description: 'Disallow string interpolation inside snapshots',
recommended: 'error',
},
Expand Down
1 change: 0 additions & 1 deletion src/rules/no-jasmine-globals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ export default createRule({
name: __filename,
meta: {
docs: {
category: 'Best Practices',
description: 'Disallow Jasmine globals',
recommended: 'error',
},
Expand Down
1 change: 0 additions & 1 deletion src/rules/no-jest-import.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ export default createRule({
type: 'problem',
docs: {
description: 'Disallow importing Jest',
category: 'Best Practices',
recommended: 'error',
},
messages: {
Expand Down
Loading