Skip to content
Draft
Show file tree
Hide file tree
Changes from all 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
14 changes: 6 additions & 8 deletions .eslint-doc-generatorrc.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
const prettier = require('prettier');

const prettierConfig = require('./.prettierrc.js');
import * as prettier from 'prettier';

/** @type {import('eslint-doc-generator').GenerateOptions} */
const config = {
export default {
ignoreConfig: [
'flat/angular',
'flat/dom',
Expand All @@ -12,8 +10,8 @@ const config = {
'flat/svelte',
'flat/vue',
],
postprocess: (content) =>
prettier.format(content, { ...prettierConfig, parser: 'markdown' }),
postprocess: async (content, path) => {
const prettierConfig = await prettier.resolveConfig(path);
return prettier.format(content, { ...prettierConfig, parser: 'markdown' });
},
};

module.exports = config;
8 changes: 7 additions & 1 deletion .github/workflows/verifications.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,13 @@ jobs:
fail-fast: false
matrix:
validation-script:
['lint', 'type-check', 'format:check', 'generate-all:check']
[
'lint',
'type-check',
'format:check',
'validate-gen-all',
'bundle-check',
]
steps:
- name: Checkout
uses: actions/checkout@v6
Expand Down
16 changes: 0 additions & 16 deletions .releaserc.json

This file was deleted.

2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ each rule has three files named with its identifier (e.g. `no-debugging-utils`):

Additionally, you need to do a couple of extra things:

- Run `pnpm run generate:rules-doc` to include your rule in the "Supported Rules" table within the [README.md](./README.md)
- Run `pnpm run generate:docs` to include your rule in the "Supported Rules" table within the [README.md](./README.md)

### Custom rule creator

Expand Down
2 changes: 1 addition & 1 deletion commitlint.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = {
export default {
extends: ['@commitlint/config-conventional'],
};
File renamed without changes.
27 changes: 0 additions & 27 deletions index.d.ts

This file was deleted.

2 changes: 1 addition & 1 deletion lib/configs/angular.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import type { Linter } from 'eslint';

export = {
export default {
plugins: ['testing-library'],
rules: {
'testing-library/await-async-events': [
Expand Down
2 changes: 1 addition & 1 deletion lib/configs/dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import type { Linter } from 'eslint';

export = {
export default {
plugins: ['testing-library'],
rules: {
'testing-library/await-async-events': [
Expand Down
2 changes: 1 addition & 1 deletion lib/configs/marko.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import type { Linter } from 'eslint';

export = {
export default {
plugins: ['testing-library'],
rules: {
'testing-library/await-async-events': [
Expand Down
2 changes: 1 addition & 1 deletion lib/configs/react.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import type { Linter } from 'eslint';

export = {
export default {
plugins: ['testing-library'],
rules: {
'testing-library/await-async-events': [
Expand Down
2 changes: 1 addition & 1 deletion lib/configs/svelte.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import type { Linter } from 'eslint';

export = {
export default {
plugins: ['testing-library'],
rules: {
'testing-library/await-async-events': [
Expand Down
2 changes: 1 addition & 1 deletion lib/configs/vue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import type { Linter } from 'eslint';

export = {
export default {
plugins: ['testing-library'],
rules: {
'testing-library/await-async-events': [
Expand Down
11 changes: 4 additions & 7 deletions lib/index.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
import { legacyConfigs } from './configs';
import rules from './rules';
import {
name as packageName,
version as packageVersion,
} from '../package.json';

import type { SupportedTestingFramework } from './utils';
import type { TSESLint } from '@typescript-eslint/utils';

const {
name: packageName,
version: packageVersion,
// we can't natively import package.json as tsc will copy it into dist/
// eslint-disable-next-line @typescript-eslint/no-require-imports
} = require('../package.json') as { name: string; version: string };

type FinalConfigs = Record<
SupportedTestingFramework | `flat/${SupportedTestingFramework}`,
TSESLint.ClassicConfig.Config | TSESLint.FlatConfig.Config
Expand Down
155 changes: 83 additions & 72 deletions lib/node-utils/is-node-of-type.ts
Original file line number Diff line number Diff line change
@@ -1,76 +1,87 @@
import { AST_NODE_TYPES, ASTUtils } from '@typescript-eslint/utils';

export const isArrayExpression = ASTUtils.isNodeOfType(
AST_NODE_TYPES.ArrayExpression
);
export const isArrowFunctionExpression = ASTUtils.isNodeOfType(
AST_NODE_TYPES.ArrowFunctionExpression
);
export const isBlockStatement = ASTUtils.isNodeOfType(
AST_NODE_TYPES.BlockStatement
);
export const isCallExpression = ASTUtils.isNodeOfType(
AST_NODE_TYPES.CallExpression
);
export const isExpressionStatement = ASTUtils.isNodeOfType(
AST_NODE_TYPES.ExpressionStatement
);
export const isVariableDeclaration = ASTUtils.isNodeOfType(
AST_NODE_TYPES.VariableDeclaration
);
export const isAssignmentExpression = ASTUtils.isNodeOfType(
AST_NODE_TYPES.AssignmentExpression
);
export const isChainExpression = ASTUtils.isNodeOfType(
AST_NODE_TYPES.ChainExpression
);
export const isSequenceExpression = ASTUtils.isNodeOfType(
AST_NODE_TYPES.SequenceExpression
);
export const isImportDeclaration = ASTUtils.isNodeOfType(
AST_NODE_TYPES.ImportDeclaration
);
export const isImportDefaultSpecifier = ASTUtils.isNodeOfType(
AST_NODE_TYPES.ImportDefaultSpecifier
);
export const isTSImportEqualsDeclaration = ASTUtils.isNodeOfType(
AST_NODE_TYPES.TSImportEqualsDeclaration
);
export const isImportExpression = ASTUtils.isNodeOfType(
AST_NODE_TYPES.ImportExpression
);
export const isImportNamespaceSpecifier = ASTUtils.isNodeOfType(
AST_NODE_TYPES.ImportNamespaceSpecifier
);
export const isImportSpecifier = ASTUtils.isNodeOfType(
AST_NODE_TYPES.ImportSpecifier
);
export const isJSXAttribute = ASTUtils.isNodeOfType(
AST_NODE_TYPES.JSXAttribute
);
export const isLiteral = ASTUtils.isNodeOfType(AST_NODE_TYPES.Literal);
export const isTemplateLiteral = ASTUtils.isNodeOfType(
AST_NODE_TYPES.TemplateLiteral
);
export const isMemberExpression = ASTUtils.isNodeOfType(
AST_NODE_TYPES.MemberExpression
);
export const isNewExpression = ASTUtils.isNodeOfType(
AST_NODE_TYPES.NewExpression
);
export const isObjectExpression = ASTUtils.isNodeOfType(
AST_NODE_TYPES.ObjectExpression
);
export const isObjectPattern = ASTUtils.isNodeOfType(
AST_NODE_TYPES.ObjectPattern
);
export const isProperty = ASTUtils.isNodeOfType(AST_NODE_TYPES.Property);
export const isReturnStatement = ASTUtils.isNodeOfType(
AST_NODE_TYPES.ReturnStatement
);
export const isFunctionExpression = ASTUtils.isNodeOfType(
AST_NODE_TYPES.FunctionExpression
import type { TSESTree } from '@typescript-eslint/utils';

// Explicit type for all node-type guards to avoid leaking non-portable inferred types
type NodeGuard<T extends TSESTree.Node> = (
node: TSESTree.Node | null | undefined
) => node is T;

export const isArrayExpression: NodeGuard<TSESTree.ArrayExpression> =
ASTUtils.isNodeOfType(AST_NODE_TYPES.ArrayExpression);

export const isArrowFunctionExpression: NodeGuard<TSESTree.ArrowFunctionExpression> =
ASTUtils.isNodeOfType(AST_NODE_TYPES.ArrowFunctionExpression);

export const isBlockStatement: NodeGuard<TSESTree.BlockStatement> =
ASTUtils.isNodeOfType(AST_NODE_TYPES.BlockStatement);

export const isCallExpression: NodeGuard<TSESTree.CallExpression> =
ASTUtils.isNodeOfType(AST_NODE_TYPES.CallExpression);

export const isExpressionStatement: NodeGuard<TSESTree.ExpressionStatement> =
ASTUtils.isNodeOfType(AST_NODE_TYPES.ExpressionStatement);

export const isVariableDeclaration: NodeGuard<TSESTree.VariableDeclaration> =
ASTUtils.isNodeOfType(AST_NODE_TYPES.VariableDeclaration);

export const isAssignmentExpression: NodeGuard<TSESTree.AssignmentExpression> =
ASTUtils.isNodeOfType(AST_NODE_TYPES.AssignmentExpression);

export const isChainExpression: NodeGuard<TSESTree.ChainExpression> =
ASTUtils.isNodeOfType(AST_NODE_TYPES.ChainExpression);

export const isSequenceExpression: NodeGuard<TSESTree.SequenceExpression> =
ASTUtils.isNodeOfType(AST_NODE_TYPES.SequenceExpression);

export const isImportDeclaration: NodeGuard<TSESTree.ImportDeclaration> =
ASTUtils.isNodeOfType(AST_NODE_TYPES.ImportDeclaration);

export const isImportDefaultSpecifier: NodeGuard<TSESTree.ImportDefaultSpecifier> =
ASTUtils.isNodeOfType(AST_NODE_TYPES.ImportDefaultSpecifier);

export const isTSImportEqualsDeclaration: NodeGuard<TSESTree.TSImportEqualsDeclaration> =
ASTUtils.isNodeOfType(AST_NODE_TYPES.TSImportEqualsDeclaration);

export const isImportExpression: NodeGuard<TSESTree.ImportExpression> =
ASTUtils.isNodeOfType(AST_NODE_TYPES.ImportExpression);

export const isImportNamespaceSpecifier: NodeGuard<TSESTree.ImportNamespaceSpecifier> =
ASTUtils.isNodeOfType(AST_NODE_TYPES.ImportNamespaceSpecifier);

export const isImportSpecifier: NodeGuard<TSESTree.ImportSpecifier> =
ASTUtils.isNodeOfType(AST_NODE_TYPES.ImportSpecifier);

export const isJSXAttribute: NodeGuard<TSESTree.JSXAttribute> =
ASTUtils.isNodeOfType(AST_NODE_TYPES.JSXAttribute);

export const isLiteral: NodeGuard<TSESTree.Literal> = ASTUtils.isNodeOfType(
AST_NODE_TYPES.Literal
);
export const isFunctionDeclaration = ASTUtils.isNodeOfType(
AST_NODE_TYPES.FunctionDeclaration
export const isTemplateLiteral: NodeGuard<TSESTree.TemplateLiteral> =
ASTUtils.isNodeOfType(AST_NODE_TYPES.TemplateLiteral);

export const isMemberExpression: NodeGuard<TSESTree.MemberExpression> =
ASTUtils.isNodeOfType(AST_NODE_TYPES.MemberExpression);

export const isNewExpression: NodeGuard<TSESTree.NewExpression> =
ASTUtils.isNodeOfType(AST_NODE_TYPES.NewExpression);

export const isObjectExpression: NodeGuard<TSESTree.ObjectExpression> =
ASTUtils.isNodeOfType(AST_NODE_TYPES.ObjectExpression);

export const isObjectPattern: NodeGuard<TSESTree.ObjectPattern> =
ASTUtils.isNodeOfType(AST_NODE_TYPES.ObjectPattern);

export const isProperty: NodeGuard<TSESTree.Property> = ASTUtils.isNodeOfType(
AST_NODE_TYPES.Property
);

export const isReturnStatement: NodeGuard<TSESTree.ReturnStatement> =
ASTUtils.isNodeOfType(AST_NODE_TYPES.ReturnStatement);

export const isFunctionExpression: NodeGuard<TSESTree.FunctionExpression> =
ASTUtils.isNodeOfType(AST_NODE_TYPES.FunctionExpression);

export const isFunctionDeclaration: NodeGuard<TSESTree.FunctionDeclaration> =
ASTUtils.isNodeOfType(AST_NODE_TYPES.FunctionDeclaration);
File renamed without changes.
Loading
Loading