Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
imjordanxd committed Sep 15, 2024
2 parents 8c3bccb + 71f37c5 commit d6a6fb4
Show file tree
Hide file tree
Showing 15 changed files with 111 additions and 90 deletions.
13 changes: 8 additions & 5 deletions .github/ISSUE_TEMPLATE/bug-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ body:
description: |
Please tell us about how you're running ESLint (Run `npx eslint --env-info`.)
value: |
Node version:
npm version:
Local ESLint version:
Global ESLint version:
Operating System:
Node version:
npm version:
Local ESLint version:
Global ESLint version:
Operating System:
validations:
required: true
- type: dropdown
Expand Down Expand Up @@ -87,6 +87,9 @@ body:
options:
- label: I am willing to submit a pull request for this issue.
required: false
- type: markdown
attributes:
value: Please **do not** open a pull request until this issue has been accepted by the team.
- type: textarea
id: comments
attributes:
Expand Down
3 changes: 3 additions & 0 deletions .github/ISSUE_TEMPLATE/change.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ body:
options:
- label: I am willing to submit a pull request for this change.
required: false
- type: markdown
attributes:
value: Please **do not** open a pull request until this issue has been accepted by the team.
- type: textarea
attributes:
label: Additional comments
Expand Down
3 changes: 3 additions & 0 deletions .github/ISSUE_TEMPLATE/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ body:
options:
- label: I am willing to submit a pull request for this change.
required: false
- type: markdown
attributes:
value: Please **do not** open a pull request until this issue has been accepted by the team.
- type: textarea
attributes:
label: Additional comments
Expand Down
3 changes: 3 additions & 0 deletions .github/ISSUE_TEMPLATE/new-rule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ body:
options:
- label: I am willing to submit a pull request to implement this rule.
required: false
- type: markdown
attributes:
value: Please **do not** open a pull request until this issue has been accepted by the team.
- type: textarea
attributes:
label: Additional comments
Expand Down
3 changes: 3 additions & 0 deletions .github/ISSUE_TEMPLATE/new-syntax.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ body:
options:
- label: I am willing to submit a pull request for this change.
required: false
- type: markdown
attributes:
value: Please **do not** open a pull request until this issue has been accepted by the team.
- type: textarea
attributes:
label: Additional comments
Expand Down
3 changes: 3 additions & 0 deletions .github/ISSUE_TEMPLATE/rule-change.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ body:
options:
- label: I am willing to submit a pull request to implement this change.
required: false
- type: markdown
attributes:
value: Please **do not** open a pull request until this issue has been accepted by the team.
- type: textarea
attributes:
label: Additional comments
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -297,9 +297,9 @@ The following companies, organizations, and individuals support ESLint's ongoing
<!--sponsorsstart-->
<h3>Platinum Sponsors</h3>
<p><a href="https://automattic.com"><img src="https://images.opencollective.com/automattic/d0ef3e1/logo.png" alt="Automattic" height="128"></a> <a href="https://www.airbnb.com/"><img src="https://images.opencollective.com/airbnb/d327d66/logo.png" alt="Airbnb" height="128"></a></p><h3>Gold Sponsors</h3>
<p><a href="https://trunk.io/"><img src="https://images.opencollective.com/trunkio/fb92d60/avatar.png" alt="trunk.io" height="96"></a> <a href="https://opensource.siemens.com"><img src="https://avatars.githubusercontent.com/u/624020?v=4" alt="Siemens" height="96"></a></p><h3>Silver Sponsors</h3>
<p><a href="https://trunk.io/"><img src="https://images.opencollective.com/trunkio/fb92d60/avatar.png" alt="trunk.io" height="96"></a></p><h3>Silver Sponsors</h3>
<p><a href="https://www.jetbrains.com/"><img src="https://images.opencollective.com/jetbrains/fe76f99/logo.png" alt="JetBrains" height="64"></a> <a href="https://liftoff.io/"><img src="https://images.opencollective.com/liftoff/5c4fa84/logo.png" alt="Liftoff" height="64"></a> <a href="https://americanexpress.io"><img src="https://avatars.githubusercontent.com/u/3853301?v=4" alt="American Express" height="64"></a> <a href="https://www.workleap.com"><img src="https://avatars.githubusercontent.com/u/53535748?u=d1e55d7661d724bf2281c1bfd33cb8f99fe2465f&v=4" alt="Workleap" height="64"></a></p><h3>Bronze Sponsors</h3>
<p><a href="https://www.crosswordsolver.org/anagram-solver/"><img src="https://images.opencollective.com/anagram-solver/2666271/logo.png" alt="Anagram Solver" height="32"></a> <a href="https://icons8.com/"><img src="https://images.opencollective.com/icons8/7fa1641/logo.png" alt="Icons8" height="32"></a> <a href="https://discord.com"><img src="https://images.opencollective.com/discordapp/f9645d9/logo.png" alt="Discord" height="32"></a> <a href="https://www.ignitionapp.com"><img src="https://avatars.githubusercontent.com/u/5753491?v=4" alt="Ignition" height="32"></a> <a href="https://nx.dev"><img src="https://avatars.githubusercontent.com/u/23692104?v=4" alt="Nx" height="32"></a> <a href="https://herocoders.com"><img src="https://avatars.githubusercontent.com/u/37549774?v=4" alt="HeroCoders" height="32"></a> <a href="https://usenextbase.com"><img src="https://avatars.githubusercontent.com/u/145838380?v=4" alt="Nextbase Starter Kit" height="32"></a></p>
<p><a href="https://www.crosswordsolver.org/anagram-solver/"><img src="https://images.opencollective.com/anagram-solver/2666271/logo.png" alt="Anagram Solver" height="32"></a> <a href="https://icons8.com/"><img src="https://images.opencollective.com/icons8/7fa1641/logo.png" alt="Icons8" height="32"></a> <a href="https://discord.com"><img src="https://images.opencollective.com/discordapp/f9645d9/logo.png" alt="Discord" height="32"></a> <a href="https://nx.dev"><img src="https://avatars.githubusercontent.com/u/23692104?v=4" alt="Nx" height="32"></a> <a href="https://herocoders.com"><img src="https://avatars.githubusercontent.com/u/37549774?v=4" alt="HeroCoders" height="32"></a> <a href="https://usenextbase.com"><img src="https://avatars.githubusercontent.com/u/145838380?v=4" alt="Nextbase Starter Kit" height="32"></a></p>
<!--sponsorsend-->

<!--techsponsorsstart-->
Expand Down
4 changes: 2 additions & 2 deletions docs/src/integrate/nodejs-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -466,8 +466,8 @@ This edit information means replacing the range of the `range` property by the `

The `LoadedFormatter` value is the object to convert the [LintResult] objects to text. The [eslint.loadFormatter()][eslint-loadformatter] method returns it. It has the following method:

* `format` (`(results: LintResult[], resultsMeta: ResultsMeta) => string | Promise<string>`)<br>
The method to convert the [LintResult] objects to text. `resultsMeta` is an object that will contain a `maxWarningsExceeded` object if `--max-warnings` was set and the number of warnings exceeded the limit. The `maxWarningsExceeded` object will contain two properties: `maxWarnings`, the value of the `--max-warnings` option, and `foundWarnings`, the number of lint warnings.
* `format` (`(results: LintResult[], resultsMeta?: ResultsMeta) => string | Promise<string>`)<br>
The method to convert the [LintResult] objects to text. `resultsMeta` is an optional parameter that is primarily intended for use by the ESLint CLI and can contain only a `maxWarningsExceeded` property that would be passed through the [`context`](../extend/custom-formatters#the-context-argument) object when this method calls the underlying formatter function. Note that ESLint automatically generates `cwd` and `rulesMeta` properties of the `context` object, so you typically don't need to pass in the second argument when calling this method.

---

Expand Down
24 changes: 21 additions & 3 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ const eslintConfigESLintCJS = require("eslint-config-eslint/cjs");
const eslintConfigESLintFormatting = require("eslint-config-eslint/formatting");
const eslintPluginYml = require("eslint-plugin-yml");
const json = require("@eslint/json").default;
const expectType = require("eslint-plugin-expect-type");
const tsParser = require("@typescript-eslint/parser");

//-----------------------------------------------------------------------------
// Helpers
Expand Down Expand Up @@ -87,14 +89,14 @@ module.exports = [
"docs/!(src|tools)/",
"docs/src/!(_data)",
"jsdoc/**",
"lib/types/**/*.ts",
"templates/**",
"tests/bench/**",
"tests/fixtures/**",
"tests/performance/**",
"tmp/**",
"**/test.js",
".vscode",
"**/*.ts"
".vscode"
]
},
{
Expand Down Expand Up @@ -279,5 +281,21 @@ module.exports = [
...eslintPluginYml.configs["flat/recommended"].map(config => ({
...config,
files: [ALL_YAML_FILES]
}))
})),
{
name: "eslint/ts-rules",
files: ["tests/lib/types/*.ts"],
languageOptions: {
parser: tsParser,
parserOptions: {
project: "tests/lib/types/tsconfig.json"
}
},
plugins: {
"expect-type": expectType
},
rules: {
"expect-type/expect": "error"
}
}
];
6 changes: 1 addition & 5 deletions lib/config/flat-config-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,9 @@ function parseRuleId(ruleId) {
* or undefined if not.
*/
function getRuleFromConfig(ruleId, config) {

const { pluginName, ruleName } = parseRuleId(ruleId);

const plugin = config.plugins && config.plugins[pluginName];
const rule = plugin && plugin.rules && plugin.rules[ruleName];

return rule;
return config.plugins?.[pluginName]?.rules?.[ruleName];
}

/**
Expand Down
53 changes: 1 addition & 52 deletions lib/languages/js/source-code/source-code.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const

CodePathAnalyzer = require("../../../linter/code-path-analysis/code-path-analyzer"),
createEmitter = require("../../../linter/safe-emitter"),
{ ConfigCommentParser, VisitNodeStep, CallMethodStep } = require("@eslint/plugin-kit"),
{ ConfigCommentParser, VisitNodeStep, CallMethodStep, Directive } = require("@eslint/plugin-kit"),

eslintScope = require("eslint-scope");

Expand Down Expand Up @@ -316,57 +316,6 @@ function markExportedVariables(globalScope, variables) {

}

/**
* A class to represent a directive comment.
* @implements {IDirective}
*/
class Directive {

/**
* The type of directive.
* @type {"disable"|"enable"|"disable-next-line"|"disable-line"}
* @readonly
*/
type;

/**
* The node representing the directive.
* @type {ASTNode|Comment}
* @readonly
*/
node;

/**
* Everything after the "eslint-disable" portion of the directive,
* but before the "--" that indicates the justification.
* @type {string}
* @readonly
*/
value;

/**
* The justification for the directive.
* @type {string}
* @readonly
*/
justification;

/**
* Creates a new instance.
* @param {Object} options The options for the directive.
* @param {"disable"|"enable"|"disable-next-line"|"disable-line"} options.type The type of directive.
* @param {ASTNode|Comment} options.node The node representing the directive.
* @param {string} options.value The value of the directive.
* @param {string} options.justification The justification for the directive.
*/
constructor({ type, node, value, justification }) {
this.type = type;
this.node = node;
this.value = value;
this.justification = justification;
}
}

//------------------------------------------------------------------------------
// Public Interface
//------------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion lib/shared/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,6 @@ module.exports = {};
* A formatter function.
* @callback FormatterFunction
* @param {LintResult[]} results The list of linting results.
* @param {{cwd: string, maxWarningsExceeded?: MaxWarningsExceeded, rulesMeta: Record<string, RuleMeta>}} [context] A context object.
* @param {{cwd: string, maxWarningsExceeded?: MaxWarningsExceeded, rulesMeta: Record<string, RuleMeta>}} context A context object.
* @returns {string | Promise<string>} Formatted text.
*/
34 changes: 29 additions & 5 deletions lib/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1411,7 +1411,7 @@ export class ESLint {

isPathIgnored(filePath: string): Promise<boolean>;

loadFormatter(nameOrPath?: string): Promise<ESLint.Formatter>;
loadFormatter(nameOrPath?: string): Promise<ESLint.LoadedFormatter>;
}

export namespace ESLint {
Expand Down Expand Up @@ -1555,14 +1555,38 @@ export namespace ESLint {
replacedBy: string[];
}

interface Formatter {
format(results: LintResult[], data?: LintResultData): string | Promise<string>;
interface ResultsMeta {
maxWarningsExceeded?: MaxWarningsExceeded | undefined;
}

/** The type of an object resolved by {@link ESLint.loadFormatter}. */
interface LoadedFormatter {

/**
* Used to call the underlying formatter.
* @param results An array of lint results to format.
* @param resultsMeta An object with an optional `maxWarningsExceeded` property that will be
* passed to the underlying formatter function along with other properties set by ESLint.
* This argument can be omitted if `maxWarningsExceeded` is not needed.
* @return The formatter output.
*/
format(results: LintResult[], resultsMeta?: ResultsMeta): string | Promise<string>;
}

// The documented type name is `LoadedFormatter`, but `Formatter` has been historically more used.
type Formatter = LoadedFormatter;

/**
* The expected signature of a custom formatter.
* @param results An array of lint results to format.
* @param context Additional information for the formatter.
* @return The formatter output.
*/
type FormatterFunction =
(results: LintResult[], context: LintResultData) => string | Promise<string>;

// Docs reference the types by those name
type EditInfo = Rule.Fix;
type LoadedFormatter = Formatter;
type ResultsMeta = LintResultData;
}

// #endregion
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
"@eslint/config-array": "^0.18.0",
"@eslint/eslintrc": "^3.1.0",
"@eslint/js": "9.10.0",
"@eslint/plugin-kit": "^0.1.0",
"@eslint/plugin-kit": "^0.2.0",
"@humanwhocodes/module-importer": "^1.0.1",
"@humanwhocodes/retry": "^0.3.0",
"@nodelib/fs.walk": "^1.2.8",
Expand Down Expand Up @@ -115,12 +115,13 @@
"devDependencies": {
"@babel/core": "^7.4.3",
"@babel/preset-env": "^7.4.3",
"@eslint/core": "^0.5.0",
"@eslint/core": "^0.6.0",
"@eslint/json": "^0.4.0",
"@trunkio/launcher": "^1.3.0",
"@types/estree": "^1.0.5",
"@types/json-schema": "^7.0.15",
"@types/node": "^20.11.5",
"@typescript-eslint/parser": "^8.4.0",
"@wdio/browser-runner": "^9.0.5",
"@wdio/cli": "^9.0.5",
"@wdio/concise-reporter": "^9.0.4",
Expand All @@ -135,6 +136,7 @@
"eslint": "file:.",
"eslint-config-eslint": "file:packages/eslint-config-eslint",
"eslint-plugin-eslint-plugin": "^6.0.0",
"eslint-plugin-expect-type": "^0.4.0",
"eslint-plugin-yml": "^1.14.0",
"eslint-release": "^3.2.2",
"eslint-rule-composer": "^0.3.0",
Expand Down
Loading

0 comments on commit d6a6fb4

Please sign in to comment.