Repository: eslint/eslint
File: lib/linter/linter.js (JavaScript)

Code before:
			if (options.warnInlineConfig) {
				if (sourceCode.getInlineConfigNodes) {
					sourceCode.getInlineConfigNodes().forEach(node => {
						const loc = sourceCode.getLoc(node);
						const range = sourceCode.getRange(node);

						report.addWarning({
							message: `'${sourceCode.text.slice(range[0], range[1])}' has no effect because you have 'noInlineConfig' setting in ${options.warnInlineConfig}.`,
							loc,
						});
					});
				}
			} else {
				if (sourceCode.getInlineConfigNodes) {
					for (const comment of sourceCode.getInlineConfigNodes()) {
						const { label } = commentParser.parseDirective(
							comment.value,
						);
						if (label === "eslint-env") {
							slots.warningService.emitESLintEnvWarning(
								options.filename,
								comment.loc.start.line,
							);
						}
					}
				}

				const inlineConfigResult = sourceCode.applyInlineConfig?.();

				if (inlineConfigResult) {
					inlineConfigResult.problems.forEach(problem => {
						report.addFatal(problem);
					});

					for (const {
						config: inlineConfig,
						loc,
					} of inlineConfigResult.configs) {
						Object.keys(inlineConfig.rules).forEach(ruleId => {
							const rule = config.getRuleDefinition(ruleId);
							const ruleValue = inlineConfig.rules[ruleId];

							if (!rule) {
								report.addError({
									ruleId,
									loc,
								});
								return;
							}

							if (

Review comment (refactor):
I think this check should be in `SourceCode.applyInlineConfig`, similar to how it is implemented in ESLint v10 (we'd just emit a warning instead of returning an error) https://github.com/eslint/eslint/blob/5a4324f38e7ce370038351ef7412dcf8548c105e/lib/languages/js/source-code/source-code.js#L1051-L1059 because we warn about `eslint-env` comments that are used with JS Language as those are no longer supported. Custom languages can still support this kind of config comments (I doubt there are any, but still in theory a custom language can support any kind and form of config comments). Also, that would simplify the implementation and avoid duplicate parsing of configuration comments.

Code after:
			if (options.warnInlineConfig) {
				if (sourceCode.getInlineConfigNodes) {
					sourceCode.getInlineConfigNodes().forEach(node => {
						const loc = sourceCode.getLoc(node);
						const range = sourceCode.getRange(node);

						report.addWarning({
							message: `'${sourceCode.text.slice(range[0], range[1])}' has no effect because you have 'noInlineConfig' setting in ${options.warnInlineConfig}.`,
							loc,
						});
					});
				}
			} else {
				if (config.language === jslang) {
					for (const comment of sourceCode.getInlineConfigNodes()) {
						const { label } = commentParser.parseDirective(
							comment.value,
						);
						if (label === "eslint-env") {
							slots.warningService.emitESLintEnvWarning(
								options.filename,
								comment.loc.start.line,
							);
						}
					}
				}

				const inlineConfigResult = sourceCode.applyInlineConfig?.();

				if (inlineConfigResult) {
					inlineConfigResult.problems.forEach(problem => {
						report.addFatal(problem);
					});

					for (const {
						config: inlineConfig,
						loc,
					} of inlineConfigResult.configs) {
						Object.keys(inlineConfig.rules).forEach(ruleId => {
							const rule = config.getRuleDefinition(ruleId);
							const ruleValue = inlineConfig.rules[ruleId];

							if (!rule) {
								report.addError({
									ruleId,
									loc,
								});
								return;
							}

							if (