Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[REFERENCE] Rule creator packages prototypes#11207

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
JoshuaKGoldberg wants to merge3 commits intotypescript-eslint:main
base:main
Choose a base branch
Loading
fromJoshuaKGoldberg:rule-creator-packages-prototypes
Draft
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions.vscode/settings.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
{
"eslint.rules.customizations": [{ "rule": "*", "severity": "warn" }],

// This matches the value configured on the autoformatter
"editor.rulers": [80],

Expand Down
1 change: 1 addition & 0 deletionspackages/eslint-plugin-internal/package.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -24,6 +24,7 @@
},
"dependencies": {
"@prettier/sync": "^0.5.1",
"@typescript-eslint/rule-creator": "workspace:*",
"@typescript-eslint/rule-tester": "workspace:*",
"@typescript-eslint/scope-manager": "workspace:*",
"@typescript-eslint/type-utils": "workspace:*",
Expand Down
4 changes: 2 additions & 2 deletionspackages/eslint-plugin-internal/src/util/createRule.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
import {ESLintUtils } from '@typescript-eslint/utils';
import {RuleCreator } from '@typescript-eslint/rule-creator';

// note - cannot migrate this to an import statement because it will make TSC copy the package.json to the dist folder
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
Expand All@@ -8,7 +8,7 @@ export interface ESLintPluginInternalDocs {
requiresTypeChecking?: true;
}

export const createRule =ESLintUtils.RuleCreator<ESLintPluginInternalDocs>(
export const createRule = RuleCreator<ESLintPluginInternalDocs>(
name =>
`https://github.com/typescript-eslint/typescript-eslint/blob/v${version}/packages/eslint-plugin-internal/src/rules/${name}.ts`,
);
3 changes: 3 additions & 0 deletionspackages/eslint-plugin-internal/tsconfig.build.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,6 +5,9 @@
{
"path": "../type-utils/tsconfig.build.json"
},
{
"path": "../rule-creator/tsconfig.build.json"
},
{
"path": "../scope-manager/tsconfig.build.json"
},
Expand Down
3 changes: 3 additions & 0 deletionspackages/eslint-plugin-internal/tsconfig.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,6 +6,9 @@
{
"path": "../type-utils"
},
{
"path": "../rule-creator"
},
{
"path": "../scope-manager"
},
Expand Down
1 change: 1 addition & 0 deletionspackages/eslint-plugin/package.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -61,6 +61,7 @@
},
"dependencies": {
"@eslint-community/regexpp": "^4.10.0",
"@typescript-eslint/rule-creator": "8.32.0",
"@typescript-eslint/scope-manager": "8.32.0",
"@typescript-eslint/type-utils": "8.32.0",
"@typescript-eslint/utils": "8.32.0",
Expand Down
9 changes: 5 additions & 4 deletionspackages/eslint-plugin/src/rules/member-ordering.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
// This rule was feature-frozen before we enabled no-property-in-node.
/* eslint-disable eslint-plugin/no-property-in-node */

import type {JSONSchema,TSESLint, TSESTree } from '@typescript-eslint/utils';
import type { TSESLint, TSESTree } from '@typescript-eslint/utils';

import { AST_NODE_TYPES } from '@typescript-eslint/utils';
import naturalCompare from 'natural-compare';
Expand All@@ -12,6 +12,7 @@ import {
getNameFromMember,
MemberNameType,
} from '../util';
import { JSONSchema4 } from '@typescript-eslint/utils/json-schema';

export type MessageIds =
| 'incorrectGroupOrder'
Expand DownExpand Up@@ -91,12 +92,12 @@ export type Options = [
},
];

const neverConfig:JSONSchema.JSONSchema4 = {
const neverConfig: JSONSchema4 = {
type: 'string',
enum: ['never'],
};

const arrayConfig = (memberTypes: string):JSONSchema.JSONSchema4 => ({
const arrayConfig = (memberTypes: string): JSONSchema4 => ({
type: 'array',
items: {
oneOf: [
Expand All@@ -113,7 +114,7 @@ const arrayConfig = (memberTypes: string): JSONSchema.JSONSchema4 => ({
},
});

const objectConfig = (memberTypes: string):JSONSchema.JSONSchema4 => ({
const objectConfig = (memberTypes: string): JSONSchema4 => ({
type: 'object',
additionalProperties: false,
properties: {
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
import type {JSONSchema } from '@typescript-eslint/utils';
import type {JSONSchema4 } from '@typescript-eslint/utils/json-schema';

import type {
IndividualAndMetaSelectorsString,
Expand All@@ -15,7 +15,7 @@ import {
UnderscoreOptions,
} from './enums';

const $DEFS: Record<string,JSONSchema.JSONSchema4> = {
const $DEFS: Record<string, JSONSchema4> = {
// enums
predefinedFormats: {
enum: getEnumNames(PredefinedFormats),
Expand DownExpand Up@@ -64,16 +64,16 @@ const $DEFS: Record<string, JSONSchema.JSONSchema4> = {
},
};

const UNDERSCORE_SCHEMA:JSONSchema.JSONSchema4 = {
const UNDERSCORE_SCHEMA: JSONSchema4 = {
$ref: '#/$defs/underscoreOptions',
};
const PREFIX_SUFFIX_SCHEMA:JSONSchema.JSONSchema4 = {
const PREFIX_SUFFIX_SCHEMA: JSONSchema4 = {
$ref: '#/$defs/prefixSuffixConfig',
};
const MATCH_REGEX_SCHEMA:JSONSchema.JSONSchema4 = {
const MATCH_REGEX_SCHEMA: JSONSchema4 = {
$ref: '#/$defs/matchRegexConfig',
};
type JSONSchemaProperties = Record<string,JSONSchema.JSONSchema4>;
type JSONSchemaProperties = Record<string, JSONSchema4>;
const FORMAT_OPTIONS_PROPERTIES: JSONSchemaProperties = {
custom: MATCH_REGEX_SCHEMA,
failureMessage: {
Expand All@@ -91,7 +91,7 @@ function selectorSchema(
selectorString: IndividualAndMetaSelectorsString,
allowType: boolean,
modifiers?: ModifiersString[],
):JSONSchema.JSONSchema4[] {
): JSONSchema4[] {
const selector: JSONSchemaProperties = {
filter: {
oneOf: [
Expand DownExpand Up@@ -141,7 +141,7 @@ function selectorSchema(
];
}

function selectorsSchema():JSONSchema.JSONSchema4 {
function selectorsSchema(): JSONSchema4 {
return {
additionalProperties: false,
description: 'Multiple selectors in one config',
Expand DownExpand Up@@ -185,7 +185,7 @@ function selectorsSchema(): JSONSchema.JSONSchema4 {
};
}

export const SCHEMA:JSONSchema.JSONSchema4 = {
export const SCHEMA: JSONSchema4 = {
$defs: $DEFS,
additionalItems: false,
items: {
Expand Down
4 changes: 2 additions & 2 deletionspackages/eslint-plugin/src/util/createRule.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
import {ESLintUtils } from '@typescript-eslint/utils';
import {RuleCreator } from '@typescript-eslint/rule-creator';

import type { ESLintPluginDocs } from '../../rules';

export const createRule =ESLintUtils.RuleCreator<ESLintPluginDocs>(
export const createRule = RuleCreator<ESLintPluginDocs>(
name => `https://typescript-eslint.io/rules/${name}`,
);
1 change: 0 additions & 1 deletionpackages/eslint-plugin/src/util/index.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -34,7 +34,6 @@ export * from './truthinessUtils';
export * from '@typescript-eslint/type-utils';

export const {
applyDefault,
deepMerge,
getParserServices,
isObjectNotArray,
Expand Down
3 changes: 3 additions & 0 deletionspackages/eslint-plugin/tsconfig.build.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,6 +5,9 @@
{
"path": "../visitor-keys/tsconfig.build.json"
},
{
"path": "../rule-creator/tsconfig.build.json"
},
{
"path": "../type-utils/tsconfig.build.json"
},
Expand Down
3 changes: 3 additions & 0 deletionspackages/eslint-plugin/tsconfig.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,6 +9,9 @@
{
"path": "../type-utils"
},
{
"path": "../rule-creator"
},
{
"path": "../scope-manager"
},
Expand Down
21 changes: 21 additions & 0 deletionspackages/parser-services/LICENSE
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2025 typescript-eslint and other contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
3 changes: 3 additions & 0 deletionspackages/parser-services/README.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
# `@typescript-eslint/parser-services`

TODO
66 changes: 66 additions & 0 deletionspackages/parser-services/package.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
{
"name": "@typescript-eslint/parser-services",
"version": "8.32.0",
"description": "TODO",
"files": [
"dist",
"!*.tsbuildinfo",
"package.json",
"README.md",
"LICENSE"
],
"type": "commonjs",
"exports": {
".": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
},
"./package.json": "./package.json"
},
"types": "./dist/index.d.ts",
"engines": {
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
},
"repository": {
"type": "git",
"url": "https://github.com/typescript-eslint/typescript-eslint.git",
"directory": "packages/parser-services"
},
"bugs": {
"url": "https://github.com/typescript-eslint/typescript-eslint/issues"
},
"homepage": "https://typescript-eslint.io",
"license": "MIT",
"keywords": [
"eslint",
"typescript",
"estree"
],
"scripts": {
"build": "tsc -b tsconfig.build.json",
"clean": "tsc -b tsconfig.build.json --clean",
"postclean": "rimraf dist/ coverage/",
"format": "prettier --write \"./**/*.{ts,mts,cts,tsx,js,mjs,cjs,jsx,json,md,css}\" --ignore-path ../../.prettierignore",
"lint": "npx nx lint",
"test": "vitest --run --config=$INIT_CWD/vitest.config.mts",
"check-types": "npx nx typecheck"
},
"dependencies": {
"@typescript-eslint/types-eslint": "^8.32.0",
"@typescript-eslint/typescript-estree": "^8.32.0",
"debug": "^4.3.4",
"fast-glob": "^3.3.2",
"is-glob": "^4.0.3"
},
"devDependencies": {
"@vitest/coverage-v8": "^3.1.2",
"prettier": "^3.2.5",
"rimraf": "*",
"typescript": "*",
"vitest": "^3.1.2"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/typescript-eslint"
}
}
16 changes: 16 additions & 0 deletionspackages/parser-services/project.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
{
"name": "parser-services",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"projectType": "library",
"root": "packages/parser-services",
"sourceRoot": "packages/parser-services/src",
"targets": {
"lint": {
"executor": "@nx/eslint:lint",
"outputs": ["{options.outputFile}"]
},
"test": {
"executor": "@nx/vite:test"
}
}
}
Original file line numberDiff line numberDiff line change
Expand Up@@ -24,6 +24,3 @@ export function clearCaches(): void {
clearTSServerProjectService();
clearGlobCache();
}

// TODO - delete this in next major
export const clearProgramCache = clearCaches;
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,7 +8,7 @@ import { getScriptKind } from './getScriptKind';
import { createDefaultCompilerOptionsFromExtra } from './shared';

const log = debug(
'typescript-eslint:typescript-estree:create-program:createIsolatedProgram',
'typescript-eslint:parser-services:create-program:createIsolatedProgram',
);

/**
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,12 +2,12 @@ import type * as ts from 'typescript';

import debug from 'debug';

import type { ParseSettings } from '../parseSettings';
import type { ASTAndDefiniteProgram } from './shared';

import { firstDefined } from '../node-utils';
import { createProjectProgramError } from './createProjectProgramError';
import { getAstFromProgram } from './shared';
import { ParseSettings } from '../parseSettings';
import { firstDefined } from './utils';

const log = debug(
'typescript-eslint:typescript-estree:create-program:createProjectProgram',
Expand All@@ -23,6 +23,7 @@ export function createProjectProgram(
): ASTAndDefiniteProgram {
log('Creating project program for: %s', parseSettings.filePath);

// TODO: switch to .find()?
const astAndProgram = firstDefined(programsForProjects, currentProgram =>
getAstFromProgram(currentProgram, parseSettings.filePath),
);
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,10 +2,9 @@ import type * as ts from 'typescript';

import path from 'node:path';

import type { ParseSettings } from '../parseSettings';

import { describeFilePath } from './describeFilePath';
import { DEFAULT_EXTRA_FILE_EXTENSIONS } from './shared';
import { ParseSettings } from '../parseSettings';

export function createProjectProgramError(
parseSettings: ParseSettings,
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,10 +3,9 @@ import type * as ts from 'typescript/lib/tsserverlibrary';

import debug from 'debug';

import type { ProjectServiceOptions } from '../parser-options';

import { getParsedConfigFile } from './getParsedConfigFile';
import { validateDefaultProjectForFilesGlob } from './validateDefaultProjectForFilesGlob';
import { ProjectServiceOptions } from '@typescript-eslint/types';

const DEFAULT_PROJECT_MATCHED_FILES_THRESHOLD = 8;

Expand Down
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
import debug from 'debug';
import * as ts from 'typescript';

import type { ParseSettings } from '../parseSettings';
import type { ASTAndNoProgram } from './shared';

import { isSourceFile } from '../source-files';
import { getScriptKind } from './getScriptKind';
import { ParseSettings } from '../parseSettings';
import { isSourceFile } from '../source-files';

const log = debug(
'typescript-eslint:typescript-estree:create-program:createSourceFile',
Expand Down
Loading
Loading

[8]ページ先頭

©2009-2025 Movatter.jp