@straub/eslint-config 0.0.0-stage → 0.1.1

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 David Straub
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,137 @@
1
- # Temporary Holding Version
1
+ # @straub/eslint-config
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ My ESLint flat config, in two layers:
4
+
5
+ - **lint**: correctness and code-quality rules. Contains no formatting rules, so
6
+ it can sit beside Prettier or any other formatter.
7
+ - **style**: formatting rules (`@stylistic`, plus eslint-plugin-vue's layout
8
+ rules). Leave it out when a formatter owns formatting.
9
+
10
+ Optional Vue and TypeScript layers follow the same split. The config doesn't
11
+ depend on any framework.
12
+
13
+ ## Usage
14
+
15
+ ```sh
16
+ npm i -D eslint @straub/eslint-config
17
+ # for .vue files
18
+ npm i -D eslint-plugin-vue
19
+ # for TypeScript
20
+ npm i -D typescript typescript-eslint
21
+ ```
22
+
23
+ ```js
24
+ // eslint.config.js
25
+ import straub from '@straub/eslint-config';
26
+
27
+ export default await straub({ vue: true, typescript: true });
28
+ ```
29
+
30
+ Options (all optional):
31
+
32
+ | option | default | effect |
33
+ | ------------ | ------- | --------------------------------------------------- |
34
+ | `style` | `true` | include the formatting layer |
35
+ | `vue` | `false` | lint `.vue` files (needs `eslint-plugin-vue`) |
36
+ | `typescript` | `false` | lint TypeScript (needs `typescript-eslint`) |
37
+
38
+ ### With Prettier
39
+
40
+ ```js
41
+ export default await straub({ style: false, vue: true });
42
+ ```
43
+
44
+ The lint layer has no rules for `eslint-config-prettier` to switch off, so that
45
+ package isn't needed.
46
+
47
+ ### Composing by hand
48
+
49
+ The layers are exported as plain config arrays:
50
+
51
+ ```js
52
+ import { ignores, lint, style } from '@straub/eslint-config';
53
+ import { vueLint, vueStyle } from '@straub/eslint-config/vue';
54
+ import { typescript } from '@straub/eslint-config/typescript';
55
+ ```
56
+
57
+ Append your own config objects after them to override rules.
58
+
59
+ ### Nuxt and other frameworks
60
+
61
+ Framework conventions belong in the consuming project. For a Nuxt app, for example:
62
+
63
+ ```js
64
+ export default [
65
+ ...await straub({ vue: true, typescript: true }),
66
+ {
67
+ files: ['**/pages/**', '**/layouts/**', '**/app.vue', '**/error.vue'],
68
+ rules: { 'vue/multi-word-component-names': 'off' },
69
+ },
70
+ ];
71
+ ```
72
+
73
+ Nuxt's auto-imports (`defineNuxtPlugin`, …) are globals ESLint doesn't know
74
+ about. In TypeScript and `.vue` files `no-undef` is off. In plain `.js` files,
75
+ declare the globals or use TypeScript.
76
+
77
+ ## Where the rules come from
78
+
79
+ The rules are carried over from `eslint-config-standard` 17.1 and
80
+ `@nuxtjs/eslint-config` 12 / `-typescript` 12, which are eslintrc-only and stuck on
81
+ ESLint 8.
82
+
83
+ Own choices:
84
+
85
+ - `semi: always` and `comma-dangle: always-multiline` instead of standard's
86
+ settings.
87
+ - `no-console` and `no-debugger` are always `warn` (the Nuxt preset switched to
88
+ `error` when `NODE_ENV=production`).
89
+ - The TypeScript rules, `no-undef: off` among them, apply only to TypeScript and
90
+ `.vue` files (the preset applied them to every file).
91
+
92
+ Differences from the original presets:
93
+
94
+ - Rules renamed upstream since then use their new names (for example
95
+ `func-call-spacing` → `@stylistic/function-call-spacing`,
96
+ `eslint-plugin-import` → `eslint-plugin-import-x`,
97
+ `unicorn/no-array-instanceof` → `unicorn/no-instanceof-builtins`). The
98
+ source files note each rename.
99
+ - The Vue rules apply to `.vue` files only.
100
+ - `@stylistic/semi` also checks TypeScript type aliases, which ESLint 8's
101
+ core `semi` skipped.
102
+ - eslint-plugin-import-x doesn't treat members of an `export =` namespace as
103
+ named exports, so `import-x/no-named-as-default-member` misses cases like
104
+ `cytoscape.use()` that eslint-plugin-import flagged.
105
+
106
+ Comments in `src/` say which preset each group of rules comes from.
107
+
108
+ ## How the split is kept honest
109
+
110
+ A rule belongs in **style** if its `meta.type` is `layout` or
111
+ `eslint-config-prettier` turns it off; anything else belongs in **lint**.
112
+ `npm test` enforces this for every layer. The only exceptions are `curly` and
113
+ `no-unexpected-multiline`, which eslint-config-prettier lists as special rules
114
+ that can stay on. The tests also fail on unknown rules or deprecated rules that
115
+ are switched on, and they lint JS, TS and Vue samples with and without the style
116
+ layer.
117
+
118
+ ```sh
119
+ npm ci
120
+ npm run lint
121
+ npm test
122
+ ```
123
+
124
+ ## Releasing
125
+
126
+ Pushing a `v*` tag publishes the package to npm through GitHub Actions trusted
127
+ publishing (`.github/workflows/release.yml`); the tag must match the
128
+ `package.json` version:
129
+
130
+ ```sh
131
+ npm version patch # or minor / major: bumps, commits and tags
132
+ git push --follow-tags
133
+ ```
134
+
135
+ ## License
136
+
137
+ MIT
package/index.js ADDED
@@ -0,0 +1,30 @@
1
+ import { ignores } from './src/ignores.js';
2
+ import { lint } from './src/lint.js';
3
+ import { style } from './src/style.js';
4
+
5
+ export { ignores, lint, style };
6
+
7
+ /**
8
+ * Build the full config.
9
+ *
10
+ * @param {object} [options]
11
+ * @param {boolean} [options.style=true] Include the formatting layer. Set false when a formatter such as Prettier owns formatting.
12
+ * @param {boolean} [options.vue=false] Lint .vue files (needs eslint-plugin-vue).
13
+ * @param {boolean} [options.typescript=false] Lint TypeScript (needs typescript-eslint).
14
+ * @returns {Promise<import('eslint').Linter.Config[]>}
15
+ */
16
+ export default async function straub ({ style: withStyle = true, vue = false, typescript = false } = {}) {
17
+ const configs = [...ignores, ...lint];
18
+ if (withStyle) {
19
+ configs.push(...style);
20
+ }
21
+ if (vue) {
22
+ const { vueLint, vueStyle } = await import('./src/vue.js');
23
+ configs.push(...vueLint, ...(withStyle ? vueStyle : []));
24
+ }
25
+ if (typescript) {
26
+ const { typescript: ts } = await import('./src/typescript.js');
27
+ configs.push(...ts);
28
+ }
29
+ return configs;
30
+ }
package/package.json CHANGED
@@ -1,6 +1,69 @@
1
1
  {
2
2
  "name": "@straub/eslint-config",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.1",
4
+ "description": "David Straub's ESLint flat config, with correctness rules and formatting rules in separate layers",
5
+ "license": "MIT",
6
+ "author": "David Straub",
7
+ "type": "module",
8
+ "exports": {
9
+ ".": "./index.js",
10
+ "./vue": "./src/vue.js",
11
+ "./typescript": "./src/typescript.js"
12
+ },
13
+ "files": [
14
+ "index.js",
15
+ "src"
16
+ ],
17
+ "engines": {
18
+ "node": ">=20.19"
19
+ },
20
+ "scripts": {
21
+ "lint": "eslint .",
22
+ "test": "node --test"
23
+ },
24
+ "repository": {
25
+ "type": "git",
26
+ "url": "git+https://github.com/straub/eslint-config.git"
27
+ },
28
+ "keywords": [
29
+ "eslint",
30
+ "eslintconfig",
31
+ "eslint-config",
32
+ "flat-config",
33
+ "vue",
34
+ "typescript"
35
+ ],
36
+ "dependencies": {
37
+ "@stylistic/eslint-plugin": "5.10.0",
38
+ "eslint-import-resolver-typescript": "4.4.5",
39
+ "eslint-plugin-import-x": "4.18.1",
40
+ "eslint-plugin-n": "18.5.0",
41
+ "eslint-plugin-promise": "7.3.0",
42
+ "eslint-plugin-unicorn": "80.0.0",
43
+ "globals": "17.14.0"
44
+ },
45
+ "devDependencies": {
46
+ "eslint": "10.15.0",
47
+ "eslint-config-prettier": "10.1.8",
48
+ "eslint-plugin-vue": "10.12.1",
49
+ "typescript": "6.0.3",
50
+ "typescript-eslint": "8.73.0",
51
+ "vue-eslint-parser": "10.4.2"
52
+ },
53
+ "peerDependencies": {
54
+ "eslint": "^10.0.0",
55
+ "eslint-plugin-vue": "^10.0.0",
56
+ "typescript-eslint": "^8.0.0"
57
+ },
58
+ "peerDependenciesMeta": {
59
+ "eslint-plugin-vue": {
60
+ "optional": true
61
+ },
62
+ "typescript-eslint": {
63
+ "optional": true
64
+ }
65
+ },
66
+ "publishConfig": {
67
+ "access": "public"
68
+ }
69
+ }
package/src/ignores.js ADDED
@@ -0,0 +1,7 @@
1
+ /** Build output and generated files, from @nuxtjs/eslint-config 12. */
2
+ export const ignores = [
3
+ {
4
+ name: '@straub/ignores',
5
+ ignores: ['**/*.min.*', '**/*.d.ts', '**/dist/', '**/output/', '**/coverage/', '**/public/', '**/__snapshots__/'],
6
+ },
7
+ ];
package/src/lint.js ADDED
@@ -0,0 +1,170 @@
1
+ import { createNodeResolver, importX } from 'eslint-plugin-import-x';
2
+ import n from 'eslint-plugin-n';
3
+ import promise from 'eslint-plugin-promise';
4
+ import unicorn from 'eslint-plugin-unicorn';
5
+ import globals from 'globals';
6
+
7
+ /**
8
+ * Correctness and code-quality rules only. No formatting: safe to combine
9
+ * with Prettier or any other formatter.
10
+ */
11
+ export const lint = [
12
+ {
13
+ name: '@straub/lint',
14
+ languageOptions: {
15
+ ecmaVersion: 'latest',
16
+ sourceType: 'module',
17
+ parserOptions: { ecmaFeatures: { jsx: true } },
18
+ globals: { ...globals.browser, ...globals.node },
19
+ },
20
+ plugins: {
21
+ 'import-x': importX,
22
+ n,
23
+ promise,
24
+ unicorn,
25
+ },
26
+ settings: {
27
+ 'import-x/resolver-next': [createNodeResolver()],
28
+ },
29
+ rules: {
30
+ // eslint-config-standard 17 (rules renamed since then are noted)
31
+ 'accessor-pairs': ['error', { setWithoutGet: true, enforceForClassMembers: true }],
32
+ 'array-callback-return': ['error', { allowImplicit: false, checkForEach: false }],
33
+ camelcase: ['error', { allow: ['^UNSAFE_'], properties: 'never', ignoreGlobals: true }],
34
+ 'constructor-super': 'error',
35
+ 'default-case-last': 'error',
36
+ eqeqeq: ['error', 'always', { null: 'ignore' }],
37
+ 'new-cap': ['error', { newIsCap: true, capIsNew: false, properties: true }],
38
+ 'no-array-constructor': 'error',
39
+ 'no-async-promise-executor': 'error',
40
+ 'no-caller': 'error',
41
+ 'no-case-declarations': 'error',
42
+ 'no-class-assign': 'error',
43
+ 'no-compare-neg-zero': 'error',
44
+ 'no-cond-assign': 'error',
45
+ 'no-const-assign': 'error',
46
+ 'no-constant-condition': ['error', { checkLoops: false }],
47
+ 'no-control-regex': 'error',
48
+ 'no-delete-var': 'error',
49
+ 'no-dupe-args': 'error',
50
+ 'no-dupe-class-members': 'error',
51
+ 'no-dupe-keys': 'error',
52
+ 'no-duplicate-case': 'error',
53
+ 'no-useless-backreference': 'error',
54
+ 'no-empty': ['error', { allowEmptyCatch: true }],
55
+ 'no-empty-character-class': 'error',
56
+ 'no-empty-pattern': 'error',
57
+ 'no-eval': 'error',
58
+ 'no-ex-assign': 'error',
59
+ 'no-extend-native': 'error',
60
+ 'no-extra-bind': 'error',
61
+ 'no-extra-boolean-cast': 'error',
62
+ 'no-fallthrough': 'error',
63
+ 'no-func-assign': 'error',
64
+ 'no-global-assign': 'error',
65
+ 'no-implied-eval': 'error',
66
+ 'no-import-assign': 'error',
67
+ 'no-invalid-regexp': 'error',
68
+ 'no-irregular-whitespace': 'error',
69
+ 'no-iterator': 'error',
70
+ 'no-labels': ['error', { allowLoop: false, allowSwitch: false }],
71
+ 'no-lone-blocks': 'error',
72
+ 'no-loss-of-precision': 'error',
73
+ 'no-misleading-character-class': 'error',
74
+ 'no-prototype-builtins': 'error',
75
+ 'no-useless-catch': 'error',
76
+ 'no-multi-str': 'error',
77
+ 'no-new': 'error',
78
+ 'no-new-func': 'error',
79
+ 'no-object-constructor': 'error', // was no-new-object
80
+ 'no-new-native-nonconstructor': 'error', // was no-new-symbol
81
+ 'no-new-wrappers': 'error',
82
+ 'no-obj-calls': 'error',
83
+ 'no-octal': 'error',
84
+ 'no-octal-escape': 'error',
85
+ 'no-proto': 'error',
86
+ 'no-redeclare': ['error', { builtinGlobals: false }],
87
+ 'no-regex-spaces': 'error',
88
+ 'no-return-assign': ['error', 'except-parens'],
89
+ 'no-self-assign': ['error', { props: true }],
90
+ 'no-self-compare': 'error',
91
+ 'no-sequences': 'error',
92
+ 'no-shadow-restricted-names': 'error',
93
+ 'no-sparse-arrays': 'error',
94
+ 'no-template-curly-in-string': 'error',
95
+ 'no-this-before-super': 'error',
96
+ 'no-throw-literal': 'error',
97
+ 'no-undef': 'error',
98
+ 'no-undef-init': 'error',
99
+ 'no-unexpected-multiline': 'error',
100
+ 'no-unmodified-loop-condition': 'error',
101
+ 'no-unneeded-ternary': ['error', { defaultAssignment: false }],
102
+ 'no-unreachable': 'error',
103
+ 'no-unreachable-loop': 'error',
104
+ 'no-unsafe-finally': 'error',
105
+ 'no-unsafe-negation': 'error',
106
+ 'no-unused-expressions': ['error', { allowShortCircuit: true, allowTernary: true, allowTaggedTemplates: true }],
107
+ 'no-unused-vars': ['error', { args: 'none', caughtErrors: 'none', ignoreRestSiblings: true, vars: 'all' }],
108
+ 'no-use-before-define': ['error', { functions: false, classes: false, variables: false }],
109
+ 'no-useless-call': 'error',
110
+ 'no-useless-computed-key': 'error',
111
+ 'no-useless-constructor': 'error',
112
+ 'no-useless-escape': 'error',
113
+ 'no-useless-return': 'error',
114
+ 'no-void': 'error',
115
+ 'no-with': 'error',
116
+ 'one-var': ['error', { initialized: 'never' }],
117
+ 'prefer-promise-reject-errors': 'error',
118
+ 'prefer-regex-literals': ['error', { disallowRedundantWrapping: true }],
119
+ 'symbol-description': 'error',
120
+ 'use-isnan': ['error', { enforceForSwitchCase: true, enforceForIndexOf: true }],
121
+ 'valid-typeof': ['error', { requireStringLiterals: true }],
122
+ yoda: ['error', 'never'],
123
+ 'import-x/export': 'error',
124
+ 'import-x/no-absolute-path': ['error', { esmodule: true, commonjs: true, amd: false }],
125
+ 'import-x/no-named-default': 'error',
126
+ 'import-x/no-webpack-loader-syntax': 'error',
127
+ 'n/handle-callback-err': ['error', '^(err|error)$'],
128
+ 'n/no-callback-literal': 'error',
129
+ 'n/no-deprecated-api': 'error',
130
+ 'n/no-exports-assign': 'error',
131
+ 'n/no-new-require': 'error',
132
+ 'n/no-path-concat': 'error',
133
+ 'n/process-exit-as-throw': 'error',
134
+ 'promise/param-names': 'error',
135
+
136
+ // eslint-plugin-import's errors + warnings presets (no-unresolved off)
137
+ 'import-x/named': 'error',
138
+ 'import-x/namespace': 'error',
139
+ 'import-x/default': 'error',
140
+ 'import-x/no-named-as-default': 'warn',
141
+ 'import-x/no-named-as-default-member': 'warn',
142
+ 'import-x/no-duplicates': 'warn',
143
+
144
+ // @nuxtjs/eslint-config 12 (additions, and settings that override standard)
145
+ 'import-x/order': 'error',
146
+ 'import-x/first': 'error',
147
+ 'import-x/no-mutable-exports': 'error',
148
+ 'no-console': 'warn',
149
+ 'no-debugger': 'warn',
150
+ 'prefer-const': ['error', { destructuring: 'any', ignoreReadBeforeAssign: false }],
151
+ 'no-lonely-if': 'error',
152
+ curly: ['error', 'all'],
153
+ 'require-await': 'error',
154
+ 'dot-notation': 'error',
155
+ 'no-var': 'error',
156
+ 'object-shorthand': ['error', 'properties'], // severity from the preset, option kept from standard
157
+ 'no-useless-rename': 'error',
158
+ 'prefer-exponentiation-operator': 'error', // was unicorn/prefer-exponentiation-operator
159
+ 'unicorn/error-message': 'error',
160
+ 'unicorn/escape-case': 'error',
161
+ 'unicorn/no-instanceof-builtins': 'error', // was unicorn/no-array-instanceof
162
+ 'unicorn/no-new-buffer': 'error',
163
+ 'unicorn/prefer-includes': 'error',
164
+ 'unicorn/prefer-string-starts-ends-with': 'error', // was unicorn/prefer-starts-ends-with
165
+ 'unicorn/prefer-dom-node-text-content': 'error', // was unicorn/prefer-text-content
166
+ 'unicorn/prefer-type-error': 'error',
167
+ 'unicorn/throw-new-error': 'error',
168
+ },
169
+ },
170
+ ];
package/src/style.js ADDED
@@ -0,0 +1,90 @@
1
+ import stylistic from '@stylistic/eslint-plugin';
2
+ import unicorn from 'eslint-plugin-unicorn';
3
+
4
+ /**
5
+ * Formatting rules only. Leave this layer out when a formatter such as
6
+ * Prettier owns formatting.
7
+ */
8
+ export const style = [
9
+ {
10
+ name: '@straub/style',
11
+ plugins: {
12
+ '@stylistic': stylistic,
13
+ unicorn,
14
+ },
15
+ rules: {
16
+ // eslint-config-standard 17, with own overrides for semi and comma-dangle
17
+ '@stylistic/array-bracket-spacing': ['error', 'never'],
18
+ '@stylistic/arrow-spacing': ['error', { before: true, after: true }],
19
+ '@stylistic/block-spacing': ['error', 'always'],
20
+ '@stylistic/brace-style': ['error', '1tbs', { allowSingleLine: true }],
21
+ '@stylistic/comma-spacing': ['error', { before: false, after: true }],
22
+ '@stylistic/comma-style': ['error', 'last'],
23
+ '@stylistic/computed-property-spacing': ['error', 'never', { enforceForClassMembers: true }],
24
+ '@stylistic/dot-location': ['error', 'property'],
25
+ '@stylistic/eol-last': 'error',
26
+ '@stylistic/function-call-spacing': ['error', 'never'], // was func-call-spacing
27
+ '@stylistic/indent': ['error', 2, { SwitchCase: 1, VariableDeclarator: 1, outerIIFEBody: 1, MemberExpression: 1, FunctionDeclaration: { parameters: 1, body: 1 }, FunctionExpression: { parameters: 1, body: 1 }, CallExpression: { arguments: 1 }, ArrayExpression: 1, ObjectExpression: 1, ImportDeclaration: 1, flatTernaryExpressions: false, ignoreComments: false, ignoredNodes: ['TemplateLiteral *', 'JSXElement', 'JSXElement > *', 'JSXAttribute', 'JSXIdentifier', 'JSXNamespacedName', 'JSXMemberExpression', 'JSXSpreadAttribute', 'JSXExpressionContainer', 'JSXOpeningElement', 'JSXClosingElement', 'JSXFragment', 'JSXOpeningFragment', 'JSXClosingFragment', 'JSXText', 'JSXEmptyExpression', 'JSXSpreadChild'], offsetTernaryExpressions: true }],
28
+ '@stylistic/key-spacing': ['error', { beforeColon: false, afterColon: true }],
29
+ '@stylistic/keyword-spacing': ['error', { before: true, after: true }],
30
+ '@stylistic/lines-between-class-members': ['error', 'always', { exceptAfterSingleLine: true }],
31
+ '@stylistic/multiline-ternary': ['error', 'always-multiline'],
32
+ '@stylistic/new-parens': 'error',
33
+ '@stylistic/no-extra-parens': ['error', 'functions'],
34
+ '@stylistic/no-floating-decimal': 'error',
35
+ '@stylistic/no-mixed-operators': [
36
+ 'error',
37
+ {
38
+ groups: [
39
+ [
40
+ '==', '!=', '===',
41
+ '!==', '>', '>=',
42
+ '<', '<=',
43
+ ],
44
+ ['&&', '||'],
45
+ ['in', 'instanceof'],
46
+ ],
47
+ allowSamePrecedence: true,
48
+ },
49
+ ],
50
+ '@stylistic/no-mixed-spaces-and-tabs': 'error',
51
+ '@stylistic/no-multi-spaces': 'error',
52
+ '@stylistic/no-multiple-empty-lines': ['error', { max: 1, maxBOF: 0, maxEOF: 0 }],
53
+ '@stylistic/no-tabs': 'error',
54
+ '@stylistic/no-trailing-spaces': 'error',
55
+ '@stylistic/no-whitespace-before-property': 'error',
56
+ '@stylistic/object-curly-newline': ['error', { multiline: true, consistent: true }],
57
+ '@stylistic/object-curly-spacing': ['error', 'always'],
58
+ '@stylistic/object-property-newline': ['error', { allowAllPropertiesOnSameLine: true }],
59
+ '@stylistic/operator-linebreak': ['error', 'after', { overrides: { '?': 'before', ':': 'before', '|>': 'before' } }],
60
+ '@stylistic/padded-blocks': ['error', { blocks: 'never', switches: 'never', classes: 'never' }],
61
+ '@stylistic/quote-props': ['error', 'as-needed'],
62
+ '@stylistic/quotes': ['error', 'single', { avoidEscape: true, allowTemplateLiterals: 'never' }],
63
+ '@stylistic/rest-spread-spacing': ['error', 'never'],
64
+ '@stylistic/semi-spacing': ['error', { before: false, after: true }],
65
+ '@stylistic/space-before-blocks': ['error', 'always'],
66
+ '@stylistic/space-before-function-paren': ['error', 'always'],
67
+ '@stylistic/space-in-parens': ['error', 'never'],
68
+ '@stylistic/space-infix-ops': 'error',
69
+ '@stylistic/space-unary-ops': ['error', { words: true, nonwords: false }],
70
+ '@stylistic/spaced-comment': [
71
+ 'error',
72
+ 'always',
73
+ { line: { markers: ['*package', '!', '/', ',', '='] }, block: { balanced: true, markers: ['*package', '!', ',', ':', '::', 'flow-include'], exceptions: ['*'] } },
74
+ ],
75
+ '@stylistic/template-curly-spacing': ['error', 'never'],
76
+ '@stylistic/template-tag-spacing': ['error', 'never'],
77
+ '@stylistic/wrap-iife': ['error', 'any', { functionPrototypeMethods: true }],
78
+ '@stylistic/yield-star-spacing': ['error', 'both'],
79
+ 'unicode-bom': ['error', 'never'],
80
+
81
+ // own overrides of standard
82
+ '@stylistic/semi': ['error', 'always'],
83
+ '@stylistic/comma-dangle': ['error', 'always-multiline'],
84
+
85
+ // @nuxtjs/eslint-config 12 (it also turned generator-star-spacing off)
86
+ '@stylistic/arrow-parens': ['error', 'as-needed', { requireForBlockBody: true }],
87
+ 'unicorn/number-literal-case': 'error',
88
+ },
89
+ },
90
+ ];
@@ -0,0 +1,39 @@
1
+ import { createTypeScriptImportResolver } from 'eslint-import-resolver-typescript';
2
+ import tseslint from 'typescript-eslint';
3
+
4
+ const TS_FILES = ['**/*.ts', '**/*.tsx', '**/*.mts', '**/*.cts'];
5
+ const TS_AND_VUE_FILES = [...TS_FILES, '**/*.vue'];
6
+
7
+ /** typescript-eslint's recommended set, scoped to TypeScript and Vue files. */
8
+ export const typescript = [
9
+ ...tseslint.configs.recommended.flatMap(({ languageOptions, plugins, ...config }) => [
10
+ // Plugins register globally; the parser only applies to TypeScript files,
11
+ // since in .vue files vue-eslint-parser must stay the outer parser.
12
+ ...(plugins ? [{ name: `${config.name}/plugins`, plugins }] : []),
13
+ ...(languageOptions ? [{ name: `${config.name}/parser`, files: TS_FILES, languageOptions }] : []),
14
+ ...(config.rules ? [{ ...config, files: config.files ?? TS_AND_VUE_FILES }] : []),
15
+ ]),
16
+ {
17
+ name: '@straub/typescript/vue-parser',
18
+ files: ['**/*.vue'],
19
+ languageOptions: { parserOptions: { parser: tseslint.parser } },
20
+ },
21
+ {
22
+ name: '@straub/typescript',
23
+ files: TS_AND_VUE_FILES,
24
+ settings: {
25
+ // @nuxtjs/eslint-config-typescript 12 resolved imports through TypeScript
26
+ 'import-x/resolver-next': [createTypeScriptImportResolver()],
27
+ },
28
+ rules: {
29
+ // @nuxtjs/eslint-config-typescript 12
30
+ 'no-unused-vars': 'off',
31
+ '@typescript-eslint/no-unused-vars': ['error', { args: 'all', argsIgnorePattern: '^_' }],
32
+ 'no-undef': 'off',
33
+ '@typescript-eslint/ban-ts-comment': 'off',
34
+ '@typescript-eslint/no-explicit-any': 'off',
35
+ '@typescript-eslint/no-namespace': 'off',
36
+ '@typescript-eslint/triple-slash-reference': 'off',
37
+ },
38
+ },
39
+ ];
package/src/vue.js ADDED
@@ -0,0 +1,45 @@
1
+ import vuePlugin from 'eslint-plugin-vue';
2
+
3
+ // Not a layout rule, but end tags are formatting a formatter owns
4
+ // (eslint-config-prettier turns it off).
5
+ const FORMATTER_OWNED = new Set(['vue/html-end-tags']);
6
+
7
+ const recommended = vuePlugin.configs['flat/recommended'];
8
+ const recommendedRules = Object.assign({}, ...recommended.map(c => c.rules ?? {}));
9
+
10
+ const isStyleRule = name =>
11
+ FORMATTER_OWNED.has(name) || vuePlugin.rules[name.slice('vue/'.length)]?.meta.type === 'layout';
12
+
13
+ const pick = keep => Object.fromEntries(
14
+ Object.entries(recommendedRules).filter(([name]) => keep(isStyleRule(name))),
15
+ );
16
+
17
+ /** eslint-plugin-vue's recommended set without its formatting rules. */
18
+ export const vueLint = [
19
+ ...recommended.map(({ rules, ...config }) => config).filter(c => c.plugins || c.languageOptions || c.processor),
20
+ {
21
+ name: '@straub/vue/lint',
22
+ files: ['**/*.vue'],
23
+ rules: {
24
+ ...pick(isStyle => !isStyle),
25
+
26
+ // @nuxtjs/eslint-config 12
27
+ 'vue/no-parsing-error': ['error', { 'x-invalid-end-tag': false }],
28
+ },
29
+ },
30
+ ];
31
+
32
+ /** eslint-plugin-vue's recommended formatting rules. */
33
+ export const vueStyle = [
34
+ {
35
+ name: '@straub/vue/style',
36
+ files: ['**/*.vue'],
37
+ plugins: { vue: vuePlugin },
38
+ rules: {
39
+ ...pick(isStyle => isStyle),
40
+
41
+ // @nuxtjs/eslint-config 12
42
+ 'vue/max-attributes-per-line': ['error', { singleline: 5 }],
43
+ },
44
+ },
45
+ ];