Skip to content

Commit

Permalink
Adds eslint-plugin-eslint-plugin to ensure eslint-plugin-next rul…
Browse files Browse the repository at this point in the history
…es 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.
  • Loading branch information
manovotny committed Aug 8, 2022
1 parent 160da6b commit ab48f54
Show file tree
Hide file tree
Showing 23 changed files with 78 additions and 12 deletions.
24 changes: 24 additions & 0 deletions .eslintrc.json
Expand Up @@ -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": {
Expand Down
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions packages/eslint-plugin-next/lib/rules/google-font-display.js
Expand Up @@ -9,6 +9,8 @@ module.exports = {
recommended: true,
url,
},
type: 'problem',
schema: [],
},
create: function (context) {
return {
Expand Down
Expand Up @@ -9,6 +9,8 @@ module.exports = {
recommended: true,
url,
},
type: 'problem',
schema: [],
},
create: function (context) {
return {
Expand Down
2 changes: 2 additions & 0 deletions packages/eslint-plugin-next/lib/rules/inline-script-id.js
Expand Up @@ -8,6 +8,8 @@ module.exports = {
recommended: true,
url,
},
type: 'problem',
schema: [],
},
create: function (context) {
let nextScriptImportName = null
Expand Down
3 changes: 2 additions & 1 deletion packages/eslint-plugin-next/lib/rules/next-script-for-ga.js
Expand Up @@ -25,8 +25,9 @@ module.exports = {
recommended: true,
url,
},
type: 'problem',
schema: [],
},
schema: [],
create: function (context) {
return {
JSXOpeningElement(node) {
Expand Down
Expand Up @@ -7,6 +7,8 @@ module.exports = {
recommended: true,
url,
},
type: 'problem',
schema: [],
},

create: function (context) {
Expand Down
Expand Up @@ -11,6 +11,8 @@ module.exports = {
recommended: true,
url,
},
type: 'problem',
schema: [],
},
create: function (context) {
let scriptImportName = null
Expand Down
3 changes: 2 additions & 1 deletion packages/eslint-plugin-next/lib/rules/no-css-tags.js
Expand Up @@ -7,8 +7,9 @@ module.exports = {
recommended: true,
url,
},
type: 'problem',
schema: [],
},
schema: [],
create: function (context) {
return {
JSXOpeningElement(node) {
Expand Down
Expand Up @@ -10,6 +10,8 @@ module.exports = {
recommended: true,
url,
},
type: 'problem',
schema: [],
},
create: function (context) {
return {
Expand Down
2 changes: 2 additions & 0 deletions packages/eslint-plugin-next/lib/rules/no-duplicate-head.js
Expand Up @@ -8,6 +8,8 @@ module.exports = {
recommended: true,
url,
},
type: 'problem',
schema: [],
},
create: function (context) {
let documentImportName
Expand Down
3 changes: 2 additions & 1 deletion packages/eslint-plugin-next/lib/rules/no-head-element.js
Expand Up @@ -8,7 +8,8 @@ module.exports = {
recommended: true,
url,
},
fixable: 'code',
type: 'problem',
schema: [],
},
create: function (context) {
return {
Expand Down
Expand Up @@ -9,6 +9,8 @@ module.exports = {
recommended: true,
url,
},
type: 'problem',
schema: [],
},
create: function (context) {
return {
Expand Down
Expand Up @@ -30,7 +30,7 @@ module.exports = {
recommended: true,
url,
},
fixable: null, // or "code" or "whitespace"
type: 'problem',
schema: [
{
oneOf: [
Expand Down
3 changes: 2 additions & 1 deletion packages/eslint-plugin-next/lib/rules/no-img-element.js
Expand Up @@ -8,7 +8,8 @@ module.exports = {
recommended: true,
url,
},
fixable: 'code',
type: 'problem',
schema: [],
},

create: function (context) {
Expand Down
2 changes: 2 additions & 0 deletions packages/eslint-plugin-next/lib/rules/no-page-custom-font.js
Expand Up @@ -10,6 +10,8 @@ module.exports = {
recommended: true,
url,
},
type: 'problem',
schema: [],
},
create: function (context) {
const paths = context.getFilename().split('pages')
Expand Down
Expand Up @@ -8,6 +8,8 @@ module.exports = {
recommended: true,
url,
},
type: 'problem',
schema: [],
},
create: function (context) {
let isNextHead = null
Expand Down
Expand Up @@ -9,7 +9,8 @@ module.exports = {
recommended: true,
url,
},
fixable: 'code',
type: 'problem',
schema: [],
},
create: function (context) {
return {
Expand Down Expand Up @@ -44,5 +45,3 @@ module.exports = {
}
},
}

module.exports.schema = []
3 changes: 2 additions & 1 deletion packages/eslint-plugin-next/lib/rules/no-sync-scripts.js
Expand Up @@ -7,8 +7,9 @@ module.exports = {
recommended: true,
url,
},
type: 'problem',
schema: [],
},
schema: [],
create: function (context) {
return {
JSXOpeningElement(node) {
Expand Down
Expand Up @@ -8,6 +8,8 @@ module.exports = {
recommended: true,
url,
},
type: 'problem',
schema: [],
},
create: function (context) {
let headFromNextDocument = false
Expand Down
5 changes: 3 additions & 2 deletions packages/eslint-plugin-next/lib/rules/no-typos.js
Expand Up @@ -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) {
Expand Down
Expand Up @@ -72,7 +72,8 @@ module.exports = {
recommended: true,
url,
},
fixable: null,
type: 'problem',
schema: [],
},

create: function (context) {
Expand Down
13 changes: 13 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ab48f54

Please sign in to comment.