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: enable eqeqeq internally#6228

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
7 changes: 7 additions & 0 deletions.eslintrc.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -106,6 +106,13 @@ module.exports = {
//

curly: ['error', 'all'],
eqeqeq: [
'error',
'always',
{
null: 'never',
},
],
'no-mixed-operators': 'error',
'no-console': 'error',
'no-process-exit': 'error',
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -65,7 +65,7 @@ export default util.createRule({
case AST_NODE_TYPES.TSDeclareFunction:
case AST_NODE_TYPES.FunctionDeclaration: {
const name = member.id?.name ?? null;
if (name === null) {
if (name == null) {
return null;
}
return {
Expand DownExpand Up@@ -143,7 +143,7 @@ export default util.createRule({

members.forEach(member => {
const method = getMemberMethod(member);
if (method === null) {
if (method == null) {
lastMethod = null;
return;
}
Expand Down
2 changes: 1 addition & 1 deletionpackages/eslint-plugin/src/rules/ban-types.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -36,7 +36,7 @@ function stringifyNode(
function getCustomMessage(
bannedType: null | string | { message?: string; fixWith?: string },
): string {
if (bannedType === null) {
if (bannedType == null) {
return '';
}

Expand Down
2 changes: 1 addition & 1 deletionpackages/eslint-plugin/src/rules/comma-spacing.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -68,7 +68,7 @@ export default createRule<Options, MessageIds>({
let previousToken = sourceCode.getFirstToken(node);
for (const element of node.elements) {
let token: TSESTree.Token | null;
if (element === null) {
if (element == null) {
token = sourceCode.getTokenAfter(previousToken!);
if (token && isCommaToken(token)) {
ignoredTokens.add(token);
Expand Down
4 changes: 2 additions & 2 deletionspackages/eslint-plugin/src/rules/member-ordering.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -489,7 +489,7 @@ function getRank(
): number {
const type = getNodeType(node);

if (type === null) {
if (type == null) {
// shouldn't happen but just in case, put it on the end
return orderConfig.length - 1;
}
Expand DownExpand Up@@ -842,7 +842,7 @@ export default util.createRule<Options, MessageIds>({
supportsModifiers,
);

if (grouped === null) {
if (grouped == null) {
return false;
}

Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -101,25 +101,25 @@ function createValidator(
let name: string | null = originalName;

name = validateUnderscore('leading', config, name, node, originalName);
if (name === null) {
if (name == null) {
// fail
return;
}

name = validateUnderscore('trailing', config, name, node, originalName);
if (name === null) {
if (name == null) {
// fail
return;
}

name = validateAffix('prefix', config, name, node, originalName);
if (name === null) {
if (name == null) {
// fail
return;
}

name = validateAffix('suffix', config, name, node, originalName);
if (name === null) {
if (name == null) {
// fail
return;
}
Expand DownExpand Up@@ -383,7 +383,7 @@ function createValidator(
modifiers: Set<Modifiers>,
): boolean {
const formats = config.format;
if (formats === null || formats.length === 0) {
if (!formats?.length) {
return true;
}

Expand DownExpand Up@@ -427,7 +427,7 @@ function isCorrectType(
context: Context,
selector: Selectors,
): boolean {
if (config.types === null) {
if (config.types == null) {
return true;
}

Expand Down
4 changes: 2 additions & 2 deletionspackages/eslint-plugin/src/rules/naming-convention.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -269,7 +269,7 @@ export default util.createRule<Options, MessageIds>({
| TSESTree.FunctionExpression,
): void {
const validator = validators.function;
if (!validator || node.id === null) {
if (!validator || node.id == null) {
return;
}

Expand DownExpand Up@@ -489,7 +489,7 @@ export default util.createRule<Options, MessageIds>({
}

const id = node.id;
if (id === null) {
if (id == null) {
return;
}

Expand Down
2 changes: 1 addition & 1 deletionpackages/eslint-plugin/src/rules/no-implied-eval.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -135,7 +135,7 @@ export default util.createRule({
node: TSESTree.NewExpression | TSESTree.CallExpression,
): void {
const calleeName = getCalleeName(node.callee);
if (calleeName === null) {
if (calleeName == null) {
return;
}

Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -147,7 +147,7 @@ export default util.createRule<Options, MessageIds>({
}

case AST_NODE_TYPES.TSNullKeyword:
return init.type === AST_NODE_TYPES.Literal && init.value === null;
return init.type === AST_NODE_TYPES.Literal && init.value == null;

case AST_NODE_TYPES.TSStringKeyword:
return (
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -25,7 +25,7 @@ export default util.createRule<Options, MessageIds>({
},
defaultOptions: [],
create(context) {
/* istanbul ignore if */ if (baseRule === null) {
/* istanbul ignore if */ if (baseRule == null) {
throw new Error(
'@typescript-eslint/no-loss-of-precision requires at least ESLint v7.1.0',
);
Expand Down
6 changes: 3 additions & 3 deletionspackages/eslint-plugin/src/rules/no-misused-promises.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -250,7 +250,7 @@ export default util.createRule<Options, MessageId>({

function checkVariableDeclaration(node: TSESTree.VariableDeclarator): void {
const tsNode = parserServices.esTreeNodeToTSNodeMap.get(node);
if (tsNode.initializer === undefined || node.init === null) {
if (tsNode.initializer === undefined || node.init == null) {
return;
}
const varType = checker.getTypeAtLocation(tsNode.name);
Expand DownExpand Up@@ -344,7 +344,7 @@ export default util.createRule<Options, MessageId>({

function checkReturnStatement(node: TSESTree.ReturnStatement): void {
const tsNode = parserServices.esTreeNodeToTSNodeMap.get(node);
if (tsNode.expression === undefined || node.argument === null) {
if (tsNode.expression === undefined || node.argument == null) {
return;
}
const contextualType = checker.getContextualType(tsNode.expression);
Expand All@@ -368,7 +368,7 @@ export default util.createRule<Options, MessageId>({
const tsNode = parserServices.esTreeNodeToTSNodeMap.get(node);
const value = tsNode.initializer;
if (
node.value === null ||
node.value == null ||
value === undefined ||
!ts.isJsxExpression(value) ||
value.expression === undefined
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -27,7 +27,7 @@ function isDefinitionWithAssignment(definition: Definition): boolean {

const variableDeclarator = definition.node;
return (
variableDeclarator.definite === true || variableDeclarator.init !== null
variableDeclarator.definite === true || variableDeclarator.init != null
);
}

Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -384,7 +384,7 @@ export default createRule<Options, MessageId>({
| TSESTree.ForStatement
| TSESTree.WhileStatement,
): void {
if (node.test === null) {
if (node.test == null) {
// e.g. `for(;;)`
return;
}
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -53,7 +53,7 @@ export default util.createRule({

const alias = tryGetAliasedSymbol(symbol, checker);

return alias !== null && symbolIsNamespaceInScope(alias);
return alias != null && symbolIsNamespaceInScope(alias);
}

function getSymbolInScope(
Expand Down
4 changes: 2 additions & 2 deletionspackages/eslint-plugin/src/rules/no-use-before-define.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -21,7 +21,7 @@ function parseOptions(options: string | Config | null): Required<Config> {

if (typeof options === 'string') {
functions = options !== 'nofunc';
} else if (typeof options === 'object' && options !== null) {
} else if (typeof options === 'object' && options != null) {
functions = options.functions !== false;
classes = options.classes !== false;
enums = options.enums !== false;
Expand DownExpand Up@@ -64,7 +64,7 @@ function isOuterEnum(
reference: TSESLint.Scope.Reference,
): boolean {
return (
variable.defs[0].type == DefinitionType.TSEnumName &&
variable.defs[0].type === DefinitionType.TSEnumName &&
variable.scope.variableScope !== reference.from.variableScope
);
}
Expand Down
8 changes: 3 additions & 5 deletionspackages/eslint-plugin/src/rules/prefer-for-of.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -24,8 +24,7 @@ export default util.createRule({
node: TSESTree.Node | null,
): node is TSESTree.VariableDeclaration {
return (
node !== null &&
node.type === AST_NODE_TYPES.VariableDeclaration &&
node?.type === AST_NODE_TYPES.VariableDeclaration &&
node.kind !== 'const' &&
node.declarations.length === 1
);
Expand All@@ -39,7 +38,7 @@ export default util.createRule({
}

function isZeroInitialized(node: TSESTree.VariableDeclarator): boolean {
return node.init !== null && isLiteral(node.init, 0);
return node.init != null && isLiteral(node.init, 0);
}

function isMatchingIdentifier(
Expand All@@ -54,8 +53,7 @@ export default util.createRule({
name: string,
): TSESTree.Expression | null {
if (
node !== null &&
node.type === AST_NODE_TYPES.BinaryExpression &&
node?.type === AST_NODE_TYPES.BinaryExpression &&
node.operator === '<' &&
isMatchingIdentifier(node.left, name) &&
node.right.type === AST_NODE_TYPES.MemberExpression &&
Expand Down
5 changes: 2 additions & 3 deletionspackages/eslint-plugin/src/rules/prefer-function-type.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -82,8 +82,7 @@ export default util.createRule({
typeof member.returnType !== 'undefined'
) {
if (
tsThisTypes !== null &&
tsThisTypes.length > 0 &&
tsThisTypes?.length &&
node.type === AST_NODE_TYPES.TSInterfaceDeclaration
) {
// the message can be confusing if we don't point directly to the `this` node instead of the whole member
Expand DownExpand Up@@ -205,7 +204,7 @@ export default util.createRule({
// inside an interface keep track of all ThisType references.
// unless it's inside a nested type literal in which case it's invalid code anyway
// we don't want to incorrectly say "it refers to name" while typescript says it's completely invalid.
if (literalNesting === 0 && tsThisTypes !== null) {
if (literalNesting === 0 && tsThisTypes != null) {
tsThisTypes.push(node);
}
},
Expand Down
2 changes: 1 addition & 1 deletionpackages/eslint-plugin/src/rules/prefer-includes.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -38,7 +38,7 @@ export default createRule({

function isNumber(node: TSESTree.Node, value: number): boolean {
const evaluated = getStaticValue(node, globalScope);
return evaluated !== null && evaluated.value === value;
return evaluated != null && evaluated.value === value;
}

function isPositiveCheck(node: TSESTree.BinaryExpression): boolean {
Expand Down
2 changes: 1 addition & 1 deletionpackages/eslint-plugin/src/rules/prefer-regexp-exec.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -123,7 +123,7 @@ export default createRule({

if (
argumentNode.type === AST_NODE_TYPES.Literal &&
typeof argumentNode.value == 'string'
typeof argumentNode.value === 'string'
) {
const regExp = RegExp(argumentNode.value);
return context.report({
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -60,7 +60,7 @@ export default createRule({
*/
function isNull(node: TSESTree.Node): node is TSESTree.Literal {
const evaluated = getStaticValue(node, globalScope);
return evaluated != null && evaluated.value === null;
return evaluated != null && evaluated.value == null;
}

/**
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -121,7 +121,7 @@ export default createRule({
const unionTypes = unionTypeParts(discriminantType);
const caseTypes: Set<ts.Type> = new Set();
for (const switchCase of node.cases) {
if (switchCase.test === null) {
if (switchCase.test == null) {
// Switch has 'default' branch - do nothing.
return;
}
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -87,7 +87,7 @@ export default util.createRule<Options, MessageIds>({
}
},
Program(node): void {
if (lib === 'always' && path === 'always' && types == 'always') {
if (lib === 'always' && path === 'always' && types === 'always') {
return;
}
programNode = node;
Expand Down
2 changes: 1 addition & 1 deletionpackages/eslint-plugin/src/util/isNullLiteral.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,5 +2,5 @@ import type { TSESTree } from '@typescript-eslint/utils';
import { AST_NODE_TYPES } from '@typescript-eslint/utils';

export function isNullLiteral(i: TSESTree.Node): boolean {
return i.type === AST_NODE_TYPES.Literal && i.value === null;
return i.type === AST_NODE_TYPES.Literal && i.value == null;
}
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -638,7 +638,7 @@ type Foo = string | {
})
.filter(
(error): error is TSESLint.TestCaseError<MessageIds> =>
error !== null,
error != null,
),
};
if (invalid.errors.length > 0) {
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1083,7 +1083,7 @@ function addOptional<
function makeOptional(code: string): string;
function makeOptional(code: string | null | undefined): string | null;
function makeOptional(code: string | null | undefined): string | null {
if (code === null || code === undefined) {
if (code == null) {
return null;
}
return (
Expand Down
2 changes: 1 addition & 1 deletionpackages/scope-manager/src/ScopeManager.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -140,7 +140,7 @@ class ScopeManager {
protected nestScope<T extends Scope>(scope: T): T;
protected nestScope(scope: Scope): Scope {
if (scope instanceof GlobalScope) {
assert(this.currentScope === null);
assert(this.currentScope == null);
this.globalScope = scope;
}
this.currentScope = scope;
Expand Down
2 changes: 1 addition & 1 deletionpackages/scope-manager/src/referencer/ClassVisitor.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -163,7 +163,7 @@ class ClassVisitor extends Visitor {
* }
*/
if (
keyName !== null &&
keyName != null &&
this.#classNode.body.body.find(
(node): node is TSESTree.MethodDefinition =>
node !== methodNode &&
Expand Down
5 changes: 1 addition & 4 deletionspackages/scope-manager/src/referencer/PatternVisitor.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -97,10 +97,7 @@ class PatternVisitor extends VisitorBase {

this.#callback(pattern, {
topLevel: pattern === this.#rootPattern,
rest:
lastRestElement !== null &&
lastRestElement !== undefined &&
lastRestElement.argument === pattern,
rest: lastRestElement != null && lastRestElement.argument === pattern,
assignments: this.#assignments,
});
}
Expand Down
4 changes: 2 additions & 2 deletionspackages/scope-manager/src/referencer/Referencer.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -124,7 +124,7 @@ class Referencer extends Visitor {
}

private referenceJsxPragma(): void {
if (this.#jsxPragma === null || this.#hasReferencedJsxFactory) {
if (this.#jsxPragma == null || this.#hasReferencedJsxFactory) {
return;
}
this.#hasReferencedJsxFactory = this.referenceInSomeUpperScope(
Expand All@@ -134,7 +134,7 @@ class Referencer extends Visitor {

private referenceJsxFragment(): void {
if (
this.#jsxFragmentName === null ||
this.#jsxFragmentName == null ||
this.#hasReferencedJsxFragmentFactory
) {
return;
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp