Adds eslint-plugin-eslint-plugin to ensure eslint-plugin-next rules follow ESLint rule best practices along with enforcing some consistency. (#37920)

* Adds eslint-plugin-eslint-plugin and recommended rules.

* Removes `fixable` as none of the rules contain fixers.

* Adds description and url rules.

* Adds message format.

* Removes optional dependencies.

* Lints eslint-plugin-next tests too.

* Removes optional dependencies from pnpm lock file.

* Resets pnpm lock file.

* Resets package.json too.

* Fixes pnpm lockfile.
This commit is contained in:
Michael Novotny 2022-08-07 23:52:02 -05:00 committed by GitHub
parent 160da6b806
commit ab48f54786
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
23 changed files with 78 additions and 12 deletions

View file

@ -145,6 +145,30 @@
}
]
}
},
{
"files": [
"packages/eslint-plugin-next/**/*.js",
"test/unit/eslint-plugin-next/**/*.test.ts"
],
"extends": ["plugin:eslint-plugin/recommended"],
"parserOptions": {
"sourceType": "script"
},
"rules": {
"eslint-plugin/prefer-replace-text": "error",
"eslint-plugin/report-message-format": [
"error",
".+\\. See: https://nextjs.org/docs/messages/[a-z\\-]+$"
],
"eslint-plugin/require-meta-docs-description": [
"error",
{
"pattern": ".+"
}
],
"eslint-plugin/require-meta-docs-url": "error"
}
}
],
"rules": {

View file

@ -126,6 +126,7 @@
"escape-string-regexp": "2.0.0",
"eslint": "7.24.0",
"eslint-config-next": "workspace:*",
"eslint-plugin-eslint-plugin": "4.3.0",
"eslint-plugin-import": "2.22.1",
"eslint-plugin-jest": "24.3.5",
"eslint-plugin-react": "7.23.2",

View file

@ -9,6 +9,8 @@ module.exports = {
recommended: true,
url,
},
type: 'problem',
schema: [],
},
create: function (context) {
return {

View file

@ -9,6 +9,8 @@ module.exports = {
recommended: true,
url,
},
type: 'problem',
schema: [],
},
create: function (context) {
return {

View file

@ -8,6 +8,8 @@ module.exports = {
recommended: true,
url,
},
type: 'problem',
schema: [],
},
create: function (context) {
let nextScriptImportName = null

View file

@ -25,8 +25,9 @@ module.exports = {
recommended: true,
url,
},
type: 'problem',
schema: [],
},
schema: [],
create: function (context) {
return {
JSXOpeningElement(node) {

View file

@ -7,6 +7,8 @@ module.exports = {
recommended: true,
url,
},
type: 'problem',
schema: [],
},
create: function (context) {

View file

@ -11,6 +11,8 @@ module.exports = {
recommended: true,
url,
},
type: 'problem',
schema: [],
},
create: function (context) {
let scriptImportName = null

View file

@ -7,8 +7,9 @@ module.exports = {
recommended: true,
url,
},
type: 'problem',
schema: [],
},
schema: [],
create: function (context) {
return {
JSXOpeningElement(node) {

View file

@ -10,6 +10,8 @@ module.exports = {
recommended: true,
url,
},
type: 'problem',
schema: [],
},
create: function (context) {
return {

View file

@ -8,6 +8,8 @@ module.exports = {
recommended: true,
url,
},
type: 'problem',
schema: [],
},
create: function (context) {
let documentImportName

View file

@ -8,7 +8,8 @@ module.exports = {
recommended: true,
url,
},
fixable: 'code',
type: 'problem',
schema: [],
},
create: function (context) {
return {

View file

@ -9,6 +9,8 @@ module.exports = {
recommended: true,
url,
},
type: 'problem',
schema: [],
},
create: function (context) {
return {

View file

@ -30,7 +30,7 @@ module.exports = {
recommended: true,
url,
},
fixable: null, // or "code" or "whitespace"
type: 'problem',
schema: [
{
oneOf: [

View file

@ -8,7 +8,8 @@ module.exports = {
recommended: true,
url,
},
fixable: 'code',
type: 'problem',
schema: [],
},
create: function (context) {

View file

@ -10,6 +10,8 @@ module.exports = {
recommended: true,
url,
},
type: 'problem',
schema: [],
},
create: function (context) {
const paths = context.getFilename().split('pages')

View file

@ -8,6 +8,8 @@ module.exports = {
recommended: true,
url,
},
type: 'problem',
schema: [],
},
create: function (context) {
let isNextHead = null

View file

@ -9,7 +9,8 @@ module.exports = {
recommended: true,
url,
},
fixable: 'code',
type: 'problem',
schema: [],
},
create: function (context) {
return {
@ -44,5 +45,3 @@ module.exports = {
}
},
}
module.exports.schema = []

View file

@ -7,8 +7,9 @@ module.exports = {
recommended: true,
url,
},
type: 'problem',
schema: [],
},
schema: [],
create: function (context) {
return {
JSXOpeningElement(node) {

View file

@ -8,6 +8,8 @@ module.exports = {
recommended: true,
url,
},
type: 'problem',
schema: [],
},
create: function (context) {
let headFromNextDocument = false

View file

@ -39,14 +39,15 @@ function minDistance(a, b) {
return previousRow[previousRow.length - 1]
}
/* eslint-disable eslint-plugin/require-meta-docs-url */
module.exports = {
meta: {
docs: {
description: 'Prevent common typos in Next.js data fetching functions.',
category: 'Stylistic Issues',
recommended: true,
},
fixable: null,
type: 'problem',
schema: [],
},
create: function (context) {

View file

@ -72,7 +72,8 @@ module.exports = {
recommended: true,
url,
},
fixable: null,
type: 'problem',
schema: [],
},
create: function (context) {

View file

@ -89,6 +89,7 @@ importers:
escape-string-regexp: 2.0.0
eslint: 7.24.0
eslint-config-next: workspace:*
eslint-plugin-eslint-plugin: 4.3.0
eslint-plugin-import: 2.22.1
eslint-plugin-jest: 24.3.5
eslint-plugin-react: 7.23.2
@ -243,6 +244,7 @@ importers:
escape-string-regexp: 2.0.0
eslint: 7.24.0
eslint-config-next: link:packages/eslint-config-next
eslint-plugin-eslint-plugin: 4.3.0_eslint@7.24.0
eslint-plugin-import: 2.22.1_23iivq3ybsthf4qrv3kgatrvhe
eslint-plugin-jest: 24.3.5_lqson4bxnnkvr5juyhnlzmz4rq
eslint-plugin-react: 7.23.2_eslint@7.24.0
@ -10326,6 +10328,17 @@ packages:
- supports-color
dev: true
/eslint-plugin-eslint-plugin/4.3.0_eslint@7.24.0:
resolution: {integrity: sha512-0xZ++ilIpGY+gBwsaW/uIhG/Rrl/sltPCai3UUPzWbaOPud2tel9UCWj8sLTADNmVqBD+vcqLHzHY86q/b71yg==}
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
peerDependencies:
eslint: '>=6.0.0'
dependencies:
eslint: 7.24.0
eslint-utils: 3.0.0_eslint@7.24.0
estraverse: 5.3.0
dev: true
/eslint-plugin-import/2.22.1_23iivq3ybsthf4qrv3kgatrvhe:
resolution: {integrity: sha512-8K7JjINHOpH64ozkAhpT3sd+FswIZTfMZTjdx052pnWrgRCVfp8op9tbjpAk3DdUeI/Ba4C8OjdC0r90erHEOw==}
engines: {node: '>=4'}