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.cjs
CHANGED
@@ -6,8 +6,8 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
8
8
|
var __export = (target, all) => {
|
9
|
-
for (var
|
10
|
-
__defProp(target,
|
9
|
+
for (var name in all)
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
11
11
|
};
|
12
12
|
var __copyProps = (to, from, except, desc) => {
|
13
13
|
if (from && typeof from === "object" || typeof from === "function") {
|
@@ -587,8 +587,8 @@ var noHeadImportInDocument = defineRule({
|
|
587
587
|
if (!document) {
|
588
588
|
return;
|
589
589
|
}
|
590
|
-
const { dir, name
|
591
|
-
if (
|
590
|
+
const { dir, name } = path4.parse(document);
|
591
|
+
if (name.startsWith("_document") || dir === "/_document" && name === "index") {
|
592
592
|
context.report({
|
593
593
|
message: `\`next/head\` should not be imported in \`pages${document}\`. Use \`<Head />\` from \`next/document\` instead. See: ${url12}`,
|
594
594
|
node
|
@@ -1067,8 +1067,8 @@ var noStyledJsxInDocument = defineRule({
|
|
1067
1067
|
if (!document) {
|
1068
1068
|
return;
|
1069
1069
|
}
|
1070
|
-
const { dir, name
|
1071
|
-
if (!(
|
1070
|
+
const { dir, name } = path8.parse(document);
|
1071
|
+
if (!(name.startsWith("_document") || dir === "/_document" && name === "index")) {
|
1072
1072
|
return;
|
1073
1073
|
}
|
1074
1074
|
if (node.name.name === "style" && node.attributes.find(
|
@@ -1202,17 +1202,17 @@ var minDistance = (a, b) => {
|
|
1202
1202
|
};
|
1203
1203
|
var noTypos = defineRule({
|
1204
1204
|
create: (context) => {
|
1205
|
-
const checkTypos = (node,
|
1206
|
-
if (NEXT_EXPORT_FUNCTIONS.includes(
|
1205
|
+
const checkTypos = (node, name) => {
|
1206
|
+
if (NEXT_EXPORT_FUNCTIONS.includes(name)) {
|
1207
1207
|
return;
|
1208
1208
|
}
|
1209
1209
|
const potentialTypos = NEXT_EXPORT_FUNCTIONS.map((o) => ({
|
1210
|
-
distance: minDistance(o,
|
1210
|
+
distance: minDistance(o, name) ?? Infinity,
|
1211
1211
|
option: o
|
1212
1212
|
})).filter(({ distance }) => distance <= THRESHOLD && distance > 0).sort((a, b) => a.distance - b.distance);
|
1213
1213
|
if (potentialTypos.length) {
|
1214
1214
|
context.report({
|
1215
|
-
message: `${
|
1215
|
+
message: `${name} may be a typo. Did you mean ${potentialTypos[0]?.option}?`,
|
1216
1216
|
node
|
1217
1217
|
});
|
1218
1218
|
}
|
@@ -1390,81 +1390,71 @@ var noUnwantedPolyfillio = defineRule({
|
|
1390
1390
|
});
|
1391
1391
|
|
1392
1392
|
// src/index.ts
|
1393
|
-
var name = "nextjs";
|
1394
1393
|
var plugin = {
|
1395
|
-
name,
|
1396
1394
|
rules: {
|
1397
|
-
|
1398
|
-
|
1399
|
-
|
1400
|
-
|
1401
|
-
|
1402
|
-
|
1403
|
-
|
1404
|
-
|
1405
|
-
|
1406
|
-
|
1407
|
-
|
1408
|
-
|
1409
|
-
|
1410
|
-
|
1411
|
-
|
1412
|
-
|
1413
|
-
|
1414
|
-
|
1415
|
-
|
1416
|
-
|
1417
|
-
|
1395
|
+
"google-font-display": googleFontDisplay,
|
1396
|
+
"google-font-preconnect": googleFontPreconnect,
|
1397
|
+
"inline-script-id": inlineScriptId,
|
1398
|
+
"next-script-for-ga": nextScriptForGa,
|
1399
|
+
"no-assign-module-variable": noAssignModuleVariable,
|
1400
|
+
"no-async-client-component": noAsyncClientComponent,
|
1401
|
+
"no-before-interactive-script-outside-document": noBeforeInteractiveScriptOutsideDocument,
|
1402
|
+
"no-css-tags": noCssTags,
|
1403
|
+
"no-document-import-in-page": noDocumentImportInPage,
|
1404
|
+
"no-duplicate-head": noDuplicateHead,
|
1405
|
+
"no-head-element": noHeadElement,
|
1406
|
+
"no-head-import-in-document": noHeadImportInDocument,
|
1407
|
+
"no-html-link-for-pages": noHtmlLinkForPages,
|
1408
|
+
"no-img-element": noImgElement,
|
1409
|
+
"no-page-custom-font": noPageCustomFont,
|
1410
|
+
"no-script-component-in-head": noScriptComponentInHead,
|
1411
|
+
"no-styled-jsx-in-document": noStyledJsxInDocument,
|
1412
|
+
"no-sync-scripts": noSyncScripts,
|
1413
|
+
"no-title-in-document-head": noTitleInDocumentHead,
|
1414
|
+
"no-typos": noTypos,
|
1415
|
+
"no-unwanted-polyfillio": noUnwantedPolyfillio
|
1418
1416
|
}
|
1419
1417
|
};
|
1420
1418
|
var recommendedRules = {
|
1421
1419
|
// warnings
|
1422
|
-
"
|
1423
|
-
"
|
1420
|
+
"google-font-display": "warn",
|
1421
|
+
"google-font-preconnect": "warn",
|
1424
1422
|
// errors
|
1425
|
-
"
|
1426
|
-
"
|
1427
|
-
"
|
1428
|
-
"
|
1429
|
-
"
|
1430
|
-
"
|
1431
|
-
"
|
1432
|
-
"
|
1433
|
-
"
|
1434
|
-
"
|
1435
|
-
"
|
1436
|
-
"
|
1437
|
-
"
|
1438
|
-
"
|
1439
|
-
"
|
1440
|
-
"
|
1441
|
-
"
|
1442
|
-
"
|
1443
|
-
"
|
1423
|
+
"inline-script-id": "error",
|
1424
|
+
"next-script-for-ga": "warn",
|
1425
|
+
"no-assign-module-variable": "error",
|
1426
|
+
"no-async-client-component": "warn",
|
1427
|
+
"no-before-interactive-script-outside-document": "warn",
|
1428
|
+
"no-css-tags": "warn",
|
1429
|
+
"no-document-import-in-page": "error",
|
1430
|
+
"no-duplicate-head": "error",
|
1431
|
+
"no-head-element": "warn",
|
1432
|
+
"no-head-import-in-document": "error",
|
1433
|
+
"no-html-link-for-pages": "warn",
|
1434
|
+
"no-img-element": "warn",
|
1435
|
+
"no-page-custom-font": "warn",
|
1436
|
+
"no-script-component-in-head": "error",
|
1437
|
+
"no-styled-jsx-in-document": "warn",
|
1438
|
+
"no-sync-scripts": "warn",
|
1439
|
+
"no-title-in-document-head": "warn",
|
1440
|
+
"no-typos": "warn",
|
1441
|
+
"no-unwanted-polyfillio": "warn"
|
1444
1442
|
};
|
1445
1443
|
var coreWebVitalsRules = {
|
1446
1444
|
...recommendedRules,
|
1447
|
-
"
|
1448
|
-
"
|
1445
|
+
"no-html-link-for-pages": "error",
|
1446
|
+
"no-sync-scripts": "error"
|
1449
1447
|
};
|
1450
|
-
var createRuleConfig = (
|
1448
|
+
var createRuleConfig = (rules2, isFlat = false) => {
|
1451
1449
|
return {
|
1452
|
-
plugins: isFlat ? {
|
1450
|
+
plugins: isFlat ? { nextjs: plugin } : ["nextjs"],
|
1453
1451
|
rules: rules2
|
1454
1452
|
};
|
1455
1453
|
};
|
1456
|
-
var recommendedFlatConfig = createRuleConfig(
|
1457
|
-
var recommendedLegacyConfig = createRuleConfig(
|
1458
|
-
var coreWebVitalsFlatConfig = createRuleConfig(
|
1459
|
-
|
1460
|
-
coreWebVitalsRules,
|
1461
|
-
true
|
1462
|
-
);
|
1463
|
-
var coreWebVitalsLegacyConfig = createRuleConfig(
|
1464
|
-
name,
|
1465
|
-
coreWebVitalsRules,
|
1466
|
-
false
|
1467
|
-
);
|
1454
|
+
var recommendedFlatConfig = createRuleConfig(recommendedRules, true);
|
1455
|
+
var recommendedLegacyConfig = createRuleConfig(recommendedRules, false);
|
1456
|
+
var coreWebVitalsFlatConfig = createRuleConfig(coreWebVitalsRules, true);
|
1457
|
+
var coreWebVitalsLegacyConfig = createRuleConfig(coreWebVitalsRules, false);
|
1468
1458
|
var index_default = {
|
1469
1459
|
...plugin,
|
1470
1460
|
configs: {
|
@@ -1484,7 +1474,8 @@ var index_default = {
|
|
1484
1474
|
* Flat config (ESLint v9+) with recommended rules
|
1485
1475
|
*/
|
1486
1476
|
"recommended/flat": recommendedFlatConfig
|
1487
|
-
}
|
1477
|
+
},
|
1478
|
+
name: "nextjs"
|
1488
1479
|
};
|
1489
1480
|
var rules = plugin.rules;
|
1490
1481
|
// Annotate the CommonJS export names for ESM import in node:
|