@next/eslint-plugin-next 14.3.0-canary.40 → 14.3.0-canary.43
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/rules/no-before-interactive-script-outside-document.js +2 -2
- package/dist/rules/no-document-import-in-page.js +1 -1
- package/dist/rules/no-duplicate-head.js +2 -2
- package/dist/rules/no-head-element.js +1 -1
- package/dist/rules/no-head-import-in-document.js +1 -1
- package/dist/rules/no-page-custom-font.js +3 -2
- package/dist/rules/no-styled-jsx-in-document.js +1 -1
- package/dist/rules/no-typos.js +1 -1
- package/dist/utils/get-root-dirs.js +1 -1
- package/package.json +2 -2
|
@@ -63,7 +63,7 @@ module.exports = (0, _definerule.defineRule)({
|
|
|
63
63
|
scriptImportName = node.local.name;
|
|
64
64
|
},
|
|
65
65
|
JSXOpeningElement: function JSXOpeningElement(node) {
|
|
66
|
-
var pathname = convertToCorrectSeparator(context.
|
|
66
|
+
var pathname = convertToCorrectSeparator(context.filename);
|
|
67
67
|
var isInAppDir = pathname.includes("".concat(_path.sep, "app").concat(_path.sep));
|
|
68
68
|
// This rule shouldn't fire in `app/`
|
|
69
69
|
if (isInAppDir) {
|
|
@@ -81,7 +81,7 @@ module.exports = (0, _definerule.defineRule)({
|
|
|
81
81
|
if (!strategy || !strategy.value || strategy.value.value !== 'beforeInteractive') {
|
|
82
82
|
return;
|
|
83
83
|
}
|
|
84
|
-
var document = context.
|
|
84
|
+
var document = context.filename.split('pages', 2)[1];
|
|
85
85
|
if (document && _path.parse(document).name.startsWith('_document')) {
|
|
86
86
|
return;
|
|
87
87
|
}
|
|
@@ -59,7 +59,7 @@ module.exports = (0, _definerule.defineRule)({
|
|
|
59
59
|
if (node.source.value !== 'next/document') {
|
|
60
60
|
return;
|
|
61
61
|
}
|
|
62
|
-
var paths = context.
|
|
62
|
+
var paths = context.filename.split('pages');
|
|
63
63
|
var page = paths[paths.length - 1];
|
|
64
64
|
if (!page || page.startsWith("".concat(_path.sep, "_document")) || page.startsWith("".concat(_path.posix.sep, "_document"))) {
|
|
65
65
|
return;
|
|
@@ -12,6 +12,7 @@ module.exports = (0, _definerule.defineRule)({
|
|
|
12
12
|
schema: []
|
|
13
13
|
},
|
|
14
14
|
create: function create(context) {
|
|
15
|
+
var sourceCode = context.sourceCode;
|
|
15
16
|
var documentImportName;
|
|
16
17
|
return {
|
|
17
18
|
ImportDeclaration: function ImportDeclaration(node) {
|
|
@@ -26,14 +27,13 @@ module.exports = (0, _definerule.defineRule)({
|
|
|
26
27
|
}
|
|
27
28
|
},
|
|
28
29
|
ReturnStatement: function ReturnStatement(node) {
|
|
29
|
-
var ancestors =
|
|
30
|
+
var ancestors = sourceCode.getAncestors(node);
|
|
30
31
|
var documentClass = ancestors.find(function(ancestorNode) {
|
|
31
32
|
return ancestorNode.type === 'ClassDeclaration' && ancestorNode.superClass && 'name' in ancestorNode.superClass && ancestorNode.superClass.name === documentImportName;
|
|
32
33
|
});
|
|
33
34
|
if (!documentClass) {
|
|
34
35
|
return;
|
|
35
36
|
}
|
|
36
|
-
// @ts-expect-error - `node.argument` could be a `JSXElement` which has property `children`
|
|
37
37
|
if (node.argument && 'children' in node.argument && node.argument.children) {
|
|
38
38
|
// @ts-expect-error - `node.argument` could be a `JSXElement` which has property `children`
|
|
39
39
|
var headComponents = node.argument.children.filter(function(childrenNode) {
|
|
@@ -16,7 +16,7 @@ module.exports = (0, _definerule.defineRule)({
|
|
|
16
16
|
create: function create(context) {
|
|
17
17
|
return {
|
|
18
18
|
JSXOpeningElement: function JSXOpeningElement(node) {
|
|
19
|
-
var paths = context.
|
|
19
|
+
var paths = context.filename;
|
|
20
20
|
var isInAppDir = function() {
|
|
21
21
|
return paths.includes("app".concat(path.sep)) || paths.includes("app".concat(path.posix.sep));
|
|
22
22
|
};
|
|
@@ -59,7 +59,7 @@ module.exports = (0, _definerule.defineRule)({
|
|
|
59
59
|
if (node.source.value !== 'next/head') {
|
|
60
60
|
return;
|
|
61
61
|
}
|
|
62
|
-
var document = context.
|
|
62
|
+
var document = context.filename.split('pages', 2)[1];
|
|
63
63
|
if (!document) {
|
|
64
64
|
return;
|
|
65
65
|
}
|
|
@@ -22,7 +22,8 @@ module.exports = (0, _definerule.defineRule)({
|
|
|
22
22
|
schema: []
|
|
23
23
|
},
|
|
24
24
|
create: function create(context) {
|
|
25
|
-
var
|
|
25
|
+
var sourceCode = context.sourceCode;
|
|
26
|
+
var paths = context.filename.split('pages');
|
|
26
27
|
var page = paths[paths.length - 1];
|
|
27
28
|
// outside of a file within `pages`, bail
|
|
28
29
|
if (!page) {
|
|
@@ -58,7 +59,7 @@ module.exports = (0, _definerule.defineRule)({
|
|
|
58
59
|
if (node.name.name !== 'link') {
|
|
59
60
|
return;
|
|
60
61
|
}
|
|
61
|
-
var ancestors =
|
|
62
|
+
var ancestors = sourceCode.getAncestors(node);
|
|
62
63
|
// if `export default <name>` is further down within the file after the
|
|
63
64
|
// currently traversed component, then `localDefaultExportName` will
|
|
64
65
|
// still be undefined
|
|
@@ -56,7 +56,7 @@ module.exports = (0, _definerule.defineRule)({
|
|
|
56
56
|
create: function create(context) {
|
|
57
57
|
return {
|
|
58
58
|
JSXOpeningElement: function JSXOpeningElement(node) {
|
|
59
|
-
var document = context.
|
|
59
|
+
var document = context.filename.split('pages', 2)[1];
|
|
60
60
|
if (!document) {
|
|
61
61
|
return;
|
|
62
62
|
}
|
package/dist/rules/no-typos.js
CHANGED
|
@@ -114,7 +114,7 @@ module.exports = (0, _definerule.defineRule)({
|
|
|
114
114
|
}
|
|
115
115
|
return {
|
|
116
116
|
ExportNamedDeclaration: function ExportNamedDeclaration(node) {
|
|
117
|
-
var page = context.
|
|
117
|
+
var page = context.filename.split('pages', 2)[1];
|
|
118
118
|
if (!page || _path.parse(page).dir.startsWith('/api')) {
|
|
119
119
|
return;
|
|
120
120
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@next/eslint-plugin-next",
|
|
3
|
-
"version": "14.3.0-canary.
|
|
3
|
+
"version": "14.3.0-canary.43",
|
|
4
4
|
"description": "ESLint plugin for Next.js.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"license": "MIT",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"glob": "10.3.10"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
|
-
"eslint": "
|
|
18
|
+
"eslint": "8.56.0"
|
|
19
19
|
},
|
|
20
20
|
"scripts": {
|
|
21
21
|
"build": "swc -d dist src",
|