eslint-plugin-nextjs 0.1.1 → 0.1.2
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/index.cjs +62 -71
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -34
- package/dist/index.d.ts +2 -34
- package/dist/index.js +60 -69
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
@@ -550,8 +550,8 @@ var noHeadImportInDocument = defineRule({
|
|
550
550
|
if (!document) {
|
551
551
|
return;
|
552
552
|
}
|
553
|
-
const { dir, name
|
554
|
-
if (
|
553
|
+
const { dir, name } = path4.parse(document);
|
554
|
+
if (name.startsWith("_document") || dir === "/_document" && name === "index") {
|
555
555
|
context.report({
|
556
556
|
message: `\`next/head\` should not be imported in \`pages${document}\`. Use \`<Head />\` from \`next/document\` instead. See: ${url12}`,
|
557
557
|
node
|
@@ -1030,8 +1030,8 @@ var noStyledJsxInDocument = defineRule({
|
|
1030
1030
|
if (!document) {
|
1031
1031
|
return;
|
1032
1032
|
}
|
1033
|
-
const { dir, name
|
1034
|
-
if (!(
|
1033
|
+
const { dir, name } = path8.parse(document);
|
1034
|
+
if (!(name.startsWith("_document") || dir === "/_document" && name === "index")) {
|
1035
1035
|
return;
|
1036
1036
|
}
|
1037
1037
|
if (node.name.name === "style" && node.attributes.find(
|
@@ -1165,17 +1165,17 @@ var minDistance = (a, b) => {
|
|
1165
1165
|
};
|
1166
1166
|
var noTypos = defineRule({
|
1167
1167
|
create: (context) => {
|
1168
|
-
const checkTypos = (node,
|
1169
|
-
if (NEXT_EXPORT_FUNCTIONS.includes(
|
1168
|
+
const checkTypos = (node, name) => {
|
1169
|
+
if (NEXT_EXPORT_FUNCTIONS.includes(name)) {
|
1170
1170
|
return;
|
1171
1171
|
}
|
1172
1172
|
const potentialTypos = NEXT_EXPORT_FUNCTIONS.map((o) => ({
|
1173
|
-
distance: minDistance(o,
|
1173
|
+
distance: minDistance(o, name) ?? Infinity,
|
1174
1174
|
option: o
|
1175
1175
|
})).filter(({ distance }) => distance <= THRESHOLD && distance > 0).sort((a, b) => a.distance - b.distance);
|
1176
1176
|
if (potentialTypos.length) {
|
1177
1177
|
context.report({
|
1178
|
-
message: `${
|
1178
|
+
message: `${name} may be a typo. Did you mean ${potentialTypos[0]?.option}?`,
|
1179
1179
|
node
|
1180
1180
|
});
|
1181
1181
|
}
|
@@ -1353,81 +1353,71 @@ var noUnwantedPolyfillio = defineRule({
|
|
1353
1353
|
});
|
1354
1354
|
|
1355
1355
|
// src/index.ts
|
1356
|
-
var name = "nextjs";
|
1357
1356
|
var plugin = {
|
1358
|
-
name,
|
1359
1357
|
rules: {
|
1360
|
-
|
1361
|
-
|
1362
|
-
|
1363
|
-
|
1364
|
-
|
1365
|
-
|
1366
|
-
|
1367
|
-
|
1368
|
-
|
1369
|
-
|
1370
|
-
|
1371
|
-
|
1372
|
-
|
1373
|
-
|
1374
|
-
|
1375
|
-
|
1376
|
-
|
1377
|
-
|
1378
|
-
|
1379
|
-
|
1380
|
-
|
1358
|
+
"google-font-display": googleFontDisplay,
|
1359
|
+
"google-font-preconnect": googleFontPreconnect,
|
1360
|
+
"inline-script-id": inlineScriptId,
|
1361
|
+
"next-script-for-ga": nextScriptForGa,
|
1362
|
+
"no-assign-module-variable": noAssignModuleVariable,
|
1363
|
+
"no-async-client-component": noAsyncClientComponent,
|
1364
|
+
"no-before-interactive-script-outside-document": noBeforeInteractiveScriptOutsideDocument,
|
1365
|
+
"no-css-tags": noCssTags,
|
1366
|
+
"no-document-import-in-page": noDocumentImportInPage,
|
1367
|
+
"no-duplicate-head": noDuplicateHead,
|
1368
|
+
"no-head-element": noHeadElement,
|
1369
|
+
"no-head-import-in-document": noHeadImportInDocument,
|
1370
|
+
"no-html-link-for-pages": noHtmlLinkForPages,
|
1371
|
+
"no-img-element": noImgElement,
|
1372
|
+
"no-page-custom-font": noPageCustomFont,
|
1373
|
+
"no-script-component-in-head": noScriptComponentInHead,
|
1374
|
+
"no-styled-jsx-in-document": noStyledJsxInDocument,
|
1375
|
+
"no-sync-scripts": noSyncScripts,
|
1376
|
+
"no-title-in-document-head": noTitleInDocumentHead,
|
1377
|
+
"no-typos": noTypos,
|
1378
|
+
"no-unwanted-polyfillio": noUnwantedPolyfillio
|
1381
1379
|
}
|
1382
1380
|
};
|
1383
1381
|
var recommendedRules = {
|
1384
1382
|
// warnings
|
1385
|
-
"
|
1386
|
-
"
|
1383
|
+
"google-font-display": "warn",
|
1384
|
+
"google-font-preconnect": "warn",
|
1387
1385
|
// errors
|
1388
|
-
"
|
1389
|
-
"
|
1390
|
-
"
|
1391
|
-
"
|
1392
|
-
"
|
1393
|
-
"
|
1394
|
-
"
|
1395
|
-
"
|
1396
|
-
"
|
1397
|
-
"
|
1398
|
-
"
|
1399
|
-
"
|
1400
|
-
"
|
1401
|
-
"
|
1402
|
-
"
|
1403
|
-
"
|
1404
|
-
"
|
1405
|
-
"
|
1406
|
-
"
|
1386
|
+
"inline-script-id": "error",
|
1387
|
+
"next-script-for-ga": "warn",
|
1388
|
+
"no-assign-module-variable": "error",
|
1389
|
+
"no-async-client-component": "warn",
|
1390
|
+
"no-before-interactive-script-outside-document": "warn",
|
1391
|
+
"no-css-tags": "warn",
|
1392
|
+
"no-document-import-in-page": "error",
|
1393
|
+
"no-duplicate-head": "error",
|
1394
|
+
"no-head-element": "warn",
|
1395
|
+
"no-head-import-in-document": "error",
|
1396
|
+
"no-html-link-for-pages": "warn",
|
1397
|
+
"no-img-element": "warn",
|
1398
|
+
"no-page-custom-font": "warn",
|
1399
|
+
"no-script-component-in-head": "error",
|
1400
|
+
"no-styled-jsx-in-document": "warn",
|
1401
|
+
"no-sync-scripts": "warn",
|
1402
|
+
"no-title-in-document-head": "warn",
|
1403
|
+
"no-typos": "warn",
|
1404
|
+
"no-unwanted-polyfillio": "warn"
|
1407
1405
|
};
|
1408
1406
|
var coreWebVitalsRules = {
|
1409
1407
|
...recommendedRules,
|
1410
|
-
"
|
1411
|
-
"
|
1408
|
+
"no-html-link-for-pages": "error",
|
1409
|
+
"no-sync-scripts": "error"
|
1412
1410
|
};
|
1413
|
-
var createRuleConfig = (
|
1411
|
+
var createRuleConfig = (rules2, isFlat = false) => {
|
1414
1412
|
return {
|
1415
|
-
plugins: isFlat ? {
|
1413
|
+
plugins: isFlat ? { nextjs: plugin } : ["nextjs"],
|
1416
1414
|
rules: rules2
|
1417
1415
|
};
|
1418
1416
|
};
|
1419
|
-
var recommendedFlatConfig = createRuleConfig(
|
1420
|
-
var recommendedLegacyConfig = createRuleConfig(
|
1421
|
-
var coreWebVitalsFlatConfig = createRuleConfig(
|
1422
|
-
|
1423
|
-
coreWebVitalsRules,
|
1424
|
-
true
|
1425
|
-
);
|
1426
|
-
var coreWebVitalsLegacyConfig = createRuleConfig(
|
1427
|
-
name,
|
1428
|
-
coreWebVitalsRules,
|
1429
|
-
false
|
1430
|
-
);
|
1417
|
+
var recommendedFlatConfig = createRuleConfig(recommendedRules, true);
|
1418
|
+
var recommendedLegacyConfig = createRuleConfig(recommendedRules, false);
|
1419
|
+
var coreWebVitalsFlatConfig = createRuleConfig(coreWebVitalsRules, true);
|
1420
|
+
var coreWebVitalsLegacyConfig = createRuleConfig(coreWebVitalsRules, false);
|
1431
1421
|
var index_default = {
|
1432
1422
|
...plugin,
|
1433
1423
|
configs: {
|
@@ -1447,7 +1437,8 @@ var index_default = {
|
|
1447
1437
|
* Flat config (ESLint v9+) with recommended rules
|
1448
1438
|
*/
|
1449
1439
|
"recommended/flat": recommendedFlatConfig
|
1450
|
-
}
|
1440
|
+
},
|
1441
|
+
name: "nextjs"
|
1451
1442
|
};
|
1452
1443
|
var rules = plugin.rules;
|
1453
1444
|
export {
|