Update rules
This commit is contained in:
@ -1,6 +1,4 @@
|
||||
// https://github.com/typescript-eslint/typescript-eslint/blob/75c128856b1ce05a4fec799bfa6de03b3dab03d0/packages/eslint-plugin/src/rules/restrict-template-expressions.ts
|
||||
import * as ts from 'typescript';
|
||||
import { AST_NODE_TYPES, ESLintUtils, type TSESTree } from '@typescript-eslint/utils';
|
||||
import {
|
||||
getConstrainedTypeAtLocation,
|
||||
getTypeName,
|
||||
@ -8,7 +6,9 @@ import {
|
||||
isTypeFlagSet,
|
||||
isTypeNeverType,
|
||||
} from '@typescript-eslint/type-utils';
|
||||
import { AST_NODE_TYPES, ESLintUtils, type TSESTree } from '@typescript-eslint/utils';
|
||||
import { getParserServices } from '@typescript-eslint/utils/eslint-utils';
|
||||
import * as ts from 'typescript';
|
||||
|
||||
const createRule = ESLintUtils.RuleCreator(
|
||||
name => `https://typescript-eslint.io/rules/${name}`,
|
||||
|
@ -1,11 +1,12 @@
|
||||
import * as fs from 'node:fs';
|
||||
import { resolve } from 'node:path';
|
||||
|
||||
import type { Middleware } from './middleware';
|
||||
import { jsdoc } from './presets/jsdoc';
|
||||
import { reactQuery, storybook } from './presets/misc';
|
||||
import { react, reactRefresh } from './presets/react';
|
||||
import { tailwind } from './presets/tailwind';
|
||||
import { jsdoc } from './presets/jsdoc';
|
||||
import { storybook, reactQuery } from './presets/misc';
|
||||
import { testingLibrary } from './presets/testing-library';
|
||||
import type { Middleware } from './middleware';
|
||||
|
||||
const middlewares = {
|
||||
react,
|
||||
|
16
src/index.ts
16
src/index.ts
@ -1,18 +1,18 @@
|
||||
/// <reference path="./modules.d.ts" />
|
||||
import './redirect';
|
||||
import { uniq } from 'lodash';
|
||||
import type { Rule } from 'eslint';
|
||||
import type { ESLintUtils } from '@typescript-eslint/utils';
|
||||
import type { ESLintConfig, Extends, Plugin, Rules } from '@aet/eslint-define-config';
|
||||
import type { ESLintUtils } from '@typescript-eslint/utils';
|
||||
import type { Rule } from 'eslint';
|
||||
import { uniq } from 'lodash';
|
||||
|
||||
import type { Middleware, MiddlewareConfig, MiddlewareFunctions } from './middleware';
|
||||
import { importTypeScript } from './presets/typescript';
|
||||
import { unicorn } from './presets/unicorn';
|
||||
import { eslintRules } from './presets/eslint';
|
||||
import { custom } from './presets/custom';
|
||||
import { off } from './constants';
|
||||
import { checkEnv } from './env';
|
||||
import type { Middleware, MiddlewareConfig, MiddlewareFunctions } from './middleware';
|
||||
import { custom } from './presets/custom';
|
||||
import { eslintRules } from './presets/eslint';
|
||||
import { stylistic } from './presets/stylistic';
|
||||
import { importTypeScript } from './presets/typescript';
|
||||
import { unicorn } from './presets/unicorn';
|
||||
|
||||
export { graphql } from './presets/graphql';
|
||||
export { jsdoc } from './presets/jsdoc';
|
||||
|
@ -1,6 +1,7 @@
|
||||
import { installPackage } from '@antfu/install-pkg';
|
||||
import { uniq } from 'lodash';
|
||||
import { getProjectDependencies, envs } from './env';
|
||||
|
||||
import { envs, getProjectDependencies } from './env';
|
||||
|
||||
const deps = getProjectDependencies();
|
||||
const packages = uniq(
|
||||
|
@ -1,10 +1,11 @@
|
||||
import type { ESLint } from 'eslint';
|
||||
import * as fs from 'node:fs';
|
||||
import { basename, extname, isAbsolute, resolve } from 'node:path';
|
||||
import { glob } from 'fast-glob';
|
||||
|
||||
import type { ESLint } from 'eslint';
|
||||
import { parseModule } from 'esprima';
|
||||
import query from 'esquery';
|
||||
import type { Node, Property } from 'estree';
|
||||
import { glob } from 'fast-glob';
|
||||
|
||||
// https://github.com/gulpjs/interpret
|
||||
const transpilers = [
|
||||
|
@ -1,5 +1,6 @@
|
||||
import type { Merge, SetRequired } from 'type-fest';
|
||||
import type { ESLintConfig, KnownExtends, Settings } from '@aet/eslint-define-config';
|
||||
import type { Merge, SetRequired } from 'type-fest';
|
||||
|
||||
import type { RuleOptions } from './index';
|
||||
|
||||
type OptionalObjectKey<T> = Exclude<
|
||||
|
@ -1,5 +1,5 @@
|
||||
import type { LocalRuleOptions } from '../index';
|
||||
import { error } from '../constants';
|
||||
import type { LocalRuleOptions } from '../index';
|
||||
import { defineMiddleware } from '../middleware';
|
||||
|
||||
const customRules: Partial<LocalRuleOptions> = {
|
||||
|
@ -1,5 +1,7 @@
|
||||
import { type EslintRulesObject } from '@aet/eslint-define-config/src/rules/eslint';
|
||||
import type { EslintRulesObject } from '@aet/eslint-define-config/src/rules/eslint';
|
||||
|
||||
import { error, off, warn } from '../constants';
|
||||
|
||||
import restrictedGlobals from './_restrictedGlobals.json';
|
||||
|
||||
export const eslintRules: Partial<EslintRulesObject> = {
|
||||
|
@ -1,4 +1,5 @@
|
||||
import type { GraphQLRulesObject } from '@aet/eslint-define-config/src/rules/graphql-eslint';
|
||||
|
||||
import { defineMiddleware } from '../middleware';
|
||||
|
||||
// https://the-guild.dev/graphql/eslint/rules
|
||||
|
@ -1,6 +1,7 @@
|
||||
import type { JSDocRulesObject } from '@aet/eslint-define-config/src/rules/jsdoc';
|
||||
import { defineMiddleware } from '../middleware';
|
||||
|
||||
import { off } from '../constants';
|
||||
import { defineMiddleware } from '../middleware';
|
||||
|
||||
const jsdocRules: Partial<JSDocRulesObject> = {
|
||||
'jsdoc/require-jsdoc': off,
|
||||
|
@ -1,5 +1,6 @@
|
||||
import type { ReactRulesObject } from '@aet/eslint-define-config/src/rules/react';
|
||||
import type { ReactRefreshRulesObject } from '@aet/eslint-define-config/src/rules/react-refresh';
|
||||
|
||||
import { error, off, warn } from '../constants';
|
||||
import { defineMiddleware } from '../middleware';
|
||||
|
||||
|
@ -1,9 +1,10 @@
|
||||
import { error } from '../constants';
|
||||
import { defineMiddleware } from '../middleware';
|
||||
import type { StylisticRulesObject } from '@aet/eslint-define-config/src/rules/stylistic';
|
||||
|
||||
import { error } from '../constants';
|
||||
import { defineMiddleware } from '../middleware';
|
||||
|
||||
const stylisticRules: Partial<StylisticRulesObject> = {
|
||||
'stylistic/spaced-comment': [
|
||||
'@stylistic/spaced-comment': [
|
||||
error,
|
||||
'always',
|
||||
{
|
||||
@ -14,6 +15,7 @@ const stylisticRules: Partial<StylisticRulesObject> = {
|
||||
],
|
||||
};
|
||||
|
||||
export const stylistic = defineMiddleware((_, { addRules }) => {
|
||||
export const stylistic = defineMiddleware((config, { addRules }) => {
|
||||
config.plugins.push('@stylistic');
|
||||
addRules(stylisticRules);
|
||||
});
|
||||
|
@ -1,6 +1,7 @@
|
||||
import type { TailwindRulesObject } from '@aet/eslint-define-config/src/rules/tailwind';
|
||||
import { defineMiddleware } from '../middleware';
|
||||
|
||||
import { off } from '../constants';
|
||||
import { defineMiddleware } from '../middleware';
|
||||
|
||||
const tailwindRules: Partial<TailwindRulesObject> = {
|
||||
'tailwindcss/no-custom-classname': off,
|
||||
|
@ -1,4 +1,5 @@
|
||||
import type { TestingLibraryRulesObject } from '@aet/eslint-define-config/src/rules/testing-library';
|
||||
|
||||
import { defineMiddleware } from '../middleware';
|
||||
|
||||
const testingLibraryRules: Partial<TestingLibraryRulesObject> = {};
|
||||
|
@ -1,12 +1,32 @@
|
||||
import { error, off, warn } from '../constants';
|
||||
import type { TypeScriptRulesObject } from '@aet/eslint-define-config/src/rules/typescript-eslint';
|
||||
import type { ImportXRulesObject } from '@aet/eslint-define-config/src/rules/import-x';
|
||||
import type { TypeScriptRulesObject } from '@aet/eslint-define-config/src/rules/typescript-eslint';
|
||||
|
||||
import { error, off, warn } from '../constants';
|
||||
import { defineMiddleware } from '../middleware';
|
||||
|
||||
const importRules: Partial<ImportXRulesObject> = {
|
||||
'import-x/export': off,
|
||||
'import-x/first': error,
|
||||
'import-x/no-absolute-path': error,
|
||||
'import-x/no-duplicates': error,
|
||||
'import-x/order': [error, { groups: ['builtin', 'external'] }],
|
||||
'import-x/no-useless-path-segments': error,
|
||||
'import-x/order': [
|
||||
error,
|
||||
{
|
||||
groups: [
|
||||
'builtin',
|
||||
'external',
|
||||
'internal',
|
||||
'parent',
|
||||
'sibling',
|
||||
'index',
|
||||
'object',
|
||||
'type',
|
||||
],
|
||||
'newlines-between': 'always-and-inside-groups',
|
||||
alphabetize: { order: 'asc', caseInsensitive: true },
|
||||
},
|
||||
],
|
||||
'import-x/unambiguous': error,
|
||||
};
|
||||
|
||||
const typescriptRules: Partial<TypeScriptRulesObject> = {
|
||||
@ -66,8 +86,8 @@ export const importTypeScript = defineMiddleware((config, { addRules, addSetting
|
||||
files: ['.eslintrc.js', '.eslintrc.cjs', '*.config.js', 'index.js'],
|
||||
extends: ['plugin:@typescript-eslint/disable-type-checked'],
|
||||
rules: {
|
||||
'@typescript-eslint/no-require-imports': off,
|
||||
'import-x/no-commonjs': off,
|
||||
'@typescript-eslint/no-require-imports': off,
|
||||
'rules/restrict-template-expressions': off,
|
||||
},
|
||||
},
|
||||
|
@ -1,7 +1,8 @@
|
||||
/* eslint-disable unicorn/string-content */
|
||||
import type { UnicornRulesObject } from '@aet/eslint-define-config/src/rules/unicorn';
|
||||
import { defineMiddleware } from '../middleware';
|
||||
|
||||
import { error, warn } from '../constants';
|
||||
import { defineMiddleware } from '../middleware';
|
||||
|
||||
const suggest = (suggest: string) => ({ suggest, fix: false });
|
||||
|
||||
@ -85,6 +86,10 @@ const unicornRules: Partial<UnicornRulesObject> = {
|
||||
'<=>': suggest('⇔'),
|
||||
'\\.\\.\\.': suggest('…'),
|
||||
"'s ": suggest('’s '),
|
||||
"l'": suggest('l’'),
|
||||
"d'": suggest('d’'),
|
||||
'?!': suggest('⁈'),
|
||||
'!?': suggest('⁉'),
|
||||
},
|
||||
},
|
||||
],
|
||||
|
@ -1,4 +1,4 @@
|
||||
import Module from 'module';
|
||||
import Module from 'node:module';
|
||||
const { name } = [require][0]('./package.json');
|
||||
|
||||
const _resolveFilename = Module._resolveFilename;
|
||||
|
Reference in New Issue
Block a user