Skip to content

Commit

Permalink
chore: fix eslint style
Browse files Browse the repository at this point in the history
  • Loading branch information
xsjcTony committed Dec 29, 2023
1 parent 053ebef commit a039336
Show file tree
Hide file tree
Showing 16 changed files with 350 additions and 350 deletions.
4 changes: 2 additions & 2 deletions changelogithub.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ export default {
examples: { title: '🏀 Examples' },
test: { title: '🧪 Tests' },
style: { title: '🎨 Styles' },
ci: { title: '🤖 CI' }
}
ci: { title: '🤖 CI' },
},
} satisfies ChangelogOptions
16 changes: 8 additions & 8 deletions docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,29 @@ export default defineConfig({
title: `Aelita's ESLint Preset`,
titleTemplate: `:title | Aelita's ESLint Preset`,
head: [
['link', { rel: 'icon', type: 'image/svg+xml', href: '/logo-with-shadow.svg' }]
['link', { rel: 'icon', type: 'image/svg+xml', href: '/logo-with-shadow.svg' }],
],
description: "Aelita's ESLint config preset",
themeConfig: {
logo: '/logo.svg',

nav: [
{ text: 'Home', link: '/' },
{ text: 'Examples', link: '/markdown-examples' }
{ text: 'Examples', link: '/markdown-examples' },
],

sidebar: [
{
text: 'Examples',
items: [
{ text: 'Markdown Examples', link: '/markdown-examples' },
{ text: 'Runtime API Examples', link: '/api-examples' }
]
}
{ text: 'Runtime API Examples', link: '/api-examples' },
],
},
],

socialLinks: [
{ icon: 'github', link: 'https://github.com/vuejs/vitepress' }
]
}
{ icon: 'github', link: 'https://github.com/vuejs/vitepress' },
],
},
})
2 changes: 1 addition & 1 deletion docs/.vitepress/theme/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ export default {
}),
enhanceApp({ app, router, siteData }) {
// ...
}
},
} satisfies Theme
10 changes: 5 additions & 5 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ export default defineConfig(
{
typescript: {
tsconfigPath: ['./tsconfig.json', './tsconfig.node.js.json'],
projectType: 'lib'
}
projectType: 'lib',
},
},
{
rules: {
'ts/sort-type-constituents': 'off'
}
}
'ts/sort-type-constituents': 'off',
},
},
)
50 changes: 25 additions & 25 deletions src/configs/import.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type {
FlatConfigItem,
OptionsConfig,
OptionsFiles,
OptionsHasTypeScript
OptionsHasTypeScript,
} from '../types'


Expand All @@ -22,7 +22,7 @@ const importRules = ({ vue }: ImportOptions): FlatConfigItem['rules'] => ({
'import/extensions': [
'error',
'ignorePackages',
{ js: 'never', jsx: 'never', ...vue && { vue: 'always' } }
{ js: 'never', jsx: 'never', ...vue && { vue: 'always' } },
],
'import/order': [
'error',
Expand All @@ -31,31 +31,31 @@ const importRules = ({ vue }: ImportOptions): FlatConfigItem['rules'] => ({
pathGroups: [
{
pattern: '/src/**',
group: 'internal'
}
group: 'internal',
},
],
'newlines-between': 'ignore',
alphabetize: {
order: 'asc',
caseInsensitive: true
caseInsensitive: true,
},
warnOnUnassignedImports: false
}
warnOnUnassignedImports: false,
},
],
'import/named': 'error',
'import/no-mutable-exports': 'error',
'import/no-duplicates': ['error', { considerQueryString: true }],
'import/no-self-import': 'error'
'import/no-self-import': 'error',
})


const importTypescriptRules = ({ vue }: ImportOptions): FlatConfigItem['rules'] => ({
'import/extensions': [
'error',
'ignorePackages',
{ ts: 'never', tsx: 'never', ...vue && { vue: 'always' } }
{ ts: 'never', tsx: 'never', ...vue && { vue: 'always' } },
],
'import/named': 'off'
'import/named': 'off',
})


Expand All @@ -66,14 +66,14 @@ const importStylisticRules: FlatConfigItem['rules'] = {
count: 2,
// @ts-expect-error - type definition is not up-to-date
exactCount: true,
considerComments: true
}
]
considerComments: true,
},
],
}


const importTypescriptStylisticRules: FlatConfigItem['rules'] = {
'import/consistent-type-specifier-style': ['error', 'prefer-top-level']
'import/consistent-type-specifier-style': ['error', 'prefer-top-level'],
}


Expand All @@ -82,7 +82,7 @@ export const importConfig = async (options: ImportOptions = {}): Promise<FlatCon
typescript = false,
vue = false,
overrides,
files
files,
} = options

