@ntnyq/eslint-config 2.0.0-beta.5 → 2.0.0-beta.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/jsonc.js DELETED
@@ -1,118 +0,0 @@
1
- import jsoncPlugin, { configs } from 'eslint-plugin-jsonc'
2
- import jsoncParser from 'jsonc-eslint-parser'
3
- import { GLOB_JSON, GLOB_JSON5, GLOB_JSONC } from './shared.js'
4
-
5
- /** @type {import('eslint-define-config').FlatESLintConfig[]} */
6
- export const jsonc = [
7
- {
8
- files: [GLOB_JSON, GLOB_JSON5, GLOB_JSONC, '**/*rc'],
9
- plugins: {
10
- jsonc: jsoncPlugin,
11
- },
12
- languageOptions: {
13
- parser: jsoncParser,
14
- },
15
- rules: {
16
- ...configs['recommended-with-jsonc'].rules,
17
- 'jsonc/array-bracket-spacing': ['error', 'never'],
18
- 'jsonc/comma-dangle': ['error', 'never'],
19
- 'jsonc/comma-style': ['error', 'last'],
20
- 'jsonc/indent': ['error', 2],
21
- 'jsonc/key-spacing': [
22
- 'error',
23
- {
24
- beforeColon: false,
25
- afterColon: true,
26
- },
27
- ],
28
- 'jsonc/no-octal-escape': 'error',
29
- 'jsonc/object-curly-newline': [
30
- 'error',
31
- {
32
- multiline: true,
33
- consistent: true,
34
- },
35
- ],
36
- 'jsonc/object-curly-spacing': ['error', 'always'],
37
- 'jsonc/object-property-newline': [
38
- 'error',
39
- {
40
- allowMultiplePropertiesPerLine: true,
41
- },
42
- ],
43
- },
44
- },
45
- ]
46
-
47
- /** @type {import('eslint-define-config').FlatESLintConfig[]} */
48
- export const pkgOrder = [
49
- {
50
- files: ['**/package.json'],
51
- rules: {
52
- 'jsonc/sort-keys': [
53
- 'error',
54
- {
55
- pathPattern: '^$',
56
- order: [
57
- 'publisher',
58
- 'name',
59
- 'displayName',
60
- 'type',
61
- 'version',
62
- 'private',
63
- 'packageManager',
64
- 'description',
65
- 'keywords',
66
- 'license',
67
- 'author',
68
- 'homepage',
69
- 'repository',
70
- 'funding',
71
- 'exports',
72
- 'main',
73
- 'module',
74
- 'unpkg',
75
- 'jsdelivr',
76
- // workaround for `type: "module"` with TS `moduleResolution: "node16"`
77
- 'types',
78
- 'typesVersions',
79
- 'bin',
80
- 'icon',
81
- 'files',
82
- 'sideEffects',
83
- 'scripts',
84
- 'peerDependencies',
85
- 'peerDependenciesMeta',
86
- 'dependencies',
87
- 'optionalDependencies',
88
- 'devDependencies',
89
- 'activationEvents',
90
- 'contributes',
91
- 'categories',
92
- 'engines',
93
- 'pnpm',
94
- 'overrides',
95
- 'resolutions',
96
- 'husky',
97
- 'prettier',
98
- 'nano-staged',
99
- 'lint-staged',
100
- 'eslintConfig',
101
- ],
102
- },
103
- {
104
- pathPattern: '^(?:dev|peer|optional|bundled)?[Dd]ependencies$',
105
- order: { type: 'asc' },
106
- },
107
- {
108
- pathPattern: '^exports.*$',
109
- order: ['types', 'require', 'import'],
110
- },
111
- {
112
- pathPattern: '^scripts$',
113
- order: { type: 'asc' },
114
- },
115
- ],
116
- },
117
- },
118
- ]
package/lib/markdown.js DELETED
@@ -1,47 +0,0 @@
1
- import markdownPlugin from 'eslint-plugin-markdown'
2
- import tsPlugin from '@typescript-eslint/eslint-plugin'
3
- import { GLOB_MARKDOWN, GLOB_SRC, GLOB_VUE } from './shared.js'
4
-
5
- /** @type {import('eslint-define-config').FlatESLintConfig[]} */
6
- export const markdown = [
7
- {
8
- files: [GLOB_MARKDOWN],
9
- plugins: {
10
- markdown: markdownPlugin,
11
- },
12
- processor: 'markdown/markdown',
13
- },
14
- {
15
- files: [`**/*.md/${GLOB_SRC}`, `**/*.md/${GLOB_VUE}`],
16
- languageOptions: {
17
- parserOptions: {
18
- ecmaFeatures: {
19
- impliedStrict: true,
20
- },
21
- },
22
- },
23
- plugins: {
24
- '@typescript-eslint': tsPlugin,
25
- },
26
- rules: {
27
- ...markdownPlugin.configs.recommended.overrides[1].rules,
28
- 'no-undef': 'off',
29
- 'no-alert': 'off',
30
- 'no-console': 'off',
31
- 'no-unused-vars': 'off',
32
- 'no-unused-expressions': 'off',
33
- 'no-restricted-imports': 'off',
34
-
35
- 'import/no-unresolved': 'off',
36
-
37
- '@typescript-eslint/comma-dangle': 'off',
38
- '@typescript-eslint/no-redeclare': 'off',
39
- '@typescript-eslint/no-unused-vars': 'off',
40
- '@typescript-eslint/no-var-requires': 'off',
41
- '@typescript-eslint/no-use-before-define': 'off',
42
-
43
- 'unused-imports/no-unused-imports': 'off',
44
- 'unused-imports/no-unused-vars': 'off',
45
- },
46
- },
47
- ]
package/lib/presets.js DELETED
@@ -1,60 +0,0 @@
1
- // @ts-check
2
-
3
- import { ts } from './ts.js'
4
- import { yml } from './yml.js'
5
- import { vue } from './vue.js'
6
- import { astro } from './astro.js'
7
- import { prettier } from './prettier.js'
8
- import { markdown } from './markdown.js'
9
- import { jsonc, pkgOrder } from './jsonc.js'
10
- import { imports, js, jsx, unicorn } from './js.js'
11
- import { eslintComments } from './eslint-comments.js'
12
- import { GLOB_EXCLUDE } from './shared.js'
13
-
14
- /**
15
- * @typedef { import('eslint-define-config').FlatESLintConfig } FlatESLintConfig
16
- */
17
-
18
- /** @type {FlatESLintConfig[]} */
19
- export const basic = [
20
- { ignores: GLOB_EXCLUDE },
21
- ...js,
22
- ...jsx,
23
- ...ts,
24
- ...vue,
25
- ...yml,
26
- ...imports,
27
- ...unicorn,
28
- ...jsonc,
29
- ...pkgOrder,
30
- ...markdown,
31
- ...eslintComments,
32
- ]
33
-
34
- /** @type {FlatESLintConfig[]} */
35
- export const all = [...vue, ...astro, ...basic, ...prettier]
36
-
37
- /** @type {(config?: FlatESLintConfig | FlatESLintConfig[], enables?: Partial<{
38
- * vue: boolean
39
- * prettier: boolean
40
- * markdown: boolean
41
- * }>) => FlatESLintConfig[]} */
42
- export function ntnyq(
43
- config = [],
44
- { vue: enableVue = true, prettier: enablePrettier = true, markdown: enableMarkdown = true } = {},
45
- ) {
46
- const configs = [...basic]
47
- if (enableVue !== false) {
48
- configs.push(...vue)
49
- }
50
- if (enableMarkdown !== false) {
51
- configs.push(...markdown)
52
- }
53
- if (enablePrettier !== false) {
54
- configs.push(...prettier)
55
- }
56
- if (Object.keys(config).length > 0) {
57
- configs.push(...(Array.isArray(config) ? config : [config]))
58
- }
59
- return configs
60
- }
package/lib/prettier.js DELETED
@@ -1,16 +0,0 @@
1
- import prettierPlugin from 'eslint-plugin-prettier'
2
- import prettierConfig from 'eslint-config-prettier'
3
-
4
- /** @type {import('eslint-define-config').FlatESLintConfigItem[]} */
5
- export const prettier = [
6
- {
7
- plugins: {
8
- prettier: prettierPlugin,
9
- },
10
- rules: {
11
- ...prettierConfig.rules,
12
- ...prettierPlugin.configs.recommended.rules,
13
- 'prettier/prettier': 'warn',
14
- },
15
- },
16
- ]
package/lib/shared.js DELETED
@@ -1,62 +0,0 @@
1
- // @ts-check
2
-
3
- export const GLOB_SRC = '**/*.?([mt])[jt]s?(x)'
4
-
5
- export const GLOB_JS = '**/*.?([mt])js'
6
- export const GLOB_JSX = '**/*.?([mt])jsx'
7
-
8
- export const GLOB_TS = '**/*.?([mt])ts'
9
- export const GLOB_TSX = '**/*.?([mt])tsx'
10
-
11
- export const GLOB_STYLE = '**/*.{c,le,sc}ss'
12
- export const GLOB_CSS = '**/*.css'
13
- export const GLOB_LESS = '**/*.less'
14
- export const GLOB_SCSS = '**/*.scss'
15
-
16
- export const GLOB_JSON = '**/*.json'
17
- export const GLOB_JSON5 = '**/*.json5'
18
- export const GLOB_JSONC = '**/*.jsonc'
19
-
20
- export const GLOB_VUE = '**/*.vue'
21
- export const GLOB_ASTRO = '**/*.astro'
22
-
23
- export const GLOB_MARKDOWN = '**/*.md'
24
- export const GLOB_YAML = '**/*.y?(a)ml'
25
- export const GLOB_HTML = '**/*.htm?(l)'
26
-
27
- export const GLOB_ALL_SRC = [
28
- GLOB_SRC,
29
- GLOB_STYLE,
30
- GLOB_JSON,
31
- GLOB_JSON5,
32
- GLOB_MARKDOWN,
33
- GLOB_VUE,
34
- GLOB_YAML,
35
- GLOB_HTML,
36
- ]
37
-
38
- export const GLOB_NODE_MODULES = '**/node_modules/**'
39
- export const GLOB_DIST = '**/dist/**'
40
- export const GLOB_LOCKFILE = ['**/package-lock.json', '**/yarn.lock', '**/pnpm-lock.yaml']
41
- export const GLOB_EXCLUDE = [
42
- GLOB_NODE_MODULES,
43
- GLOB_DIST,
44
- ...GLOB_LOCKFILE,
45
- '**/CHANGELOG*.md',
46
- '**/*.min.*',
47
- '**/LICENSE*',
48
- '**/output',
49
- '**/coverage',
50
- '**/temp',
51
- '**/cache',
52
- '**/fixtures',
53
- '**/.vitepress/cache',
54
- '**/.nuxt',
55
- '**/.vercel',
56
- '**/.changeset',
57
- '**/__snapshots__',
58
- '**/auto-import.d.ts',
59
- '**/components.d.ts',
60
- '**/.npmrc',
61
- '**/.yarnrc',
62
- ]
package/lib/ts.js DELETED
@@ -1,77 +0,0 @@
1
- import tsParser from '@typescript-eslint/parser'
2
- import tsPlugin from '@typescript-eslint/eslint-plugin'
3
- import { GLOB_TS, GLOB_TSX } from './shared.js'
4
-
5
- export { tsParser, tsPlugin }
6
-
7
- /** @type {import('eslint-define-config').FlatESLintConfig[]} */
8
- export const ts = [
9
- {
10
- files: [GLOB_TS, GLOB_TSX],
11
- languageOptions: {
12
- parser: tsParser,
13
- parserOptions: {
14
- sourceType: 'module',
15
- },
16
- },
17
- plugins: {
18
- '@typescript-eslint': tsPlugin,
19
- },
20
- rules: {
21
- ...tsPlugin.configs['eslint-recommended'].overrides[0].rules,
22
- ...tsPlugin.configs.recommended.rules,
23
-
24
- '@typescript-eslint/no-unused-vars': 'error',
25
- '@typescript-eslint/no-redeclare': 'error',
26
- '@typescript-eslint/consistent-type-imports': [
27
- 'error',
28
- {
29
- prefer: 'type-imports',
30
- fixStyle: 'separate-type-imports',
31
- disallowTypeAnnotations: false,
32
- },
33
- ],
34
- '@typescript-eslint/prefer-as-const': 'warn',
35
-
36
- '@typescript-eslint/ban-types': 'off',
37
- '@typescript-eslint/camelcase': 'off',
38
- '@typescript-eslint/no-namespace': 'off',
39
- '@typescript-eslint/ban-ts-ignore': 'off',
40
- '@typescript-eslint/ban-ts-comment': 'off',
41
- '@typescript-eslint/no-explicit-any': 'off',
42
- '@typescript-eslint/no-empty-function': 'off',
43
- '@typescript-eslint/naming-convention': 'off',
44
- '@typescript-eslint/no-empty-interface': 'off',
45
- '@typescript-eslint/no-non-null-assertion': 'off',
46
- '@typescript-eslint/triple-slash-reference': 'off',
47
- '@typescript-eslint/no-parameter-properties': 'off',
48
- '@typescript-eslint/explicit-member-accessibility': 'off',
49
- '@typescript-eslint/explicit-function-return-type': 'off',
50
- '@typescript-eslint/explicit-module-boundary-types': 'off',
51
- '@typescript-eslint/consistent-indexed-object-style': 'off',
52
- },
53
- },
54
-
55
- {
56
- files: ['**/*.d.ts'],
57
- rules: {
58
- 'import/no-duplicates': 'off',
59
- 'import/newline-after-import': 'off',
60
- },
61
- },
62
-
63
- {
64
- files: ['**/*.{spec,test}.ts?(x)'],
65
- rules: {
66
- 'no-unused-expressions': 'off',
67
- 'max-lines-per-function': 'off',
68
- },
69
- },
70
-
71
- {
72
- files: ['**/*.js', '**/*.cjs'],
73
- rules: {
74
- '@typescript-eslint/no-var-requires': 'off',
75
- },
76
- },
77
- ]
package/lib/vue.js DELETED
@@ -1,62 +0,0 @@
1
- import { getPackageInfoSync } from 'local-pkg'
2
- import vuePlugin from 'eslint-plugin-vue'
3
- import vueParser from 'vue-eslint-parser'
4
- import tsPlugin from '@typescript-eslint/eslint-plugin'
5
- import { ts } from './ts.js'
6
- import { GLOB_VUE } from './shared.js'
7
-
8
- export { vueParser, vuePlugin }
9
-
10
- export function getVueVersion() {
11
- const pkg = getPackageInfoSync('vue', { paths: [process.cwd()] })
12
- if (pkg && typeof pkg.version === 'string' && !Number.isNaN(+pkg.version[0])) {
13
- return +pkg.version[0]
14
- }
15
- return 3
16
- }
17
- const isVue3 = getVueVersion() === 3
18
-
19
- /** @type {import('eslint-define-config').Rules} */
20
- const vueBaseRules = {}
21
-
22
- /** @type {import('eslint-define-config').Rules} */
23
- const vue2Rules = {
24
- ...vueBaseRules,
25
- }
26
-
27
- /** @type {import('eslint-define-config').Rules} */
28
- const vue3Rules = {
29
- ...vueBaseRules,
30
- }
31
-
32
- /** @type {import('eslint-define-config').FlatESLintConfig[]} */
33
- export const vue = [
34
- {
35
- files: [GLOB_VUE],
36
- plugins: {
37
- vue: vuePlugin,
38
- '@typescript-eslint': tsPlugin,
39
- },
40
- languageOptions: {
41
- parser: vueParser,
42
- parserOptions: {
43
- parser: '@typescript-eslint/parser',
44
- sourceType: 'module',
45
- extraFileExtensions: ['.vue'],
46
- ecmaFeatures: {
47
- jsx: true,
48
- },
49
- },
50
- },
51
- processor: vuePlugin.processors['.vue'],
52
- rules: {
53
- ...ts[0].rules,
54
- },
55
- },
56
- {
57
- plugins: {
58
- vue: vuePlugin,
59
- },
60
- rules: isVue3 ? vue3Rules : vue2Rules,
61
- },
62
- ]
package/lib/yml.js DELETED
@@ -1,21 +0,0 @@
1
- import ymlPlugin, { configs } from 'eslint-plugin-yml'
2
- import ymlParser from 'yaml-eslint-parser'
3
- import { GLOB_YAML } from './shared.js'
4
-
5
- /** @type {import('eslint-define-config').FlatESLintConfig[]} */
6
- export const yml = [
7
- {
8
- files: [GLOB_YAML],
9
- languageOptions: {
10
- parser: ymlParser,
11
- },
12
- plugins: {
13
- yml: ymlPlugin,
14
- },
15
- rules: {
16
- ...configs.standard.rules,
17
- ...configs.prettier.rules,
18
- 'yml/no-empty-mapping-value': 'off',
19
- },
20
- },
21
- ]