@neralabs/rerail-pack-next 0.1.0
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/LICENSE +202 -0
- package/NOTICE +7 -0
- package/README.md +37 -0
- package/licenses/next.js/LICENSE +21 -0
- package/licenses/next.js/UPSTREAM.md +216 -0
- package/pack.json +181 -0
- package/package.json +30 -0
- package/rules/next-google-font-preconnect.json +133 -0
- package/rules/next-inline-script-id.json +397 -0
- package/rules/next-next-script-for-ga.json +143 -0
- package/rules/next-no-assign-module-variable.json +60 -0
- package/rules/next-no-async-client-component.json +212 -0
- package/rules/next-no-before-interactive-script-outside-document.json +118 -0
- package/rules/next-no-css-tags.json +107 -0
- package/rules/next-no-document-import-in-page.json +61 -0
- package/rules/next-no-duplicate-head.json +187 -0
- package/rules/next-no-head-import-in-document.json +61 -0
- package/rules/next-no-img-element.json +231 -0
- package/rules/next-no-script-component-in-head.json +102 -0
- package/rules/next-no-styled-jsx-in-document.json +81 -0
- package/rules/next-no-sync-scripts.json +106 -0
- package/rules/next-no-title-in-document-head.json +186 -0
- package/rules/next-no-typos.json +97 -0
- package/rules/next-no-unwanted-polyfillio.json +191 -0
package/pack.json
ADDED
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
{
|
|
2
|
+
"format": "rerail.rule-pack/v1",
|
|
3
|
+
"id": "next",
|
|
4
|
+
"name": "Next.js",
|
|
5
|
+
"category": "framework",
|
|
6
|
+
"covers": "17 @next/eslint-plugin-next rules ported to Rerail, each scored against the plugin's own recorded findings on its rule tests.",
|
|
7
|
+
"reason": "matches Next.js",
|
|
8
|
+
"match": {
|
|
9
|
+
"any": [
|
|
10
|
+
{
|
|
11
|
+
"npmDependencies": [
|
|
12
|
+
"next"
|
|
13
|
+
]
|
|
14
|
+
}
|
|
15
|
+
]
|
|
16
|
+
},
|
|
17
|
+
"rules": [
|
|
18
|
+
{
|
|
19
|
+
"id": "next-no-img-element",
|
|
20
|
+
"document": "rules/next-no-img-element.json",
|
|
21
|
+
"title": "No img element",
|
|
22
|
+
"group": "Next.js",
|
|
23
|
+
"examples": {
|
|
24
|
+
"caught": {
|
|
25
|
+
"path": "app/page.tsx",
|
|
26
|
+
"text": "export default function Page() {\n return <img src=\"/hero.png\" alt=\"Hero\" />;\n}\n"
|
|
27
|
+
},
|
|
28
|
+
"passes": {
|
|
29
|
+
"path": "app/opengraph-image.tsx",
|
|
30
|
+
"text": "import { ImageResponse } from \"next/og\";\n\nexport default function OpengraphImage() {\n return new ImageResponse(<img src=\"https://example.com/hero.png\" alt=\"Hero\" />);\n}\n"
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"id": "next-no-sync-scripts",
|
|
36
|
+
"document": "rules/next-no-sync-scripts.json",
|
|
37
|
+
"title": "No sync scripts",
|
|
38
|
+
"group": "Next.js",
|
|
39
|
+
"examples": {
|
|
40
|
+
"caught": {
|
|
41
|
+
"path": "pages/index.tsx",
|
|
42
|
+
"text": "export default function Home() {\n return <script src=\"https://example.com/widget.js\" />;\n}\n"
|
|
43
|
+
},
|
|
44
|
+
"passes": {
|
|
45
|
+
"path": "pages/index.tsx",
|
|
46
|
+
"text": "export default function Home() {\n return <script src=\"https://example.com/widget.js\" async />;\n}\n"
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"id": "next-no-css-tags",
|
|
52
|
+
"document": "rules/next-no-css-tags.json",
|
|
53
|
+
"title": "No css tags",
|
|
54
|
+
"group": "Next.js"
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
"id": "next-google-font-preconnect",
|
|
58
|
+
"document": "rules/next-google-font-preconnect.json",
|
|
59
|
+
"title": "Google font preconnect",
|
|
60
|
+
"group": "Next.js"
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
"id": "next-next-script-for-ga",
|
|
64
|
+
"document": "rules/next-next-script-for-ga.json",
|
|
65
|
+
"title": "Next script for ga",
|
|
66
|
+
"group": "Next.js"
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
"id": "next-no-unwanted-polyfillio",
|
|
70
|
+
"document": "rules/next-no-unwanted-polyfillio.json",
|
|
71
|
+
"title": "No unwanted polyfillio",
|
|
72
|
+
"group": "Next.js"
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
"id": "next-no-assign-module-variable",
|
|
76
|
+
"document": "rules/next-no-assign-module-variable.json",
|
|
77
|
+
"title": "No assign module variable",
|
|
78
|
+
"group": "Next.js",
|
|
79
|
+
"examples": {
|
|
80
|
+
"caught": {
|
|
81
|
+
"path": "pages/index.tsx",
|
|
82
|
+
"text": "let module = { title: \"Home\" };\n\nexport default function Home() {\n return <h1>{module.title}</h1>;\n}\n"
|
|
83
|
+
},
|
|
84
|
+
"passes": {
|
|
85
|
+
"path": "pages/index.tsx",
|
|
86
|
+
"text": "const page = { title: \"Home\" };\n\nexport default function Home() {\n return <h1>{page.title}</h1>;\n}\n"
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
"id": "next-no-document-import-in-page",
|
|
92
|
+
"document": "rules/next-no-document-import-in-page.json",
|
|
93
|
+
"title": "No document import in page",
|
|
94
|
+
"group": "Next.js"
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
"id": "next-no-head-import-in-document",
|
|
98
|
+
"document": "rules/next-no-head-import-in-document.json",
|
|
99
|
+
"title": "No head import in document",
|
|
100
|
+
"group": "Next.js"
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
"id": "next-no-styled-jsx-in-document",
|
|
104
|
+
"document": "rules/next-no-styled-jsx-in-document.json",
|
|
105
|
+
"title": "No styled jsx in document",
|
|
106
|
+
"group": "Next.js",
|
|
107
|
+
"examples": {
|
|
108
|
+
"caught": {
|
|
109
|
+
"path": "pages/_document.tsx",
|
|
110
|
+
"text": "import { Html, Head, Main, NextScript } from \"next/document\";\n\nexport default function Document() {\n return (\n <Html>\n <Head />\n <body>\n <style jsx>{\"body { margin: 0; }\"}</style>\n <Main />\n <NextScript />\n </body>\n </Html>\n );\n}\n"
|
|
111
|
+
},
|
|
112
|
+
"passes": {
|
|
113
|
+
"path": "pages/_document.tsx",
|
|
114
|
+
"text": "import { Html, Head, Main, NextScript } from \"next/document\";\n\nexport default function Document() {\n return (\n <Html>\n <Head />\n <body>\n <style>{\"body { margin: 0; }\"}</style>\n <Main />\n <NextScript />\n </body>\n </Html>\n );\n}\n"
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
"id": "next-no-title-in-document-head",
|
|
120
|
+
"document": "rules/next-no-title-in-document-head.json",
|
|
121
|
+
"title": "No title in document head",
|
|
122
|
+
"group": "Next.js",
|
|
123
|
+
"examples": {
|
|
124
|
+
"caught": {
|
|
125
|
+
"path": "pages/_document.tsx",
|
|
126
|
+
"text": "import { Html, Head, Main, NextScript } from \"next/document\";\n\nexport default function Document() {\n return (\n <Html>\n <Head>\n <title>My site</title>\n </Head>\n <body>\n <Main />\n <NextScript />\n </body>\n </Html>\n );\n}\n"
|
|
127
|
+
},
|
|
128
|
+
"passes": {
|
|
129
|
+
"path": "pages/index.tsx",
|
|
130
|
+
"text": "import Head from \"next/head\";\n\nexport default function Home() {\n return (\n <Head>\n <title>My site</title>\n </Head>\n );\n}\n"
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
"id": "next-no-script-component-in-head",
|
|
136
|
+
"document": "rules/next-no-script-component-in-head.json",
|
|
137
|
+
"title": "No script component in head",
|
|
138
|
+
"group": "Next.js",
|
|
139
|
+
"examples": {
|
|
140
|
+
"caught": {
|
|
141
|
+
"path": "pages/index.tsx",
|
|
142
|
+
"text": "import Head from \"next/head\";\nimport Script from \"next/script\";\n\nexport default function Home() {\n return (\n <Head>\n <Script src=\"https://example.com/analytics.js\" />\n </Head>\n );\n}\n"
|
|
143
|
+
},
|
|
144
|
+
"passes": {
|
|
145
|
+
"path": "pages/index.tsx",
|
|
146
|
+
"text": "import Head from \"next/head\";\nimport Script from \"next/script\";\n\nexport default function Home() {\n return (\n <>\n <Head>\n <title>Home</title>\n </Head>\n <Script src=\"https://example.com/analytics.js\" />\n </>\n );\n}\n"
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
"id": "next-inline-script-id",
|
|
152
|
+
"document": "rules/next-inline-script-id.json",
|
|
153
|
+
"title": "Inline script id",
|
|
154
|
+
"group": "Next.js"
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
"id": "next-no-async-client-component",
|
|
158
|
+
"document": "rules/next-no-async-client-component.json",
|
|
159
|
+
"title": "No async client component",
|
|
160
|
+
"group": "Next.js"
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
"id": "next-no-before-interactive-script-outside-document",
|
|
164
|
+
"document": "rules/next-no-before-interactive-script-outside-document.json",
|
|
165
|
+
"title": "No before interactive script outside document",
|
|
166
|
+
"group": "Next.js"
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
"id": "next-no-duplicate-head",
|
|
170
|
+
"document": "rules/next-no-duplicate-head.json",
|
|
171
|
+
"title": "No duplicate head",
|
|
172
|
+
"group": "Next.js"
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
"id": "next-no-typos",
|
|
176
|
+
"document": "rules/next-no-typos.json",
|
|
177
|
+
"title": "No typos",
|
|
178
|
+
"group": "Next.js"
|
|
179
|
+
}
|
|
180
|
+
]
|
|
181
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@neralabs/rerail-pack-next",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Rerail rule pack: @next/eslint-plugin-next rules ported to Rerail code rules.",
|
|
5
|
+
"license": "Apache-2.0 AND MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/neralabs/rerail.git",
|
|
9
|
+
"directory": "packs/next"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"pack.json",
|
|
13
|
+
"rules",
|
|
14
|
+
"licenses",
|
|
15
|
+
"LICENSE",
|
|
16
|
+
"NOTICE",
|
|
17
|
+
"README.md"
|
|
18
|
+
],
|
|
19
|
+
"peerDependencies": {
|
|
20
|
+
"@neralabs/rerail": ">=0.1.0-0 <0.2.0"
|
|
21
|
+
},
|
|
22
|
+
"peerDependenciesMeta": {
|
|
23
|
+
"@neralabs/rerail": {
|
|
24
|
+
"optional": true
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"publishConfig": {
|
|
28
|
+
"access": "restricted"
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
{
|
|
2
|
+
"format": "rerail.policy/v1",
|
|
3
|
+
"id": "next-google-font-preconnect",
|
|
4
|
+
"revision": 1,
|
|
5
|
+
"mode": "steer",
|
|
6
|
+
"description": "@next/eslint-plugin-next 16.3.8 @next/next/google-font-preconnect: a <link> whose literal href starts with https://fonts.gstatic.com and whose rel is not the literal \"preconnect\".",
|
|
7
|
+
"scope": {
|
|
8
|
+
"include": [
|
|
9
|
+
"**/*.ts",
|
|
10
|
+
"**/*.mts",
|
|
11
|
+
"**/*.cts",
|
|
12
|
+
"**/*.tsx",
|
|
13
|
+
"**/*.js",
|
|
14
|
+
"**/*.jsx",
|
|
15
|
+
"**/*.mjs",
|
|
16
|
+
"**/*.cjs"
|
|
17
|
+
],
|
|
18
|
+
"exclude": []
|
|
19
|
+
},
|
|
20
|
+
"clauses": [
|
|
21
|
+
{
|
|
22
|
+
"id": "upstream",
|
|
23
|
+
"forbid": {
|
|
24
|
+
"ast": {
|
|
25
|
+
"language": "typescript",
|
|
26
|
+
"rule": {
|
|
27
|
+
"all": [
|
|
28
|
+
{
|
|
29
|
+
"any": [
|
|
30
|
+
{
|
|
31
|
+
"kind": "jsx_opening_element"
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"kind": "jsx_self_closing_element"
|
|
35
|
+
}
|
|
36
|
+
]
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"has": {
|
|
40
|
+
"field": "name",
|
|
41
|
+
"kind": "identifier",
|
|
42
|
+
"regex": "^link$"
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
"has": {
|
|
47
|
+
"kind": "jsx_attribute",
|
|
48
|
+
"all": [
|
|
49
|
+
{
|
|
50
|
+
"has": {
|
|
51
|
+
"kind": "property_identifier",
|
|
52
|
+
"regex": "^href$"
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"has": {
|
|
57
|
+
"any": [
|
|
58
|
+
{
|
|
59
|
+
"kind": "string",
|
|
60
|
+
"value": {
|
|
61
|
+
"startsWith": "https://fonts.gstatic.com"
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"kind": "jsx_expression",
|
|
66
|
+
"has": {
|
|
67
|
+
"kind": "string",
|
|
68
|
+
"value": {
|
|
69
|
+
"startsWith": "https://fonts.gstatic.com"
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
]
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
]
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"not": {
|
|
81
|
+
"has": {
|
|
82
|
+
"kind": "jsx_attribute",
|
|
83
|
+
"all": [
|
|
84
|
+
{
|
|
85
|
+
"has": {
|
|
86
|
+
"kind": "property_identifier",
|
|
87
|
+
"regex": "^rel$"
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
"has": {
|
|
92
|
+
"any": [
|
|
93
|
+
{
|
|
94
|
+
"kind": "string",
|
|
95
|
+
"value": {
|
|
96
|
+
"eq": "preconnect"
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
"kind": "jsx_expression",
|
|
101
|
+
"has": {
|
|
102
|
+
"kind": "string",
|
|
103
|
+
"value": {
|
|
104
|
+
"eq": "preconnect"
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
]
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
]
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
]
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
"violation": {
|
|
120
|
+
"anchor": "witness.span",
|
|
121
|
+
"code": "@next/next/google-font-preconnect",
|
|
122
|
+
"message": "`rel=\"preconnect\"` is missing from Google Font. See: https://nextjs.org/docs/messages/google-font-preconnect",
|
|
123
|
+
"suppress": {
|
|
124
|
+
"eslint": {
|
|
125
|
+
"rules": [
|
|
126
|
+
"@next/next/google-font-preconnect"
|
|
127
|
+
]
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
]
|
|
133
|
+
}
|