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

chore: use named import forutil#7669

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

Merged
Merged
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
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
import type { TSESTree } from '@typescript-eslint/utils';
import { AST_NODE_TYPES } from '@typescript-eslint/utils';

import* as util from '../util';
import{ createRule, getNameFromMember, MemberNameType } from '../util';

type RuleNode =
| TSESTree.BlockStatement
Expand All@@ -15,7 +15,7 @@ type Member =
| TSESTree.ProgramStatement
| TSESTree.TypeElement;

export defaultutil.createRule({
export default createRule({
name: 'adjacent-overload-signatures',
meta: {
type: 'suggestion',
Expand All@@ -36,7 +36,7 @@ export default util.createRule({
name: string;
static: boolean;
callSignature: boolean;
type:util.MemberNameType;
type: MemberNameType;
}

/**
Expand DownExpand Up@@ -72,12 +72,12 @@ export default util.createRule({
name,
static: isStatic,
callSignature: false,
type:util.MemberNameType.Normal,
type: MemberNameType.Normal,
};
}
case AST_NODE_TYPES.TSMethodSignature:
return {
...util.getNameFromMember(member, sourceCode),
...getNameFromMember(member, sourceCode),
static: isStatic,
callSignature: false,
};
Expand All@@ -86,18 +86,18 @@ export default util.createRule({
name: 'call',
static: isStatic,
callSignature: true,
type:util.MemberNameType.Normal,
type: MemberNameType.Normal,
};
case AST_NODE_TYPES.TSConstructSignatureDeclaration:
return {
name: 'new',
static: isStatic,
callSignature: false,
type:util.MemberNameType.Normal,
type: MemberNameType.Normal,
};
case AST_NODE_TYPES.MethodDefinition:
return {
...util.getNameFromMember(member, sourceCode),
...getNameFromMember(member, sourceCode),
static: isStatic,
callSignature: false,
};
Expand Down
6 changes: 3 additions & 3 deletionspackages/eslint-plugin/src/rules/array-type.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
import type { TSESTree } from '@typescript-eslint/utils';
import { AST_NODE_TYPES } from '@typescript-eslint/utils';

import* as util from '../util';
import{ createRule, isParenthesized } from '../util';

/**
* Check whatever node can be considered as simple
Expand DownExpand Up@@ -85,7 +85,7 @@ type MessageIds =
| 'errorStringGeneric'
| 'errorStringGenericSimple';

export defaultutil.createRule<Options, MessageIds>({
export default createRule<Options, MessageIds>({
name: 'array-type',
meta: {
type: 'suggestion',
Expand DownExpand Up@@ -254,7 +254,7 @@ export default util.createRule<Options, MessageIds>({
const parentParens =
readonlyPrefix &&
node.parent?.type === AST_NODE_TYPES.TSArrayType &&
!util.isParenthesized(node.parent.elementType, sourceCode);
!isParenthesized(node.parent.elementType, sourceCode);

const start = `${parentParens ? '(' : ''}${readonlyPrefix}${
typeParens ? '(' : ''
Expand Down
25 changes: 15 additions & 10 deletionspackages/eslint-plugin/src/rules/await-thenable.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
import type { TSESLint } from '@typescript-eslint/utils';
import * as tsutils from 'ts-api-utils';

import * as util from '../util';
import {
createRule,
getParserServices,
isAwaitKeyword,
isTypeAnyType,
isTypeUnknownType,
nullThrows,
NullThrowsReasons,
} from '../util';

export defaultutil.createRule({
export default createRule({
name: 'await-thenable',
meta: {
docs: {
Expand All@@ -22,13 +30,13 @@ export default util.createRule({
defaultOptions: [],

create(context) {
const services =util.getParserServices(context);
const services = getParserServices(context);
const checker = services.program.getTypeChecker();

return {
AwaitExpression(node): void {
const type = services.getTypeAtLocation(node.argument);
if (util.isTypeAnyType(type) ||util.isTypeUnknownType(type)) {
if (isTypeAnyType(type) || isTypeUnknownType(type)) {
return;
}

Expand All@@ -43,12 +51,9 @@ export default util.createRule({
messageId: 'removeAwait',
fix(fixer): TSESLint.RuleFix {
const sourceCode = context.getSourceCode();
const awaitKeyword = util.nullThrows(
sourceCode.getFirstToken(node, util.isAwaitKeyword),
util.NullThrowsReasons.MissingToken(
'await',
'await expression',
),
const awaitKeyword = nullThrows(
sourceCode.getFirstToken(node, isAwaitKeyword),
NullThrowsReasons.MissingToken('await', 'await expression'),
);

return fixer.remove(awaitKeyword);
Expand Down
7 changes: 3 additions & 4 deletionspackages/eslint-plugin/src/rules/ban-ts-comment.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
import { AST_TOKEN_TYPES } from '@typescript-eslint/utils';

import* as util from '../util';
import{ createRule, getStringLength } from '../util';

type DirectiveConfig =
| boolean
Expand All@@ -22,7 +22,7 @@ type MessageIds =
| 'tsDirectiveCommentDescriptionNotMatchPattern'
| 'tsDirectiveCommentRequiresDescription';

export defaultutil.createRule<[Options], MessageIds>({
export default createRule<[Options], MessageIds>({
name: 'ban-ts-comment',
meta: {
type: 'problem',
Expand DownExpand Up@@ -146,8 +146,7 @@ export default util.createRule<[Options], MessageIds>({
} = options;
const format = descriptionFormats.get(fullDirective);
if (
util.getStringLength(description.trim()) <
minimumDescriptionLength
getStringLength(description.trim()) < minimumDescriptionLength
) {
context.report({
data: { directive, minimumDescriptionLength },
Expand Down
4 changes: 2 additions & 2 deletionspackages/eslint-plugin/src/rules/ban-tslint-comment.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
import { AST_TOKEN_TYPES } from '@typescript-eslint/utils';

import* as util from '../util';
import{ createRule } from '../util';

// tslint regex
// https://github.com/palantir/tslint/blob/95d9d958833fd9dc0002d18cbe34db20d0fbf437/src/enableDisableRules.ts#L32
Expand All@@ -15,7 +15,7 @@ const toText = (
? ['//', text.trim()].join(' ')
: ['/*', text.trim(), '*/'].join(' ');

export defaultutil.createRule({
export default createRule({
name: 'ban-tslint-comment',
meta: {
type: 'suggestion',
Expand Down
6 changes: 3 additions & 3 deletionspackages/eslint-plugin/src/rules/ban-types.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
import type { TSESLint, TSESTree } from '@typescript-eslint/utils';
import { AST_NODE_TYPES } from '@typescript-eslint/utils';

import* as util from '../util';
import{ createRule, objectReduceKey } from '../util';

type Types = Record<
string,
Expand DownExpand Up@@ -124,7 +124,7 @@ export const TYPE_KEYWORDS = {
void: AST_NODE_TYPES.TSVoidKeyword,
};

export defaultutil.createRule<Options, MessageIds>({
export default createRule<Options, MessageIds>({
name: 'ban-types',
meta: {
type: 'suggestion',
Expand DownExpand Up@@ -256,7 +256,7 @@ export default util.createRule<Options, MessageIds>({
});
}

const keywordSelectors =util.objectReduceKey(
const keywordSelectors = objectReduceKey(
TYPE_KEYWORDS,
(acc: TSESLint.RuleListener, keyword) => {
if (bannedTypes.has(keyword)) {
Expand Down
14 changes: 9 additions & 5 deletionspackages/eslint-plugin/src/rules/block-spacing.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
import type { TSESTree } from '@typescript-eslint/utils';
import { AST_TOKEN_TYPES } from '@typescript-eslint/utils';

import * as util from '../util';
import type {
InferMessageIdsTypeFromRule,
InferOptionsTypeFromRule,
} from '../util';
import { createRule, isTokenOnSameLine } from '../util';
import { getESLintCoreRule } from '../util/getESLintCoreRule';

const baseRule = getESLintCoreRule('block-spacing');

export type Options =util.InferOptionsTypeFromRule<typeof baseRule>;
export type MessageIds =util.InferMessageIdsTypeFromRule<typeof baseRule>;
export type Options = InferOptionsTypeFromRule<typeof baseRule>;
export type MessageIds = InferMessageIdsTypeFromRule<typeof baseRule>;

export defaultutil.createRule<Options, MessageIds>({
export default createRule<Options, MessageIds>({
name: 'block-spacing',
meta: {
type: 'layout',
Expand DownExpand Up@@ -58,7 +62,7 @@ export default util.createRule<Options, MessageIds>({
*/
function isValid(left: TSESTree.Token, right: TSESTree.Token): boolean {
return (
!util.isTokenOnSameLine(left, right) ||
!isTokenOnSameLine(left, right) ||
sourceCode.isSpaceBetween!(left, right) === always
);
}
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
import type { TSESLint, TSESTree } from '@typescript-eslint/utils';
import { AST_NODE_TYPES } from '@typescript-eslint/utils';

import* as util from '../util';
import{ createRule } from '../util';

type Options = ['fields' | 'getters'];
type MessageIds =
Expand DownExpand Up@@ -40,7 +40,7 @@ const isSupportedLiteral = (
return false;
};

export defaultutil.createRule<Options, MessageIds>({
export default createRule<Options, MessageIds>({
name: 'class-literal-property-style',
meta: {
type: 'problem',
Expand Down
15 changes: 10 additions & 5 deletionspackages/eslint-plugin/src/rules/class-methods-use-this.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
import type { TSESTree } from '@typescript-eslint/utils';
import { AST_NODE_TYPES } from '@typescript-eslint/utils';

import * as util from '../util';
import {
createRule,
getFunctionHeadLoc,
getFunctionNameWithKind,
getStaticStringValue,
} from '../util';

type Options = [
{
Expand All@@ -13,7 +18,7 @@ type Options = [
];
type MessageIds = 'missingThis';

export defaultutil.createRule<Options, MessageIds>({
export default createRule<Options, MessageIds>({
name: 'class-methods-use-this',
meta: {
type: 'suggestion',
Expand DownExpand Up@@ -164,7 +169,7 @@ export default util.createRule<Options, MessageIds>({
node.key.type === AST_NODE_TYPES.PrivateIdentifier ? '#' : '';
const name =
node.key.type === AST_NODE_TYPES.Literal
?util.getStaticStringValue(node.key)
? getStaticStringValue(node.key)
: node.key.name || '';

return !exceptMethods.has(hashIfNeeded + (name ?? ''));
Expand DownExpand Up@@ -193,10 +198,10 @@ export default util.createRule<Options, MessageIds>({
if (isIncludedInstanceMethod(stackContext.member)) {
context.report({
node,
loc:util.getFunctionHeadLoc(node, sourceCode),
loc: getFunctionHeadLoc(node, sourceCode),
messageId: 'missingThis',
data: {
name:util.getFunctionNameWithKind(node),
name: getFunctionNameWithKind(node),
},
});
}
Expand Down
16 changes: 10 additions & 6 deletionspackages/eslint-plugin/src/rules/comma-dangle.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
import type { TSESTree } from '@typescript-eslint/utils';
import { AST_NODE_TYPES } from '@typescript-eslint/utils';

import * as util from '../util';
import type {
InferMessageIdsTypeFromRule,
InferOptionsTypeFromRule,
} from '../util';
import { createRule, isCommaToken } from '../util';
import { getESLintCoreRule } from '../util/getESLintCoreRule';

const baseRule = getESLintCoreRule('comma-dangle');

export type Options =util.InferOptionsTypeFromRule<typeof baseRule>;
export type MessageIds =util.InferMessageIdsTypeFromRule<typeof baseRule>;
export type Options = InferOptionsTypeFromRule<typeof baseRule>;
export type MessageIds = InferMessageIdsTypeFromRule<typeof baseRule>;

type Option = Options[0];
type NormalizedOptions = Required<
Expand DownExpand Up@@ -38,7 +42,7 @@ function normalizeOptions(options: Option): NormalizedOptions {
};
}

export defaultutil.createRule<Options, MessageIds>({
export default createRule<Options, MessageIds>({
name: 'comma-dangle',
meta: {
type: 'layout',
Expand DownExpand Up@@ -135,7 +139,7 @@ export default util.createRule<Options, MessageIds>({
function forbidComma(node: TSESTree.Node): void {
const last = getLastItem(node);
const trailing = getTrailingToken(node);
if (last && trailing &&util.isCommaToken(trailing)) {
if (last && trailing && isCommaToken(trailing)) {
context.report({
node,
messageId: 'unexpected',
Expand All@@ -149,7 +153,7 @@ export default util.createRule<Options, MessageIds>({
function forceComma(node: TSESTree.Node): void {
const last = getLastItem(node);
const trailing = getTrailingToken(node);
if (last && trailing && !util.isCommaToken(trailing)) {
if (last && trailing && !isCommaToken(trailing)) {
context.report({
node,
messageId: 'missing',
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp