create project
This commit is contained in:
26
kitabcitab/node_modules/next/dist/lib/eslint/customFormatter.d.ts
generated
vendored
Normal file
26
kitabcitab/node_modules/next/dist/lib/eslint/customFormatter.d.ts
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
export declare enum MessageSeverity {
|
||||
Warning = 1,
|
||||
Error = 2
|
||||
}
|
||||
interface LintMessage {
|
||||
ruleId: string | null;
|
||||
severity: 1 | 2;
|
||||
message: string;
|
||||
line: number;
|
||||
column: number;
|
||||
}
|
||||
export interface LintResult {
|
||||
filePath: string;
|
||||
messages: LintMessage[];
|
||||
errorCount: number;
|
||||
warningCount: number;
|
||||
output?: string;
|
||||
source?: string;
|
||||
}
|
||||
export declare function formatResults(baseDir: string, results: LintResult[], format: (r: LintResult[]) => string): {
|
||||
output: string;
|
||||
outputWithMessages: string;
|
||||
totalNextPluginErrorCount: number;
|
||||
totalNextPluginWarningCount: number;
|
||||
};
|
||||
export {};
|
||||
84
kitabcitab/node_modules/next/dist/lib/eslint/customFormatter.js
generated
vendored
Normal file
84
kitabcitab/node_modules/next/dist/lib/eslint/customFormatter.js
generated
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.formatResults = formatResults;
|
||||
exports.MessageSeverity = void 0;
|
||||
var _chalk = _interopRequireDefault(require("next/dist/compiled/chalk"));
|
||||
var _path = _interopRequireDefault(require("path"));
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {
|
||||
default: obj
|
||||
};
|
||||
}
|
||||
var MessageSeverity;
|
||||
exports.MessageSeverity = MessageSeverity;
|
||||
(function(MessageSeverity) {
|
||||
MessageSeverity[MessageSeverity["Warning"] = 1] = "Warning";
|
||||
MessageSeverity[MessageSeverity["Error"] = 2] = "Error";
|
||||
})(MessageSeverity || (exports.MessageSeverity = MessageSeverity = {}));
|
||||
function pluginCount(messages) {
|
||||
let nextPluginWarningCount = 0;
|
||||
let nextPluginErrorCount = 0;
|
||||
for(let i = 0; i < messages.length; i++){
|
||||
const { severity , ruleId } = messages[i];
|
||||
if (ruleId == null ? void 0 : ruleId.includes("@next/next")) {
|
||||
if (severity === 1) {
|
||||
nextPluginWarningCount += 1;
|
||||
} else {
|
||||
nextPluginErrorCount += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return {
|
||||
nextPluginErrorCount,
|
||||
nextPluginWarningCount
|
||||
};
|
||||
}
|
||||
function formatMessage(dir, messages, filePath) {
|
||||
let fileName = _path.default.posix.normalize(_path.default.relative(dir, filePath).replace(/\\/g, "/"));
|
||||
if (!fileName.startsWith(".")) {
|
||||
fileName = "./" + fileName;
|
||||
}
|
||||
let output = "\n" + _chalk.default.cyan(fileName);
|
||||
for(let i = 0; i < messages.length; i++){
|
||||
const { message , severity , line , column , ruleId } = messages[i];
|
||||
output = output + "\n";
|
||||
if (line && column) {
|
||||
output = output + _chalk.default.yellow(line.toString()) + ":" + _chalk.default.yellow(column.toString()) + " ";
|
||||
}
|
||||
if (severity === 1) {
|
||||
output += _chalk.default.yellow.bold("Warning") + ": ";
|
||||
} else {
|
||||
output += _chalk.default.red.bold("Error") + ": ";
|
||||
}
|
||||
output += message;
|
||||
if (ruleId) {
|
||||
output += " " + _chalk.default.gray.bold(ruleId);
|
||||
}
|
||||
}
|
||||
return output;
|
||||
}
|
||||
function formatResults(baseDir, results, format) {
|
||||
let totalNextPluginErrorCount = 0;
|
||||
let totalNextPluginWarningCount = 0;
|
||||
let resultsWithMessages = results.filter(({ messages })=>{
|
||||
return messages == null ? void 0 : messages.length;
|
||||
});
|
||||
// Track number of Next.js plugin errors and warnings
|
||||
resultsWithMessages.forEach(({ messages })=>{
|
||||
const res = pluginCount(messages);
|
||||
totalNextPluginErrorCount += res.nextPluginErrorCount;
|
||||
totalNextPluginWarningCount += res.nextPluginWarningCount;
|
||||
});
|
||||
// Use user defined formatter or Next.js's built-in custom formatter
|
||||
const output = format ? format(resultsWithMessages) : resultsWithMessages.map(({ messages , filePath })=>formatMessage(baseDir, messages, filePath)).join("\n");
|
||||
return {
|
||||
output: output,
|
||||
outputWithMessages: resultsWithMessages.length > 0 ? output + `\n\n${_chalk.default.cyan("info")} - Need to disable some ESLint rules? Learn more here: https://nextjs.org/docs/basic-features/eslint#disabling-rules` : "",
|
||||
totalNextPluginErrorCount,
|
||||
totalNextPluginWarningCount
|
||||
};
|
||||
}
|
||||
|
||||
//# sourceMappingURL=customFormatter.js.map
|
||||
1
kitabcitab/node_modules/next/dist/lib/eslint/customFormatter.js.map
generated
vendored
Normal file
1
kitabcitab/node_modules/next/dist/lib/eslint/customFormatter.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../lib/eslint/customFormatter.ts"],"names":["formatResults","MessageSeverity","Warning","Error","pluginCount","messages","nextPluginWarningCount","nextPluginErrorCount","i","length","severity","ruleId","includes","formatMessage","dir","filePath","fileName","path","posix","normalize","relative","replace","startsWith","output","chalk","cyan","message","line","column","yellow","toString","bold","red","gray","baseDir","results","format","totalNextPluginErrorCount","totalNextPluginWarningCount","resultsWithMessages","filter","forEach","res","map","join","outputWithMessages"],"mappings":"AAAA;;;;QAgGgBA,aAAa,GAAbA,aAAa;;AAhGX,IAAA,MAA0B,kCAA1B,0BAA0B,EAAA;AAC3B,IAAA,KAAM,kCAAN,MAAM,EAAA;;;;;;IAGhB,eAGN;;UAHWC,eAAe;IAAfA,eAAe,CAAfA,eAAe,CACzBC,SAAO,IAAG,CAAC,IAAXA,SAAO;IADGD,eAAe,CAAfA,eAAe,CAEzBE,OAAK,IAAG,CAAC,IAATA,OAAK;GAFKF,eAAe,+BAAfA,eAAe;AAsB3B,SAASG,WAAW,CAACC,QAAuB,EAG1C;IACA,IAAIC,sBAAsB,GAAG,CAAC;IAC9B,IAAIC,oBAAoB,GAAG,CAAC;IAE5B,IAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGH,QAAQ,CAACI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C,CAAC,EAAEtC,QAAQ,CAAA,EAAEU,QAAQ,CAAA,EAAE,GAC1BF,aAAa,CAACqB,OAAO,EAAE7B,QAAQ,EAAEU,QAAQ,CAAC,CAC3C,CACA6B,IAAI,CAAC,IAAI,CAAC;IAEjB,OAAO;QACLrB,MAAM,EAAEA,MAAM;QACdsB,kBAAkB,EAChBN,mBAAmB,CAAC9B,MAAM,GAAG,CAAC,GAC1Bc,MAAM,GACN,CAAC,IAAI,EAAEC,MAAK,QAAA,CAACC,IAAI,CACf,MAAM,CACP,CAAC,qHAAqH,CAAC,GACxH,EAAE;QACRY,yBAAyB;QACzBC,2BAA2B;KAC5B,CAAA;CACF"}
|
||||
9
kitabcitab/node_modules/next/dist/lib/eslint/hasEslintConfiguration.d.ts
generated
vendored
Normal file
9
kitabcitab/node_modules/next/dist/lib/eslint/hasEslintConfiguration.d.ts
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
export declare type ConfigAvailable = {
|
||||
exists: boolean;
|
||||
emptyEslintrc?: boolean;
|
||||
emptyPkgJsonConfig?: boolean;
|
||||
firstTimeSetup?: true;
|
||||
};
|
||||
export declare function hasEslintConfiguration(eslintrcFile: string | null, packageJsonConfig: {
|
||||
eslintConfig: any;
|
||||
} | null): Promise<ConfigAvailable>;
|
||||
42
kitabcitab/node_modules/next/dist/lib/eslint/hasEslintConfiguration.js
generated
vendored
Normal file
42
kitabcitab/node_modules/next/dist/lib/eslint/hasEslintConfiguration.js
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.hasEslintConfiguration = hasEslintConfiguration;
|
||||
var _fs = require("fs");
|
||||
async function hasEslintConfiguration(eslintrcFile, packageJsonConfig) {
|
||||
const configObject = {
|
||||
exists: false,
|
||||
emptyEslintrc: false,
|
||||
emptyPkgJsonConfig: false
|
||||
};
|
||||
if (eslintrcFile) {
|
||||
const content = await _fs.promises.readFile(eslintrcFile, {
|
||||
encoding: "utf8"
|
||||
}).then((txt)=>txt.trim().replace(/\n/g, ""), ()=>null);
|
||||
if (content === "" || content === "{}" || content === "---" || content === "module.exports = {}") {
|
||||
return {
|
||||
...configObject,
|
||||
emptyEslintrc: true
|
||||
};
|
||||
}
|
||||
return {
|
||||
...configObject,
|
||||
exists: true
|
||||
};
|
||||
} else if (packageJsonConfig == null ? void 0 : packageJsonConfig.eslintConfig) {
|
||||
if (Object.keys(packageJsonConfig == null ? void 0 : packageJsonConfig.eslintConfig).length) {
|
||||
return {
|
||||
...configObject,
|
||||
exists: true
|
||||
};
|
||||
}
|
||||
return {
|
||||
...configObject,
|
||||
emptyPkgJsonConfig: true
|
||||
};
|
||||
}
|
||||
return configObject;
|
||||
}
|
||||
|
||||
//# sourceMappingURL=hasEslintConfiguration.js.map
|
||||
1
kitabcitab/node_modules/next/dist/lib/eslint/hasEslintConfiguration.js.map
generated
vendored
Normal file
1
kitabcitab/node_modules/next/dist/lib/eslint/hasEslintConfiguration.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../lib/eslint/hasEslintConfiguration.ts"],"names":["hasEslintConfiguration","eslintrcFile","packageJsonConfig","configObject","exists","emptyEslintrc","emptyPkgJsonConfig","content","fs","readFile","encoding","then","txt","trim","replace","eslintConfig","Object","keys","length"],"mappings":"AAAA;;;;QASsBA,sBAAsB,GAAtBA,sBAAsB;AATb,IAAA,GAAI,WAAJ,IAAI,CAAA;AAS5B,eAAeA,sBAAsB,CAC1CC,YAA2B,EAC3BC,iBAA+C,EACrB;IAC1B,MAAMC,YAAY,GAAG;QACnBC,MAAM,EAAE,KAAK;QACbC,aAAa,EAAE,KAAK;QACpBC,kBAAkB,EAAE,KAAK;KAC1B;IAED,IAAIL,YAAY,EAAE;QAChB,MAAMM,OAAO,GAAG,MAAMC,GAAE,SAAA,CAACC,QAAQ,CAACR,YAAY,EAAE;YAAES,QAAQ,EAAE,MAAM;SAAE,CAAC,CAACC,IAAI,CACxE,CAACC,GAAG,GAAKA,GAAG,CAACC,IAAI,EAAE,CAACC,OAAO,QAAQ,EAAE,CAAC,EACtC,IAAM,IAAI,CACX;QAED,IACEP,OAAO,KAAK,EAAE,IACdA,OAAO,KAAK,IAAI,IAChBA,OAAO,KAAK,KAAK,IACjBA,OAAO,KAAK,qBAAqB,EACjC;YACA,OAAO;gBAAE,GAAGJ,YAAY;gBAAEE,aAAa,EAAE,IAAI;aAAE,CAAA;SAChD;QACD,OAAO;YAAE,GAAGF,YAAY;YAAEC,MAAM,EAAE,IAAI;SAAE,CAAA;KACzC,MAAM,IAAIF,iBAAiB,QAAc,GAA/BA,KAAAA,CAA+B,GAA/BA,iBAAiB,CAAEa,YAAY,EAAE;QAC1C,IAAIC,MAAM,CAACC,IAAI,CAACf,iBAAiB,QAAc,GAA/BA,KAAAA,CAA+B,GAA/BA,iBAAiB,CAAEa,YAAY,CAAC,CAACG,MAAM,EAAE;YACvD,OAAO;gBAAE,GAAGf,YAAY;gBAAEC,MAAM,EAAE,IAAI;aAAE,CAAA;SACzC;QACD,OAAO;YAAE,GAAGD,YAAY;YAAEG,kBAAkB,EAAE,IAAI;SAAE,CAAA;KACrD;IACD,OAAOH,YAAY,CAAA;CACpB"}
|
||||
23
kitabcitab/node_modules/next/dist/lib/eslint/runLintCheck.d.ts
generated
vendored
Normal file
23
kitabcitab/node_modules/next/dist/lib/eslint/runLintCheck.d.ts
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
import { EventLintCheckCompleted } from '../../telemetry/events/build';
|
||||
declare function lint(baseDir: string, lintDirs: string[], eslintrcFile: string | null, pkgJsonPath: string | null, hasAppDir: boolean, { lintDuringBuild, eslintOptions, reportErrorsOnly, maxWarnings, formatter, outputFile, }: {
|
||||
lintDuringBuild: boolean;
|
||||
eslintOptions: any;
|
||||
reportErrorsOnly: boolean;
|
||||
maxWarnings: number;
|
||||
formatter: string | null;
|
||||
outputFile: string | null;
|
||||
}): Promise<string | null | {
|
||||
output: string | null;
|
||||
isError: boolean;
|
||||
eventInfo: EventLintCheckCompleted;
|
||||
}>;
|
||||
export declare function runLintCheck(baseDir: string, lintDirs: string[], hasAppDir: boolean, opts: {
|
||||
lintDuringBuild?: boolean;
|
||||
eslintOptions?: any;
|
||||
reportErrorsOnly?: boolean;
|
||||
maxWarnings?: number;
|
||||
formatter?: string | null;
|
||||
outputFile?: string | null;
|
||||
strict?: boolean;
|
||||
}): ReturnType<typeof lint>;
|
||||
export {};
|
||||
295
kitabcitab/node_modules/next/dist/lib/eslint/runLintCheck.js
generated
vendored
Normal file
295
kitabcitab/node_modules/next/dist/lib/eslint/runLintCheck.js
generated
vendored
Normal file
@@ -0,0 +1,295 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.runLintCheck = runLintCheck;
|
||||
var _fs = require("fs");
|
||||
var _chalk = _interopRequireDefault(require("next/dist/compiled/chalk"));
|
||||
var _path = _interopRequireDefault(require("path"));
|
||||
var _findUp = _interopRequireDefault(require("next/dist/compiled/find-up"));
|
||||
var _semver = _interopRequireDefault(require("next/dist/compiled/semver"));
|
||||
var CommentJson = _interopRequireWildcard(require("next/dist/compiled/comment-json"));
|
||||
var _customFormatter = require("./customFormatter");
|
||||
var _writeDefaultConfig = require("./writeDefaultConfig");
|
||||
var _hasEslintConfiguration = require("./hasEslintConfiguration");
|
||||
var _writeOutputFile = require("./writeOutputFile");
|
||||
var _constants = require("../constants");
|
||||
var _findPagesDir = require("../find-pages-dir");
|
||||
var _installDependencies = require("../install-dependencies");
|
||||
var _hasNecessaryDependencies = require("../has-necessary-dependencies");
|
||||
var Log = _interopRequireWildcard(require("../../build/output/log"));
|
||||
var _isError = _interopRequireWildcard(require("../is-error"));
|
||||
var _getPkgManager = require("../helpers/get-pkg-manager");
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {
|
||||
default: obj
|
||||
};
|
||||
}
|
||||
function _getRequireWildcardCache() {
|
||||
if (typeof WeakMap !== "function") return null;
|
||||
var cache = new WeakMap();
|
||||
_getRequireWildcardCache = function() {
|
||||
return cache;
|
||||
};
|
||||
return cache;
|
||||
}
|
||||
function _interopRequireWildcard(obj) {
|
||||
if (obj && obj.__esModule) {
|
||||
return obj;
|
||||
}
|
||||
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
||||
return {
|
||||
default: obj
|
||||
};
|
||||
}
|
||||
var cache = _getRequireWildcardCache();
|
||||
if (cache && cache.has(obj)) {
|
||||
return cache.get(obj);
|
||||
}
|
||||
var newObj = {};
|
||||
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
||||
for(var key in obj){
|
||||
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
||||
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
||||
if (desc && (desc.get || desc.set)) {
|
||||
Object.defineProperty(newObj, key, desc);
|
||||
} else {
|
||||
newObj[key] = obj[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
newObj.default = obj;
|
||||
if (cache) {
|
||||
cache.set(obj, newObj);
|
||||
}
|
||||
return newObj;
|
||||
}
|
||||
// 0 is off, 1 is warn, 2 is error. See https://eslint.org/docs/user-guide/configuring/rules#configuring-rules
|
||||
const VALID_SEVERITY = [
|
||||
"off",
|
||||
"warn",
|
||||
"error"
|
||||
];
|
||||
function isValidSeverity(severity) {
|
||||
return VALID_SEVERITY.includes(severity);
|
||||
}
|
||||
const requiredPackages = [
|
||||
{
|
||||
file: "eslint",
|
||||
pkg: "eslint",
|
||||
exportsRestrict: false
|
||||
},
|
||||
{
|
||||
file: "eslint-config-next",
|
||||
pkg: "eslint-config-next",
|
||||
exportsRestrict: false
|
||||
},
|
||||
];
|
||||
async function cliPrompt() {
|
||||
console.log(_chalk.default.bold(`${_chalk.default.cyan("?")} How would you like to configure ESLint? https://nextjs.org/docs/basic-features/eslint`));
|
||||
try {
|
||||
const cliSelect = (await Promise.resolve(require("next/dist/compiled/cli-select"))).default;
|
||||
const { value } = await cliSelect({
|
||||
values: _constants.ESLINT_PROMPT_VALUES,
|
||||
valueRenderer: ({ title , recommended }, selected)=>{
|
||||
const name = selected ? _chalk.default.bold.underline.cyan(title) : title;
|
||||
return name + (recommended ? _chalk.default.bold.yellow(" (recommended)") : "");
|
||||
},
|
||||
selected: _chalk.default.cyan("\u276F "),
|
||||
unselected: " "
|
||||
});
|
||||
return {
|
||||
config: value == null ? void 0 : value.config
|
||||
};
|
||||
} catch {
|
||||
return {
|
||||
config: null
|
||||
};
|
||||
}
|
||||
}
|
||||
async function lint(baseDir, lintDirs, eslintrcFile, pkgJsonPath, hasAppDir, { lintDuringBuild =false , eslintOptions =null , reportErrorsOnly =false , maxWarnings =-1 , formatter =null , outputFile =null }) {
|
||||
try {
|
||||
var ref, ref1;
|
||||
// Load ESLint after we're sure it exists:
|
||||
const deps = await (0, _hasNecessaryDependencies).hasNecessaryDependencies(baseDir, requiredPackages);
|
||||
const packageManager = (0, _getPkgManager).getPkgManager(baseDir);
|
||||
if (deps.missing.some((dep)=>dep.pkg === "eslint")) {
|
||||
Log.error(`ESLint must be installed${lintDuringBuild ? " in order to run during builds:" : ":"} ${_chalk.default.bold.cyan((packageManager === "yarn" ? "yarn add --dev" : packageManager === "pnpm" ? "pnpm install --save-dev" : "npm install --save-dev") + " eslint")}`);
|
||||
return null;
|
||||
}
|
||||
const mod = await Promise.resolve(require(deps.resolved.get("eslint")));
|
||||
const { ESLint } = mod;
|
||||
let eslintVersion = (ESLint == null ? void 0 : ESLint.version) ?? (mod == null ? void 0 : (ref = mod.CLIEngine) == null ? void 0 : ref.version);
|
||||
if (!eslintVersion || _semver.default.lt(eslintVersion, "7.0.0")) {
|
||||
return `${_chalk.default.red("error")} - Your project has an older version of ESLint installed${eslintVersion ? " (" + eslintVersion + ")" : ""}. Please upgrade to ESLint version 7 or above`;
|
||||
}
|
||||
let options = {
|
||||
useEslintrc: true,
|
||||
baseConfig: {},
|
||||
errorOnUnmatchedPattern: false,
|
||||
extensions: [
|
||||
".js",
|
||||
".jsx",
|
||||
".ts",
|
||||
".tsx"
|
||||
],
|
||||
cache: true,
|
||||
...eslintOptions
|
||||
};
|
||||
let eslint = new ESLint(options);
|
||||
let nextEslintPluginIsEnabled = false;
|
||||
const nextRulesEnabled = new Map();
|
||||
for (const configFile of [
|
||||
eslintrcFile,
|
||||
pkgJsonPath
|
||||
]){
|
||||
var ref2;
|
||||
if (!configFile) continue;
|
||||
const completeConfig = await eslint.calculateConfigForFile(configFile);
|
||||
if ((ref2 = completeConfig.plugins) == null ? void 0 : ref2.includes("@next/next")) {
|
||||
nextEslintPluginIsEnabled = true;
|
||||
for (const [name, [severity]] of Object.entries(completeConfig.rules)){
|
||||
if (!name.startsWith("@next/next/")) {
|
||||
continue;
|
||||
}
|
||||
if (typeof severity === "number" && severity >= 0 && severity < VALID_SEVERITY.length) {
|
||||
nextRulesEnabled.set(name, VALID_SEVERITY[severity]);
|
||||
} else if (typeof severity === "string" && isValidSeverity(severity)) {
|
||||
nextRulesEnabled.set(name, severity);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
const pagesDir = (0, _findPagesDir).findPagesDir(baseDir, hasAppDir).pagesDir;
|
||||
const pagesDirRules = pagesDir ? [
|
||||
"@next/next/no-html-link-for-pages"
|
||||
] : [];
|
||||
if (nextEslintPluginIsEnabled) {
|
||||
let updatedPagesDir = false;
|
||||
for (const rule of pagesDirRules){
|
||||
var ref3, ref4;
|
||||
if (!((ref3 = options.baseConfig.rules) == null ? void 0 : ref3[rule]) && !((ref4 = options.baseConfig.rules) == null ? void 0 : ref4[rule.replace("@next/next", "@next/babel-plugin-next")])) {
|
||||
if (!options.baseConfig.rules) {
|
||||
options.baseConfig.rules = {};
|
||||
}
|
||||
options.baseConfig.rules[rule] = [
|
||||
1,
|
||||
pagesDir
|
||||
];
|
||||
updatedPagesDir = true;
|
||||
}
|
||||
}
|
||||
if (updatedPagesDir) {
|
||||
eslint = new ESLint(options);
|
||||
}
|
||||
} else {
|
||||
Log.warn("The Next.js plugin was not detected in your ESLint configuration. See https://nextjs.org/docs/basic-features/eslint#migrating-existing-config");
|
||||
}
|
||||
const lintStart = process.hrtime();
|
||||
let results = await eslint.lintFiles(lintDirs);
|
||||
let selectedFormatter = null;
|
||||
if (options.fix) await ESLint.outputFixes(results);
|
||||
if (reportErrorsOnly) results = await ESLint.getErrorResults(results) // Only return errors if --quiet flag is used
|
||||
;
|
||||
if (formatter) selectedFormatter = await eslint.loadFormatter(formatter);
|
||||
const formattedResult = (0, _customFormatter).formatResults(baseDir, results, selectedFormatter == null ? void 0 : selectedFormatter.format);
|
||||
const lintEnd = process.hrtime(lintStart);
|
||||
const totalWarnings = results.reduce((sum, file)=>sum + file.warningCount, 0);
|
||||
if (outputFile) await (0, _writeOutputFile).writeOutputFile(outputFile, formattedResult.output);
|
||||
return {
|
||||
output: formattedResult.outputWithMessages,
|
||||
isError: ((ref1 = ESLint.getErrorResults(results)) == null ? void 0 : ref1.length) > 0 || maxWarnings >= 0 && totalWarnings > maxWarnings,
|
||||
eventInfo: {
|
||||
durationInSeconds: lintEnd[0],
|
||||
eslintVersion: eslintVersion,
|
||||
lintedFilesCount: results.length,
|
||||
lintFix: !!options.fix,
|
||||
nextEslintPluginVersion: nextEslintPluginIsEnabled && deps.resolved.has("eslint-config-next") ? require(_path.default.join(_path.default.dirname(deps.resolved.get("eslint-config-next")), "package.json")).version : null,
|
||||
nextEslintPluginErrorsCount: formattedResult.totalNextPluginErrorCount,
|
||||
nextEslintPluginWarningsCount: formattedResult.totalNextPluginWarningCount,
|
||||
nextRulesEnabled: Object.fromEntries(nextRulesEnabled)
|
||||
}
|
||||
};
|
||||
} catch (err) {
|
||||
if (lintDuringBuild) {
|
||||
Log.error(`ESLint: ${(0, _isError).default(err) && err.message ? err.message.replace(/\n/g, " ") : err}`);
|
||||
return null;
|
||||
} else {
|
||||
throw (0, _isError).getProperError(err);
|
||||
}
|
||||
}
|
||||
}
|
||||
async function runLintCheck(baseDir, lintDirs, hasAppDir, opts) {
|
||||
const { lintDuringBuild =false , eslintOptions =null , reportErrorsOnly =false , maxWarnings =-1 , formatter =null , outputFile =null , strict =false , } = opts;
|
||||
try {
|
||||
// Find user's .eslintrc file
|
||||
// See: https://eslint.org/docs/user-guide/configuring/configuration-files#configuration-file-formats
|
||||
const eslintrcFile = await (0, _findUp).default([
|
||||
".eslintrc.js",
|
||||
".eslintrc.cjs",
|
||||
".eslintrc.yaml",
|
||||
".eslintrc.yml",
|
||||
".eslintrc.json",
|
||||
".eslintrc",
|
||||
], {
|
||||
cwd: baseDir
|
||||
}) ?? null;
|
||||
const pkgJsonPath = await (0, _findUp).default("package.json", {
|
||||
cwd: baseDir
|
||||
}) ?? null;
|
||||
let packageJsonConfig = null;
|
||||
if (pkgJsonPath) {
|
||||
const pkgJsonContent = await _fs.promises.readFile(pkgJsonPath, {
|
||||
encoding: "utf8"
|
||||
});
|
||||
packageJsonConfig = CommentJson.parse(pkgJsonContent);
|
||||
}
|
||||
const config = await (0, _hasEslintConfiguration).hasEslintConfiguration(eslintrcFile, packageJsonConfig);
|
||||
let deps;
|
||||
if (config.exists) {
|
||||
// Run if ESLint config exists
|
||||
return await lint(baseDir, lintDirs, eslintrcFile, pkgJsonPath, hasAppDir, {
|
||||
lintDuringBuild,
|
||||
eslintOptions,
|
||||
reportErrorsOnly,
|
||||
maxWarnings,
|
||||
formatter,
|
||||
outputFile
|
||||
});
|
||||
} else {
|
||||
// Display warning if no ESLint configuration is present inside
|
||||
// config file during "next build", no warning is shown when
|
||||
// no eslintrc file is present
|
||||
if (lintDuringBuild) {
|
||||
if (config.emptyPkgJsonConfig || config.emptyEslintrc) {
|
||||
Log.warn(`No ESLint configuration detected. Run ${_chalk.default.bold.cyan("next lint")} to begin setup`);
|
||||
}
|
||||
return null;
|
||||
} else {
|
||||
// Ask user what config they would like to start with for first time "next lint" setup
|
||||
const { config: selectedConfig } = strict ? _constants.ESLINT_PROMPT_VALUES.find((opt)=>opt.title === "Strict") : await cliPrompt();
|
||||
if (selectedConfig == null) {
|
||||
// Show a warning if no option is selected in prompt
|
||||
Log.warn("If you set up ESLint yourself, we recommend adding the Next.js ESLint plugin. See https://nextjs.org/docs/basic-features/eslint#migrating-existing-config");
|
||||
return null;
|
||||
} else {
|
||||
// Check if necessary deps installed, and install any that are missing
|
||||
deps = await (0, _hasNecessaryDependencies).hasNecessaryDependencies(baseDir, requiredPackages);
|
||||
if (deps.missing.length > 0) await (0, _installDependencies).installDependencies(baseDir, deps.missing, true);
|
||||
// Write default ESLint config.
|
||||
// Check for /pages and src/pages is to make sure this happens in Next.js folder
|
||||
if ((0, _findPagesDir).existsSync(_path.default.join(baseDir, "pages")) || (0, _findPagesDir).existsSync(_path.default.join(baseDir, "src/pages"))) {
|
||||
await (0, _writeDefaultConfig).writeDefaultConfig(baseDir, config, selectedConfig, eslintrcFile, pkgJsonPath, packageJsonConfig);
|
||||
}
|
||||
}
|
||||
Log.ready(`ESLint has successfully been configured. Run ${_chalk.default.bold.cyan("next lint")} again to view warnings and errors.`);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=runLintCheck.js.map
|
||||
1
kitabcitab/node_modules/next/dist/lib/eslint/runLintCheck.js.map
generated
vendored
Normal file
1
kitabcitab/node_modules/next/dist/lib/eslint/runLintCheck.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
4
kitabcitab/node_modules/next/dist/lib/eslint/writeDefaultConfig.d.ts
generated
vendored
Normal file
4
kitabcitab/node_modules/next/dist/lib/eslint/writeDefaultConfig.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
import { ConfigAvailable } from './hasEslintConfiguration';
|
||||
export declare function writeDefaultConfig(baseDir: string, { exists, emptyEslintrc, emptyPkgJsonConfig }: ConfigAvailable, selectedConfig: any, eslintrcFile: string | null, pkgJsonPath: string | null, packageJsonConfig: {
|
||||
eslintConfig: any;
|
||||
} | null): Promise<void>;
|
||||
80
kitabcitab/node_modules/next/dist/lib/eslint/writeDefaultConfig.js
generated
vendored
Normal file
80
kitabcitab/node_modules/next/dist/lib/eslint/writeDefaultConfig.js
generated
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.writeDefaultConfig = writeDefaultConfig;
|
||||
var _fs = require("fs");
|
||||
var _chalk = _interopRequireDefault(require("next/dist/compiled/chalk"));
|
||||
var _os = _interopRequireDefault(require("os"));
|
||||
var _path = _interopRequireDefault(require("path"));
|
||||
var CommentJson = _interopRequireWildcard(require("next/dist/compiled/comment-json"));
|
||||
var Log = _interopRequireWildcard(require("../../build/output/log"));
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {
|
||||
default: obj
|
||||
};
|
||||
}
|
||||
function _getRequireWildcardCache() {
|
||||
if (typeof WeakMap !== "function") return null;
|
||||
var cache = new WeakMap();
|
||||
_getRequireWildcardCache = function() {
|
||||
return cache;
|
||||
};
|
||||
return cache;
|
||||
}
|
||||
function _interopRequireWildcard(obj) {
|
||||
if (obj && obj.__esModule) {
|
||||
return obj;
|
||||
}
|
||||
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
||||
return {
|
||||
default: obj
|
||||
};
|
||||
}
|
||||
var cache = _getRequireWildcardCache();
|
||||
if (cache && cache.has(obj)) {
|
||||
return cache.get(obj);
|
||||
}
|
||||
var newObj = {};
|
||||
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
||||
for(var key in obj){
|
||||
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
||||
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
||||
if (desc && (desc.get || desc.set)) {
|
||||
Object.defineProperty(newObj, key, desc);
|
||||
} else {
|
||||
newObj[key] = obj[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
newObj.default = obj;
|
||||
if (cache) {
|
||||
cache.set(obj, newObj);
|
||||
}
|
||||
return newObj;
|
||||
}
|
||||
async function writeDefaultConfig(baseDir, { exists , emptyEslintrc , emptyPkgJsonConfig }, selectedConfig, eslintrcFile, pkgJsonPath, packageJsonConfig) {
|
||||
if (!exists && emptyEslintrc && eslintrcFile) {
|
||||
const ext = _path.default.extname(eslintrcFile);
|
||||
let newFileContent;
|
||||
if (ext === ".yaml" || ext === ".yml") {
|
||||
newFileContent = "extends: 'next'";
|
||||
} else {
|
||||
newFileContent = CommentJson.stringify(selectedConfig, null, 2);
|
||||
if (ext === ".js") {
|
||||
newFileContent = "module.exports = " + newFileContent;
|
||||
}
|
||||
}
|
||||
await _fs.promises.writeFile(eslintrcFile, newFileContent + _os.default.EOL);
|
||||
Log.info(`We detected an empty ESLint configuration file (${_chalk.default.bold(_path.default.basename(eslintrcFile))}) and updated it for you!`);
|
||||
} else if (!exists && emptyPkgJsonConfig && packageJsonConfig) {
|
||||
packageJsonConfig.eslintConfig = selectedConfig;
|
||||
if (pkgJsonPath) await _fs.promises.writeFile(pkgJsonPath, CommentJson.stringify(packageJsonConfig, null, 2) + _os.default.EOL);
|
||||
Log.info(`We detected an empty ${_chalk.default.bold("eslintConfig")} field in package.json and updated it for you!`);
|
||||
} else if (!exists) {
|
||||
await _fs.promises.writeFile(_path.default.join(baseDir, ".eslintrc.json"), CommentJson.stringify(selectedConfig, null, 2) + _os.default.EOL);
|
||||
console.log(_chalk.default.green(`We created the ${_chalk.default.bold(".eslintrc.json")} file for you and included your selected configuration.`));
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=writeDefaultConfig.js.map
|
||||
1
kitabcitab/node_modules/next/dist/lib/eslint/writeDefaultConfig.js.map
generated
vendored
Normal file
1
kitabcitab/node_modules/next/dist/lib/eslint/writeDefaultConfig.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../lib/eslint/writeDefaultConfig.ts"],"names":["writeDefaultConfig","CommentJson","Log","baseDir","exists","emptyEslintrc","emptyPkgJsonConfig","selectedConfig","eslintrcFile","pkgJsonPath","packageJsonConfig","ext","path","extname","newFileContent","stringify","fs","writeFile","os","EOL","info","chalk","bold","basename","eslintConfig","join","console","log","green"],"mappings":"AAAA;;;;QASsBA,kBAAkB,GAAlBA,kBAAkB;AATT,IAAA,GAAI,WAAJ,IAAI,CAAA;AACjB,IAAA,MAA0B,kCAA1B,0BAA0B,EAAA;AAC7B,IAAA,GAAI,kCAAJ,IAAI,EAAA;AACF,IAAA,KAAM,kCAAN,MAAM,EAAA;AACXC,IAAAA,WAAW,mCAAM,iCAAiC,EAAvC;AAGXC,IAAAA,GAAG,mCAAM,wBAAwB,EAA9B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAER,eAAeF,kBAAkB,CACtCG,OAAe,EACf,EAAEC,MAAM,CAAA,EAAEC,aAAa,CAAA,EAAEC,kBAAkB,CAAA,EAAmB,EAC9DC,cAAmB,EACnBC,YAA2B,EAC3BC,WAA0B,EAC1BC,iBAA+C,EAC/C;IACA,IAAI,CAACN,MAAM,IAAIC,aAAa,IAAIG,YAAY,EAAE;QAC5C,MAAMG,GAAG,GAAGC,KAAI,QAAA,CAACC,OAAO,CAACL,YAAY,CAAC;QAEtC,IAAIM,cAAc;QAClB,IAAIH,GAAG,KAAK,OAAO,IAAIA,GAAG,KAAK,MAAM,EAAE;YACrCG,cAAc,GAAG,iBAAiB;SACnC,MAAM;YACLA,cAAc,GAAGb,WAAW,CAACc,SAAS,CAACR,cAAc,EAAE,IAAI,EAAE,CAAC,CAAC;YAE/D,IAAII,GAAG,KAAK,KAAK,EAAE;gBACjBG,cAAc,GAAG,mBAAmB,GAAGA,cAAc;aACtD;SACF;QAED,MAAME,GAAE,SAAA,CAACC,SAAS,CAACT,YAAY,EAAEM,cAAc,GAAGI,GAAE,QAAA,CAACC,GAAG,CAAC;QAEzDjB,GAAG,CAACkB,IAAI,CACN,CAAC,gDAAgD,EAAEC,MAAK,QAAA,CAACC,IAAI,CAC3DV,KAAI,QAAA,CAACW,QAAQ,CAACf,YAAY,CAAC,CAC5B,CAAC,yBAAyB,CAAC,CAC7B;KACF,MAAM,IAAI,CAACJ,MAAM,IAAIE,kBAAkB,IAAII,iBAAiB,EAAE;QAC7DA,iBAAiB,CAACc,YAAY,GAAGjB,cAAc;QAE/C,IAAIE,WAAW,EACb,MAAMO,GAAE,SAAA,CAACC,SAAS,CAChBR,WAAW,EACXR,WAAW,CAACc,SAAS,CAACL,iBAAiB,EAAE,IAAI,EAAE,CAAC,CAAC,GAAGQ,GAAE,QAAA,CAACC,GAAG,CAC3D;QAEHjB,GAAG,CAACkB,IAAI,CACN,CAAC,qBAAqB,EAAEC,MAAK,QAAA,CAACC,IAAI,CAChC,cAAc,CACf,CAAC,8CAA8C,CAAC,CAClD;KACF,MAAM,IAAI,CAAClB,MAAM,EAAE;QAClB,MAAMY,GAAE,SAAA,CAACC,SAAS,CAChBL,KAAI,QAAA,CAACa,IAAI,CAACtB,OAAO,EAAE,gBAAgB,CAAC,EACpCF,WAAW,CAACc,SAAS,CAACR,cAAc,EAAE,IAAI,EAAE,CAAC,CAAC,GAAGW,GAAE,QAAA,CAACC,GAAG,CACxD;QAEDO,OAAO,CAACC,GAAG,CACTN,MAAK,QAAA,CAACO,KAAK,CACT,CAAC,eAAe,EAAEP,MAAK,QAAA,CAACC,IAAI,CAC1B,gBAAgB,CACjB,CAAC,uDAAuD,CAAC,CAC3D,CACF;KACF;CACF"}
|
||||
8
kitabcitab/node_modules/next/dist/lib/eslint/writeOutputFile.d.ts
generated
vendored
Normal file
8
kitabcitab/node_modules/next/dist/lib/eslint/writeOutputFile.d.ts
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* Create a file with eslint output data
|
||||
*/
|
||||
export declare function writeOutputFile(
|
||||
/** The name file that needs to be created */
|
||||
outputFile: string,
|
||||
/** The data that needs to be inserted into the file */
|
||||
outputData: string): Promise<void>;
|
||||
85
kitabcitab/node_modules/next/dist/lib/eslint/writeOutputFile.js
generated
vendored
Normal file
85
kitabcitab/node_modules/next/dist/lib/eslint/writeOutputFile.js
generated
vendored
Normal file
@@ -0,0 +1,85 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.writeOutputFile = writeOutputFile;
|
||||
var _fs = require("fs");
|
||||
var _path = _interopRequireDefault(require("path"));
|
||||
var Log = _interopRequireWildcard(require("../../build/output/log"));
|
||||
var _isError = _interopRequireDefault(require("../../lib/is-error"));
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {
|
||||
default: obj
|
||||
};
|
||||
}
|
||||
function _getRequireWildcardCache() {
|
||||
if (typeof WeakMap !== "function") return null;
|
||||
var cache = new WeakMap();
|
||||
_getRequireWildcardCache = function() {
|
||||
return cache;
|
||||
};
|
||||
return cache;
|
||||
}
|
||||
function _interopRequireWildcard(obj) {
|
||||
if (obj && obj.__esModule) {
|
||||
return obj;
|
||||
}
|
||||
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
||||
return {
|
||||
default: obj
|
||||
};
|
||||
}
|
||||
var cache = _getRequireWildcardCache();
|
||||
if (cache && cache.has(obj)) {
|
||||
return cache.get(obj);
|
||||
}
|
||||
var newObj = {};
|
||||
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
||||
for(var key in obj){
|
||||
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
||||
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
||||
if (desc && (desc.get || desc.set)) {
|
||||
Object.defineProperty(newObj, key, desc);
|
||||
} else {
|
||||
newObj[key] = obj[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
newObj.default = obj;
|
||||
if (cache) {
|
||||
cache.set(obj, newObj);
|
||||
}
|
||||
return newObj;
|
||||
}
|
||||
/**
|
||||
* Check if a given file path is a directory or not.
|
||||
* Returns `true` if the path is a directory.
|
||||
*/ async function isDirectory(/** The path to a file to check. */ filePath) {
|
||||
try {
|
||||
return (await _fs.promises.stat(filePath)).isDirectory();
|
||||
} catch (error) {
|
||||
if ((0, _isError).default(error) && (error.code === "ENOENT" || error.code === "ENOTDIR")) {
|
||||
return false;
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
async function writeOutputFile(/** The name file that needs to be created */ outputFile, /** The data that needs to be inserted into the file */ outputData) {
|
||||
const filePath = _path.default.resolve(process.cwd(), outputFile);
|
||||
if (await isDirectory(filePath)) {
|
||||
Log.error(`Cannot write to output file path, it is a directory: ${filePath}`);
|
||||
} else {
|
||||
try {
|
||||
await _fs.promises.mkdir(_path.default.dirname(filePath), {
|
||||
recursive: true
|
||||
});
|
||||
await _fs.promises.writeFile(filePath, outputData);
|
||||
Log.info(`The output file has been created: ${filePath}`);
|
||||
} catch (err) {
|
||||
Log.error(`There was a problem writing the output file: ${filePath}`);
|
||||
console.error(err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=writeOutputFile.js.map
|
||||
1
kitabcitab/node_modules/next/dist/lib/eslint/writeOutputFile.js.map
generated
vendored
Normal file
1
kitabcitab/node_modules/next/dist/lib/eslint/writeOutputFile.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../lib/eslint/writeOutputFile.ts"],"names":["writeOutputFile","Log","isDirectory","filePath","fs","stat","error","isError","code","outputFile","outputData","path","resolve","process","cwd","mkdir","dirname","recursive","writeFile","info","err","console"],"mappings":"AAAA;;;;QA4BsBA,eAAe,GAAfA,eAAe;AA5BN,IAAA,GAAI,WAAJ,IAAI,CAAA;AAClB,IAAA,KAAM,kCAAN,MAAM,EAAA;AACXC,IAAAA,GAAG,mCAAM,wBAAwB,EAA9B;AACK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