@shayanthenerd/eslint-config 0.12.1 → 0.13.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/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  A modern, flexible ESLint configuration for enforcing best practices and maintaining a consistent coding style.
4
4
 
5
- - **Performant**: Powered by [OXLint](https://oxc.rs/docs/guide/usage/linter) for rapid linting
5
+ - **Performant**: Powered by [OXLint (OXC Linter)](https://oxc.rs/docs/guide/usage/linter) for rapid linting
6
6
  - **Flat Config**: Type-safe [ESLint Flat Config](https://eslint.org/docs/latest/use/configure/configuration-files) with `extends` and `overrides` support
7
7
  - **Comprehensive**: Dependency detection with support for TypeScript, Vue & Nuxt, Tailwind, Storybook, Vitest & Playwright, and more
8
8
  - **Automatic Formatting**: Fine-grained control over formatting with [ESLint Stylistic](https://eslint.style), eliminating the need for Prettier
@@ -138,17 +138,29 @@ This config uses [ESLint Stylistic](https://eslint.style) to format JavaScript a
138
138
  npm i -D prettier
139
139
  ```
140
140
 
141
- 2. Create a Prettier config file (_prettier.config.js_) in the root of your project:
141
+ 2. Create a Prettier config file in the root of your project (_prettier.config.js_):
142
142
  ```js
143
143
  import prettierConfig from '@shayanthenerd/eslint-config/prettier';
144
144
 
145
145
  /** @type {import('prettier').Config} */
146
146
  export default {
147
147
  ...prettierConfig,
148
- semi: false, // Override the `semi` option from the shared config
148
+ semi: false, // Override `semi` from the shared config
149
149
  };
150
150
  ```
151
151
 
152
+ Or if you prefer using TypeScrpit (_prettier.config.ts_):
153
+ ```ts
154
+ import type { Config } from 'prettier';
155
+
156
+ import prettierConfig from '@shayanthenerd/eslint-config/prettier';
157
+
158
+ export default {
159
+ ...prettierConfig,
160
+ semi: true, // Override `semi` from the shared config
161
+ } satisfies Config;
162
+ ```
163
+
152
164
  3. To prevent conflicts with ESLint, Prettier should be configured to only format files other than JavaScript, TypeScript, HTML, and Vue. Hence, add the following script to your _package.json_ file:
153
165
  ```json
154
166
  {
@@ -259,7 +271,7 @@ Since OXLint and ESLint use separate config files, customizations made in your E
259
271
 
260
272
  `defineConfig` takes the `options` object as the first argument. `options` is thoroughly documented with JSDoc, and provides many options for rule customizations. In addition, each config object in `options.configs` accepts an `overrides` option:
261
273
  ```ts
262
- interface overrides {
274
+ interface Overrides {
263
275
  name: '',
264
276
  files: [],
265
277
  ignores: [],
@@ -13,7 +13,14 @@ function getPerfectionistConfig(options) {
13
13
  name: "shayanthenerd/perfectionist",
14
14
  files: isEnabled(vue) ? [globs.src, globs.vue] : [globs.src],
15
15
  plugins: { perfectionist: eslintPluginPerfectionist },
16
- settings: { perfectionist: { type: sortType } },
16
+ settings: { perfectionist: {
17
+ type: sortType,
18
+ specialCharacters: "trim",
19
+ fallbackSort: {
20
+ order: "asc",
21
+ type: "natural"
22
+ }
23
+ } },
17
24
  rules: getPerfectionistRules(options)
18
25
  }, overrides);
19
26
  }
@@ -17,6 +17,7 @@ function getHTMLRules(options) {
17
17
  "@html-eslint/no-obsolete-tags": "error",
18
18
  "@html-eslint/no-script-style-type": "warn",
19
19
  "@html-eslint/no-target-blank": "warn",
20
+ "@html-eslint/no-whitespace-only-children": "error",
20
21
  "@html-eslint/prefer-https": "warn",
21
22
  "@html-eslint/require-button-type": "error",
22
23
  "@html-eslint/require-closing-tags": ["warn", {
@@ -12,8 +12,8 @@ function getPerfectionistRules(options) {
12
12
  "perfectionist/sort-union-types": "warn",
13
13
  "perfectionist/sort-array-includes": "warn",
14
14
  "perfectionist/sort-intersection-types": "warn",
15
- "perfectionist/sort-named-imports": ["warn", { groupKind: "types-first" }],
16
- "perfectionist/sort-named-exports": ["warn", { groupKind: "types-first" }],
15
+ "perfectionist/sort-named-imports": "warn",
16
+ "perfectionist/sort-named-exports": "warn",
17
17
  "perfectionist/sort-imports": ["warn", {
18
18
  environment: env,
19
19
  tsconfig: tsConfig || void 0,
@@ -20,6 +20,7 @@ function getStylisticRules(options) {
20
20
  "@stylistic/comma-spacing": "warn",
21
21
  "@stylistic/comma-style": "warn",
22
22
  "@stylistic/computed-property-spacing": "warn",
23
+ "@stylistic/dot-location": ["warn", "property"],
23
24
  "@stylistic/eol-last": "warn",
24
25
  "@stylistic/exp-list-style": "warn",
25
26
  "@stylistic/function-call-argument-newline": ["warn", "consistent"],
@@ -87,6 +87,7 @@ function getTypeScriptRules(options) {
87
87
  "@typescript-eslint/no-unused-expressions": "error",
88
88
  "@typescript-eslint/no-unused-vars": "error",
89
89
  "@typescript-eslint/no-useless-constructor": "error",
90
+ "@typescript-eslint/no-useless-default-assignment": "warn",
90
91
  "@typescript-eslint/no-wrapper-object-types": "error",
91
92
  "@typescript-eslint/only-throw-error": "error",
92
93
  "@typescript-eslint/prefer-as-const": "warn",
@@ -2,6 +2,7 @@ import { RuleOptions } from "../eslintRules.mjs";
2
2
  import { ConfigWithOverrides } from "../index.mjs";
3
3
 
4
4
  //#region src/types/configOptions/perfectionist.d.ts
5
+ type SortTypeOptions = RuleOptions<'perfectionist/sort-imports'>['type'];
5
6
  interface PerfectionistOptions extends ConfigWithOverrides {
6
7
  /**
7
8
  * The type of sorting.
@@ -10,7 +11,7 @@ interface PerfectionistOptions extends ConfigWithOverrides {
10
11
  *
11
12
  * @see [Perfectionist Settings: `type` option](https://perfectionist.dev/guide/getting-started#settings)
12
13
  */
13
- sortType?: RuleOptions<'perfectionist/sort-imports'>['type'];
14
+ sortType?: Exclude<SortTypeOptions, 'type-import-first'>;
14
15
  }
15
16
  //#endregion
16
17
  export { type PerfectionistOptions };
@@ -7,7 +7,7 @@ interface BlockLang {
7
7
  style?: 'css' | 'scss' | 'postcss' | 'implicit';
8
8
  script?: 'js' | 'ts' | 'jsx' | 'tsx' | 'implicit';
9
9
  }
10
- type Macro = 'definePage' | 'defineModel' | 'defineProps' | 'defineEmits' | 'defineSlots' | 'defineCustom' | 'defineExpose' | 'defineOptions';
10
+ type Macro = 'definePage' | 'defineEmits' | 'defineModel' | 'defineProps' | 'defineSlots' | 'defineCustom' | 'defineExpose' | 'defineOptions';
11
11
  type SFCBlock = 'docs' | 'template' | 'script[setup]' | 'style[scoped]' | 'i18n[locale=en]' | 'script:not([setup])' | 'style:not([scoped])' | 'i18n:not([locale=en])';
12
12
  type VBindStyleSameNameShorthandOptions = RuleOptions<'vue/v-bind-style', 1>['sameNameShorthand'];
13
13
  interface VueOptions extends ConfigWithOverrides {