return [
Expand All @@ -91,34 +91,34 @@ export const importConfig = async (options: ImportOptions = {}): Promise<FlatCon
...files && files,
plugins: {
// @ts-expect-error - no dts file available
'import': await interopDefault(import('eslint-plugin-import'))
'import': await interopDefault(import('eslint-plugin-import')),
},
settings: {
...typescript && {
'import/parsers': {
'@typescript-eslint/parser': ['.ts', '.tsx', ...vue ? ['.vue'] : []]
}
'@typescript-eslint/parser': ['.ts', '.tsx', ...vue ? ['.vue'] : []],
},
},
'import/resolver': {
node: {
extensions: [
'.js',
'.jsx',
...typescript ? ['.ts', '.tsx'] : [],
...vue ? ['.vue'] : []
]
...vue ? ['.vue'] : [],
],
},
...typescript && { typescript: true }
}
...typescript && { typescript: true },
},
},
rules: {
...importRules(options),
...typescript && importTypescriptRules(options),
...importStylisticRules,
...typescript && importTypescriptStylisticRules,
...overrides?.import,
...typescript && overrides?.importTypescript
}
}
...typescript && overrides?.importTypescript,
},
},
]
}
50 changes: 25 additions & 25 deletions src/configs/javascript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ const javascriptRules: FlatConfigItem['rules'] = {
properties: 'never',
ignoreDestructuring: true,
ignoreImports: false,
ignoreGlobals: false
}
ignoreGlobals: false,
},
],
'dot-notation': ['error', { allowKeywords: true }],
'new-cap': [
'error',
{
newIsCap: true,
capIsNew: true,
properties: true
}
properties: true,
},
],
'no-console': ['error', { allow: ['warn', 'error'] }],
'no-multi-assign': 'error',
Expand Down Expand Up @@ -63,15 +63,15 @@ const javascriptRules: FlatConfigItem['rules'] = {
vars: 'all',
args: 'none',
ignoreRestSiblings: true,
destructuredArrayIgnorePattern: '^_'
}
destructuredArrayIgnorePattern: '^_',
},
],
eqeqeq: ['error', 'always', { 'null': 'ignore' }],
'no-with': 'error',
'default-param-last': 'error',
'no-else-return': ['error', { allowElseIf: false }],
'no-implied-eval': 'error',
'no-loss-of-precision': 'error'
'no-loss-of-precision': 'error',
}


Expand Down Expand Up @@ -101,8 +101,8 @@ const javascriptStylisticRules: FlatConfigItem['rules'] = {
'all',
{
ignoreJSX: 'multi-line',
nestedBinaryExpressions: false
}
nestedBinaryExpressions: false,
},
],
'no-extra-semi': 'error',
'no-floating-decimal': 'error',
Expand All @@ -118,16 +118,16 @@ const javascriptStylisticRules: FlatConfigItem['rules'] = {
'padding-line-between-statements': [
'error',
{ blankLine: 'always', prev: '*', next: ['class', 'function', 'iife'] },
{ blankLine: 'always', prev: ['class', 'function', 'iife'], next: '*' }
{ blankLine: 'always', prev: ['class', 'function', 'iife'], next: '*' },
],
'quote-props': ['error', 'as-needed', { keywords: true }],
quotes: [
'error',
'single',
{
avoidEscape: true,
allowTemplateLiterals: true
}
allowTemplateLiterals: true,
},
],
'rest-spread-spacing': ['error', 'never'],
semi: ['error', 'never'],
Expand All @@ -137,8 +137,8 @@ const javascriptStylisticRules: FlatConfigItem['rules'] = {
{
anonymous: 'never',
named: 'never',
asyncArrow: 'always'
}
asyncArrow: 'always',
},
],
'space-in-parens': ['error', 'never'],
'space-infix-ops': ['error', { int32Hint: false }],
Expand All @@ -148,7 +148,7 @@ const javascriptStylisticRules: FlatConfigItem['rules'] = {
'template-curly-spacing': ['error', 'never'],
'template-tag-spacing': ['error', 'never'],
'wrap-iife': ['error', 'inside', { functionPrototypeMethods: false }],
'yield-star-spacing': ['error', 'after']
'yield-star-spacing': ['error', 'after'],
}


Expand All @@ -164,32 +164,32 @@ export const javascript = ({ files, overrides }: JavascriptOptions = {}): FlatCo
...globals.node,
document: 'readonly',
navigator: 'readonly',
window: 'readonly'
window: 'readonly',
},
parserOptions: {
ecmaFeatures: {
jsx: true,
impliedStrict: true
impliedStrict: true,
},
ecmaVersion: 'latest',
sourceType: 'module'
sourceType: 'module',
},
sourceType: 'module'
sourceType: 'module',
},
linterOptions: {
reportUnusedDisableDirectives: true
reportUnusedDisableDirectives: true,
},
rules: {
...javascriptRules,
...javascriptStylisticRules,
...overrides
}
...overrides,
},
},
{
name: 'aelita:javascript:scripts-override',
files: [`scripts/${GLOB_SRC}`, `cli.${GLOB_SRC_EXT}`],
rules: {
'no-console': 'off'
}
}
'no-console': 'off',
},
},
]
20 changes: 10 additions & 10 deletions src/configs/playwright.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,40 +23,40 @@ const playwrightRules: FlatConfigItem['rules'] = {
'off',
{
ignore: ['test.describe'],
ignoreTopLevelDescribe: true
}
ignoreTopLevelDescribe: true,
},
],
'playwright/prefer-to-be': 'error',
'playwright/prefer-to-have-length': 'error',
'playwright/valid-expect': [
'error',
{
minArgs: 1,
maxArgs: 2
}
maxArgs: 2,
},
],
'playwright/prefer-web-first-assertions': 'error',
'playwright/no-networkidle': 'error',
'playwright/no-nested-step': 'error',
'playwright/prefer-to-contain': 'error',
'playwright/prefer-to-have-count': 'error',
'playwright/valid-title': 'error'
'playwright/valid-title': 'error',
}


export const playwright = async ({
files = [GLOB_PLAYWRIGHT],
overrides
overrides,
}: PlaywrightOptions): Promise<FlatConfigItem[]> => [
{
name: 'aelita:playwright',
files,
plugins: {
playwright: await interopDefault(import('eslint-plugin-playwright'))
playwright: await interopDefault(import('eslint-plugin-playwright')),
},
rules: {
...playwrightRules,
...overrides
}
}
...overrides,
},
},
]
Loading

0 comments on commit a039336

Please sign in to comment.