@shayanthenerd/eslint-config 0.1.0 → 0.2.0
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 +24 -8
- package/dist/configs/base.cjs +1 -1
- package/dist/configs/base.js +1 -1
- package/dist/configs/commons.cjs +3 -2
- package/dist/configs/commons.js +3 -2
- package/dist/configs/importX.cjs +22 -2
- package/dist/configs/importX.js +22 -2
- package/dist/configs/oxlintOverrides.cjs +3 -1
- package/dist/configs/oxlintOverrides.js +3 -1
- package/dist/configs/tailwind.cjs +3 -3
- package/dist/configs/tailwind.js +3 -3
- package/dist/configs/typescript.cjs +1 -1
- package/dist/configs/typescript.js +1 -1
- package/dist/rules/importX.cjs +12 -12
- package/dist/rules/importX.js +12 -12
- package/dist/rules/vue.cjs +4 -2
- package/dist/rules/vue.js +4 -2
- package/dist/types/configOptions/importX.d.cts +16 -7
- package/dist/types/configOptions/importX.d.ts +16 -7
- package/dist/types/eslint-schema.d.cts +475 -1
- package/dist/types/eslint-schema.d.ts +475 -1
- package/dist/utils/globs.cjs +3 -2
- package/dist/utils/globs.js +3 -2
- package/dist/utils/options/defaultOptions.cjs +2 -1
- package/dist/utils/options/defaultOptions.js +2 -1
- package/dist/utils/options/enableDetectedConfigs.cjs +8 -4
- package/dist/utils/options/enableDetectedConfigs.js +8 -4
- package/package.json +24 -28
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# @shayanthenerd/eslint-config [](https://www.npmjs.com/package/@shayanthenerd/eslint-config) [](https://github.com/ShayanTheNerd/eslint-config/blob/main/LICENSE) [](https://eslint-config.shayan-zamani.me)
|
|
2
2
|
|
|
3
3
|
A modern, flexible ESLint configuration for enforcing best practices and maintaining a consistent coding style.
|
|
4
4
|
|
|
@@ -34,9 +34,7 @@ A modern, flexible ESLint configuration for enforcing best practices and maintai
|
|
|
34
34
|
npm i -D @shayanthenerd/eslint-config
|
|
35
35
|
```
|
|
36
36
|
|
|
37
|
-
OXLint and all necessary ESLint plugins and parsers will be installed automatically
|
|
38
|
-
|
|
39
|
-
If you're using TypeScript and see [eslint-plugin-import-x](https://github.com/un-ts/eslint-plugin-import-x) fail to resolve imports, you should also install [eslint-import-resolver-typescript](https://github.com/import-js/eslint-import-resolver-typescript) as a dev dependency.
|
|
37
|
+
OXLint and all necessary ESLint plugins and parsers will be installed automatically.
|
|
40
38
|
|
|
41
39
|
2. Create an ESLint config file (_eslint.config.js_) at the root of your project:
|
|
42
40
|
```js
|
|
@@ -45,7 +43,23 @@ import { defineConfig } from '@shayanthenerd/eslint-config';
|
|
|
45
43
|
export default defineConfig();
|
|
46
44
|
```
|
|
47
45
|
|
|
48
|
-
You can also use a TypeScript file (_eslint.config.ts_)
|
|
46
|
+
You can also use a TypeScript file (_eslint.config.ts_). Depending on your Node.js version, [additional setup](https://eslint.org/docs/latest/use/configure/configuration-files#typescript-configuration-files) may be required.
|
|
47
|
+
|
|
48
|
+
If you're using Nuxt, install [@nuxt/eslint](https://eslint.nuxt.com) as a dev dependency:
|
|
49
|
+
```shell
|
|
50
|
+
npm i -D @nuxt/eslint
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Then, update your ESLint config file:
|
|
54
|
+
```js
|
|
55
|
+
import { defineConfig } from '@shayanthenerd/eslint-config';
|
|
56
|
+
|
|
57
|
+
import eslintConfigNuxt from './.nuxt/eslint.config.mjs';
|
|
58
|
+
|
|
59
|
+
const eslintConfig = defineConfig();
|
|
60
|
+
|
|
61
|
+
export default eslintConfigNuxt(eslintConfig);
|
|
62
|
+
```
|
|
49
63
|
|
|
50
64
|
3. Create an OXLint config file (_.oxlintrc.json_) in the root of your project:
|
|
51
65
|
```jsonc
|
|
@@ -123,7 +137,7 @@ npm i -D prettier
|
|
|
123
137
|
|
|
124
138
|
2. Create a Prettier config file (_prettier.config.js_) in the root of your project:
|
|
125
139
|
```js
|
|
126
|
-
import prettierConfig from '@shayanthenerd/eslint-config/prettier
|
|
140
|
+
import prettierConfig from '@shayanthenerd/eslint-config/prettier';
|
|
127
141
|
|
|
128
142
|
/** @type {import('prettier').Config} */
|
|
129
143
|
export default {
|
|
@@ -159,6 +173,7 @@ Install VS Code extensions for [ESLint](https://marketplace.visualstudio.com/ite
|
|
|
159
173
|
/* Imports are sorted and organized with eslint-plugin-perfectionist. */
|
|
160
174
|
"source.sortImports": "never",
|
|
161
175
|
"source.organizeImports": "never",
|
|
176
|
+
"source.removeUnusedImports": "never",
|
|
162
177
|
|
|
163
178
|
/* Apply OXLint and ESLint automatic fixes on file save. */
|
|
164
179
|
"source.fixAll.oxc": "explicit",
|
|
@@ -232,7 +247,7 @@ Since OXLint and ESLint use separate config files, customizations made in your E
|
|
|
232
247
|
],
|
|
233
248
|
|
|
234
249
|
/* OXLint respects the ignore patterns defined in `.gitignore` and `.eslintignore` files by default. */
|
|
235
|
-
"ignorePatterns": ["**/*.min.*"
|
|
250
|
+
"ignorePatterns": ["**/*.min.*"]
|
|
236
251
|
}
|
|
237
252
|
```
|
|
238
253
|
|
|
@@ -384,7 +399,8 @@ interface options {
|
|
|
384
399
|
overrides?: {},
|
|
385
400
|
},
|
|
386
401
|
importX?: boolean | {
|
|
387
|
-
|
|
402
|
+
removeUnusedImports?: boolean,
|
|
403
|
+
requireFileExtension?: boolean,
|
|
388
404
|
overrides?: {},
|
|
389
405
|
},
|
|
390
406
|
perfectionist?: boolean | {
|
package/dist/configs/base.cjs
CHANGED
|
@@ -14,8 +14,8 @@ function getBaseConfig(options) {
|
|
|
14
14
|
files: [require__Users_shayan_Desktop_Dev_GitHub_eslint_config_src_utils_globs.globs.src, vue ? require__Users_shayan_Desktop_Dev_GitHub_eslint_config_src_utils_globs.globs.vue : ""],
|
|
15
15
|
extends: [__eslint_js.default.configs.recommended],
|
|
16
16
|
languageOptions: {
|
|
17
|
+
parser: typescript_eslint.default.parser,
|
|
17
18
|
parserOptions: {
|
|
18
|
-
parser: typescript_eslint.default.parser,
|
|
19
19
|
ecmaVersion: "latest",
|
|
20
20
|
ecmaFeatures: {
|
|
21
21
|
jsx: true,
|
package/dist/configs/base.js
CHANGED
|
@@ -13,8 +13,8 @@ function getBaseConfig(options) {
|
|
|
13
13
|
files: [globs.src, vue ? globs.vue : ""],
|
|
14
14
|
extends: [javascriptESLint.configs.recommended],
|
|
15
15
|
languageOptions: {
|
|
16
|
+
parser: typescriptESLint.parser,
|
|
16
17
|
parserOptions: {
|
|
17
|
-
parser: typescriptESLint.parser,
|
|
18
18
|
ecmaVersion: "latest",
|
|
19
19
|
ecmaFeatures: {
|
|
20
20
|
jsx: true,
|
package/dist/configs/commons.cjs
CHANGED
|
@@ -4,14 +4,15 @@ const typescript_eslint = require_rolldown_runtime.__toESM(require("typescript-e
|
|
|
4
4
|
|
|
5
5
|
//#region src/configs/commons.ts
|
|
6
6
|
function getCommonsConfig(options) {
|
|
7
|
+
const { typescript, base: { preferNamedExports } } = options.configs;
|
|
7
8
|
const commonsConfig = {
|
|
8
9
|
name: "shayanthenerd/commons",
|
|
9
10
|
files: [require__Users_shayan_Desktop_Dev_GitHub_eslint_config_src_utils_globs.globs.commons],
|
|
10
11
|
ignores: [require__Users_shayan_Desktop_Dev_GitHub_eslint_config_src_utils_globs.globs.commonsIgnore],
|
|
11
12
|
plugins: { "@typescript-eslint": typescript_eslint.default.plugin },
|
|
12
13
|
rules: {
|
|
13
|
-
"@typescript-eslint/explicit-function-return-type": "error",
|
|
14
|
-
"no-restricted-exports": [
|
|
14
|
+
"@typescript-eslint/explicit-function-return-type": typescript ? "error" : "off",
|
|
15
|
+
"no-restricted-exports": [preferNamedExports ? "error" : "off", { restrictDefaultExports: {
|
|
15
16
|
named: true,
|
|
16
17
|
direct: true,
|
|
17
18
|
namedFrom: true,
|
package/dist/configs/commons.js
CHANGED
|
@@ -3,14 +3,15 @@ import typescriptESLint from "typescript-eslint";
|
|
|
3
3
|
|
|
4
4
|
//#region src/configs/commons.ts
|
|
5
5
|
function getCommonsConfig(options) {
|
|
6
|
+
const { typescript, base: { preferNamedExports } } = options.configs;
|
|
6
7
|
const commonsConfig = {
|
|
7
8
|
name: "shayanthenerd/commons",
|
|
8
9
|
files: [globs.commons],
|
|
9
10
|
ignores: [globs.commonsIgnore],
|
|
10
11
|
plugins: { "@typescript-eslint": typescriptESLint.plugin },
|
|
11
12
|
rules: {
|
|
12
|
-
"@typescript-eslint/explicit-function-return-type": "error",
|
|
13
|
-
"no-restricted-exports": [
|
|
13
|
+
"@typescript-eslint/explicit-function-return-type": typescript ? "error" : "off",
|
|
14
|
+
"no-restricted-exports": [preferNamedExports ? "error" : "off", { restrictDefaultExports: {
|
|
14
15
|
named: true,
|
|
15
16
|
direct: true,
|
|
16
17
|
namedFrom: true,
|
package/dist/configs/importX.cjs
CHANGED
|
@@ -4,19 +4,39 @@ const require__Users_shayan_Desktop_Dev_GitHub_eslint_config_src_utils_isEnabled
|
|
|
4
4
|
const require__Users_shayan_Desktop_Dev_GitHub_eslint_config_src_utils_options_defaultOptions = require('../utils/options/defaultOptions.cjs');
|
|
5
5
|
const require__Users_shayan_Desktop_Dev_GitHub_eslint_config_src_rules_importX = require('../rules/importX.cjs');
|
|
6
6
|
const eslint_flat_config_utils = require_rolldown_runtime.__toESM(require("eslint-flat-config-utils"));
|
|
7
|
+
const eslint_plugin_import = require_rolldown_runtime.__toESM(require("eslint-plugin-import"));
|
|
7
8
|
const eslint_plugin_import_x = require_rolldown_runtime.__toESM(require("eslint-plugin-import-x"));
|
|
8
9
|
const eslint_plugin_unused_imports = require_rolldown_runtime.__toESM(require("eslint-plugin-unused-imports"));
|
|
9
10
|
|
|
10
11
|
//#region src/configs/importX.ts
|
|
12
|
+
eslint_plugin_import.default.flatConfigs.recommended.rules = {};
|
|
11
13
|
function getImportXConfig(options) {
|
|
12
14
|
const { vue, importX, typescript } = options.configs;
|
|
13
15
|
const { overrides } = require__Users_shayan_Desktop_Dev_GitHub_eslint_config_src_utils_isEnabled.isEnabled(importX) ? importX : require__Users_shayan_Desktop_Dev_GitHub_eslint_config_src_utils_options_defaultOptions.defaultOptions.configs.importX;
|
|
14
16
|
const importXConfig = {
|
|
15
17
|
name: "shayanthenerd/import-x",
|
|
16
18
|
files: [require__Users_shayan_Desktop_Dev_GitHub_eslint_config_src_utils_globs.globs.src, vue ? require__Users_shayan_Desktop_Dev_GitHub_eslint_config_src_utils_globs.globs.vue : ""],
|
|
17
|
-
extends: [
|
|
19
|
+
extends: [
|
|
20
|
+
eslint_plugin_import.default.flatConfigs.recommended,
|
|
21
|
+
eslint_plugin_import_x.default.flatConfigs.recommended,
|
|
22
|
+
typescript ? eslint_plugin_import.default.flatConfigs.typescript : {},
|
|
23
|
+
typescript ? eslint_plugin_import_x.default.flatConfigs.typescript : {}
|
|
24
|
+
],
|
|
18
25
|
plugins: { "unused-imports": eslint_plugin_unused_imports.default },
|
|
19
|
-
settings: {
|
|
26
|
+
settings: {
|
|
27
|
+
"import/resolver": { typescript: true },
|
|
28
|
+
"import/extensions": [
|
|
29
|
+
".js",
|
|
30
|
+
".cjs",
|
|
31
|
+
".mjs",
|
|
32
|
+
".jsx",
|
|
33
|
+
".ts",
|
|
34
|
+
".cts",
|
|
35
|
+
".mts",
|
|
36
|
+
".tsx",
|
|
37
|
+
".vue"
|
|
38
|
+
]
|
|
39
|
+
},
|
|
20
40
|
rules: require__Users_shayan_Desktop_Dev_GitHub_eslint_config_src_rules_importX.getImportXRules(options)
|
|
21
41
|
};
|
|
22
42
|
return (0, eslint_flat_config_utils.mergeConfigs)(importXConfig, overrides);
|
package/dist/configs/importX.js
CHANGED
|
@@ -3,19 +3,39 @@ import { isEnabled } from "../utils/isEnabled.js";
|
|
|
3
3
|
import { defaultOptions } from "../utils/options/defaultOptions.js";
|
|
4
4
|
import { getImportXRules } from "../rules/importX.js";
|
|
5
5
|
import { mergeConfigs } from "eslint-flat-config-utils";
|
|
6
|
+
import eslintPluginImport from "eslint-plugin-import";
|
|
6
7
|
import eslintPluginImportX from "eslint-plugin-import-x";
|
|
7
8
|
import eslintPluginUnusedImports from "eslint-plugin-unused-imports";
|
|
8
9
|
|
|
9
10
|
//#region src/configs/importX.ts
|
|
11
|
+
eslintPluginImport.flatConfigs.recommended.rules = {};
|
|
10
12
|
function getImportXConfig(options) {
|
|
11
13
|
const { vue, importX, typescript } = options.configs;
|
|
12
14
|
const { overrides } = isEnabled(importX) ? importX : defaultOptions.configs.importX;
|
|
13
15
|
const importXConfig = {
|
|
14
16
|
name: "shayanthenerd/import-x",
|
|
15
17
|
files: [globs.src, vue ? globs.vue : ""],
|
|
16
|
-
extends: [
|
|
18
|
+
extends: [
|
|
19
|
+
eslintPluginImport.flatConfigs.recommended,
|
|
20
|
+
eslintPluginImportX.flatConfigs.recommended,
|
|
21
|
+
typescript ? eslintPluginImport.flatConfigs.typescript : {},
|
|
22
|
+
typescript ? eslintPluginImportX.flatConfigs.typescript : {}
|
|
23
|
+
],
|
|
17
24
|
plugins: { "unused-imports": eslintPluginUnusedImports },
|
|
18
|
-
settings: {
|
|
25
|
+
settings: {
|
|
26
|
+
"import/resolver": { typescript: true },
|
|
27
|
+
"import/extensions": [
|
|
28
|
+
".js",
|
|
29
|
+
".cjs",
|
|
30
|
+
".mjs",
|
|
31
|
+
".jsx",
|
|
32
|
+
".ts",
|
|
33
|
+
".cts",
|
|
34
|
+
".mts",
|
|
35
|
+
".tsx",
|
|
36
|
+
".vue"
|
|
37
|
+
]
|
|
38
|
+
},
|
|
19
39
|
rules: getImportXRules(options)
|
|
20
40
|
};
|
|
21
41
|
return mergeConfigs(importXConfig, overrides);
|
|
@@ -6,6 +6,7 @@ const require__Users_shayan_Desktop_Dev_GitHub_eslint_config_src_rules_vitest =
|
|
|
6
6
|
const require__Users_shayan_Desktop_Dev_GitHub_eslint_config_src_rules_importX = require('../rules/importX.cjs');
|
|
7
7
|
const require__Users_shayan_Desktop_Dev_GitHub_eslint_config_src_rules_playwright = require('../rules/playwright.cjs');
|
|
8
8
|
const require__Users_shayan_Desktop_Dev_GitHub_eslint_config_src_rules_typescript = require('../rules/typescript.cjs');
|
|
9
|
+
const typescript_eslint = require_rolldown_runtime.__toESM(require("typescript-eslint"));
|
|
9
10
|
const __vitest_eslint_plugin = require_rolldown_runtime.__toESM(require("@vitest/eslint-plugin"));
|
|
10
11
|
const eslint_plugin_import_x = require_rolldown_runtime.__toESM(require("eslint-plugin-import-x"));
|
|
11
12
|
const eslint_plugin_playwright = require_rolldown_runtime.__toESM(require("eslint-plugin-playwright"));
|
|
@@ -29,7 +30,8 @@ function getOXLintOverridesConfig(options) {
|
|
|
29
30
|
plugins: {
|
|
30
31
|
"vitest": __vitest_eslint_plugin.default,
|
|
31
32
|
"import-x": eslint_plugin_import_x.default,
|
|
32
|
-
"playwright": eslint_plugin_playwright.default
|
|
33
|
+
"playwright": eslint_plugin_playwright.default,
|
|
34
|
+
"@typescript-eslint": typescript_eslint.default.plugin
|
|
33
35
|
},
|
|
34
36
|
rules: {
|
|
35
37
|
"max-depth": javascriptRules["max-depth"],
|
|
@@ -5,6 +5,7 @@ import { getVitestRules } from "../rules/vitest.js";
|
|
|
5
5
|
import { getImportXRules } from "../rules/importX.js";
|
|
6
6
|
import { getPlaywrightRules } from "../rules/playwright.js";
|
|
7
7
|
import { getTypeScriptRules } from "../rules/typescript.js";
|
|
8
|
+
import typescriptESLint from "typescript-eslint";
|
|
8
9
|
import eslintPluginVitest from "@vitest/eslint-plugin";
|
|
9
10
|
import eslintPluginImportX from "eslint-plugin-import-x";
|
|
10
11
|
import eslintPluginPlaywright from "eslint-plugin-playwright";
|
|
@@ -28,7 +29,8 @@ function getOXLintOverridesConfig(options) {
|
|
|
28
29
|
plugins: {
|
|
29
30
|
"vitest": eslintPluginVitest,
|
|
30
31
|
"import-x": eslintPluginImportX,
|
|
31
|
-
"playwright": eslintPluginPlaywright
|
|
32
|
+
"playwright": eslintPluginPlaywright,
|
|
33
|
+
"@typescript-eslint": typescriptESLint.plugin
|
|
32
34
|
},
|
|
33
35
|
rules: {
|
|
34
36
|
"max-depth": javascriptRules["max-depth"],
|
|
@@ -14,7 +14,7 @@ const eslintParserHTML = __html_eslint_eslint_plugin.default.configs["flat/recom
|
|
|
14
14
|
const eslintParserVue = eslint_plugin_vue.default.configs["flat/recommended"].find((config) => config.name === "vue/base/setup-for-vue")?.languageOptions?.parser;
|
|
15
15
|
function getTailwindConfig(options) {
|
|
16
16
|
const { tsConfig, configs: { vue, html, tailwind } } = options;
|
|
17
|
-
const {
|
|
17
|
+
const { config, entryPoint, overrides } = require__Users_shayan_Desktop_Dev_GitHub_eslint_config_src_utils_isEnabled.isEnabled(tailwind) ? tailwind : require__Users_shayan_Desktop_Dev_GitHub_eslint_config_src_utils_options_defaultOptions.defaultOptions.configs.tailwind;
|
|
18
18
|
const tailwindConfig = {
|
|
19
19
|
name: "shayanthenerd/tailwind",
|
|
20
20
|
files: [
|
|
@@ -25,8 +25,8 @@ function getTailwindConfig(options) {
|
|
|
25
25
|
plugins: { "better-tailwindcss": eslint_plugin_better_tailwindcss.default },
|
|
26
26
|
languageOptions: { parserOptions: { parser: html ? eslintParserHTML : eslintParserVue } },
|
|
27
27
|
settings: { "better-tailwindcss": {
|
|
28
|
-
entryPoint
|
|
29
|
-
tailwindConfig:
|
|
28
|
+
entryPoint,
|
|
29
|
+
tailwindConfig: config,
|
|
30
30
|
tsconfig: tsConfig ? node_path.default.resolve(tsConfig.rootDir, tsConfig.filename) : void 0,
|
|
31
31
|
attributes: [["^v-bind:ui$", [{ match: "objectValues" }]], ["^(?:v-bind:)?(class|activeClass|inactiveClass)$", [
|
|
32
32
|
{ match: "strings" },
|
package/dist/configs/tailwind.js
CHANGED
|
@@ -13,7 +13,7 @@ const eslintParserHTML = eslintPluginHTML.configs["flat/recommended"].languageOp
|
|
|
13
13
|
const eslintParserVue = eslintPluginVue.configs["flat/recommended"].find((config) => config.name === "vue/base/setup-for-vue")?.languageOptions?.parser;
|
|
14
14
|
function getTailwindConfig(options) {
|
|
15
15
|
const { tsConfig, configs: { vue, html, tailwind } } = options;
|
|
16
|
-
const {
|
|
16
|
+
const { config, entryPoint, overrides } = isEnabled(tailwind) ? tailwind : defaultOptions.configs.tailwind;
|
|
17
17
|
const tailwindConfig = {
|
|
18
18
|
name: "shayanthenerd/tailwind",
|
|
19
19
|
files: [
|
|
@@ -24,8 +24,8 @@ function getTailwindConfig(options) {
|
|
|
24
24
|
plugins: { "better-tailwindcss": eslintPluginTailwind },
|
|
25
25
|
languageOptions: { parserOptions: { parser: html ? eslintParserHTML : eslintParserVue } },
|
|
26
26
|
settings: { "better-tailwindcss": {
|
|
27
|
-
entryPoint
|
|
28
|
-
tailwindConfig:
|
|
27
|
+
entryPoint,
|
|
28
|
+
tailwindConfig: config,
|
|
29
29
|
tsconfig: tsConfig ? path.resolve(tsConfig.rootDir, tsConfig.filename) : void 0,
|
|
30
30
|
attributes: [["^v-bind:ui$", [{ match: "objectValues" }]], ["^(?:v-bind:)?(class|activeClass|inactiveClass)$", [
|
|
31
31
|
{ match: "strings" },
|
|
@@ -13,7 +13,7 @@ function getTypeScriptConfig(options) {
|
|
|
13
13
|
const { overrides } = require__Users_shayan_Desktop_Dev_GitHub_eslint_config_src_utils_isEnabled.isEnabled(typescript) ? typescript : require__Users_shayan_Desktop_Dev_GitHub_eslint_config_src_utils_options_defaultOptions.defaultOptions.configs.typescript;
|
|
14
14
|
const typescriptConfig = {
|
|
15
15
|
name: "shayanthenerd/typescript",
|
|
16
|
-
files: [require__Users_shayan_Desktop_Dev_GitHub_eslint_config_src_utils_globs.globs.
|
|
16
|
+
files: [require__Users_shayan_Desktop_Dev_GitHub_eslint_config_src_utils_globs.globs.ts, vue ? require__Users_shayan_Desktop_Dev_GitHub_eslint_config_src_utils_globs.globs.vue : ""],
|
|
17
17
|
extends: [typescript_eslint.default.configs.strictTypeChecked, typescript_eslint.default.configs.stylisticTypeChecked],
|
|
18
18
|
languageOptions: { parserOptions: {
|
|
19
19
|
tsconfigRootDir: tsConfig ? tsConfig.rootDir : void 0,
|
|
@@ -12,7 +12,7 @@ function getTypeScriptConfig(options) {
|
|
|
12
12
|
const { overrides } = isEnabled(typescript) ? typescript : defaultOptions.configs.typescript;
|
|
13
13
|
const typescriptConfig = {
|
|
14
14
|
name: "shayanthenerd/typescript",
|
|
15
|
-
files: [globs.
|
|
15
|
+
files: [globs.ts, vue ? globs.vue : ""],
|
|
16
16
|
extends: [typescriptESLint.configs.strictTypeChecked, typescriptESLint.configs.stylisticTypeChecked],
|
|
17
17
|
languageOptions: { parserOptions: {
|
|
18
18
|
tsconfigRootDir: tsConfig ? tsConfig.rootDir : void 0,
|
package/dist/rules/importX.cjs
CHANGED
|
@@ -6,9 +6,18 @@ const node_path = require_rolldown_runtime.__toESM(require("node:path"));
|
|
|
6
6
|
//#region src/rules/importX.ts
|
|
7
7
|
function getImportXRules(options) {
|
|
8
8
|
const { packageDir, configs: { importX } } = options;
|
|
9
|
-
const { requireFileExtension } = require__Users_shayan_Desktop_Dev_GitHub_eslint_config_src_utils_isEnabled.isEnabled(importX) ? importX : require__Users_shayan_Desktop_Dev_GitHub_eslint_config_src_utils_options_defaultOptions.defaultOptions.configs.importX;
|
|
9
|
+
const { removeUnusedImports, requireFileExtension } = require__Users_shayan_Desktop_Dev_GitHub_eslint_config_src_utils_isEnabled.isEnabled(importX) ? importX : require__Users_shayan_Desktop_Dev_GitHub_eslint_config_src_utils_options_defaultOptions.defaultOptions.configs.importX;
|
|
10
10
|
const importXRules = {
|
|
11
|
-
"unused-imports/no-unused-imports": "warn",
|
|
11
|
+
"unused-imports/no-unused-imports": removeUnusedImports ? "warn" : "off",
|
|
12
|
+
"import-x/extensions": "off",
|
|
13
|
+
"import/extensions": [
|
|
14
|
+
requireFileExtension ? "warn" : "off",
|
|
15
|
+
"always",
|
|
16
|
+
{
|
|
17
|
+
ignorePackages: true,
|
|
18
|
+
checkTypeImports: true
|
|
19
|
+
}
|
|
20
|
+
],
|
|
12
21
|
"import-x/no-amd": "error",
|
|
13
22
|
"import-x/exports-last": "warn",
|
|
14
23
|
"import-x/no-commonjs": "error",
|
|
@@ -33,16 +42,7 @@ function getImportXRules(options) {
|
|
|
33
42
|
"import-x/no-extraneous-dependencies": ["error", {
|
|
34
43
|
includeTypes: true,
|
|
35
44
|
packageDir: node_path.default.resolve(packageDir)
|
|
36
|
-
}]
|
|
37
|
-
"import-x/extensions": [
|
|
38
|
-
"error",
|
|
39
|
-
requireFileExtension,
|
|
40
|
-
{
|
|
41
|
-
fix: true,
|
|
42
|
-
ignorePackages: true,
|
|
43
|
-
checkTypeImports: true
|
|
44
|
-
}
|
|
45
|
-
]
|
|
45
|
+
}]
|
|
46
46
|
};
|
|
47
47
|
return importXRules;
|
|
48
48
|
}
|
package/dist/rules/importX.js
CHANGED
|
@@ -5,9 +5,18 @@ import path from "node:path";
|
|
|
5
5
|
//#region src/rules/importX.ts
|
|
6
6
|
function getImportXRules(options) {
|
|
7
7
|
const { packageDir, configs: { importX } } = options;
|
|
8
|
-
const { requireFileExtension } = isEnabled(importX) ? importX : defaultOptions.configs.importX;
|
|
8
|
+
const { removeUnusedImports, requireFileExtension } = isEnabled(importX) ? importX : defaultOptions.configs.importX;
|
|
9
9
|
const importXRules = {
|
|
10
|
-
"unused-imports/no-unused-imports": "warn",
|
|
10
|
+
"unused-imports/no-unused-imports": removeUnusedImports ? "warn" : "off",
|
|
11
|
+
"import-x/extensions": "off",
|
|
12
|
+
"import/extensions": [
|
|
13
|
+
requireFileExtension ? "warn" : "off",
|
|
14
|
+
"always",
|
|
15
|
+
{
|
|
16
|
+
ignorePackages: true,
|
|
17
|
+
checkTypeImports: true
|
|
18
|
+
}
|
|
19
|
+
],
|
|
11
20
|
"import-x/no-amd": "error",
|
|
12
21
|
"import-x/exports-last": "warn",
|
|
13
22
|
"import-x/no-commonjs": "error",
|
|
@@ -32,16 +41,7 @@ function getImportXRules(options) {
|
|
|
32
41
|
"import-x/no-extraneous-dependencies": ["error", {
|
|
33
42
|
includeTypes: true,
|
|
34
43
|
packageDir: path.resolve(packageDir)
|
|
35
|
-
}]
|
|
36
|
-
"import-x/extensions": [
|
|
37
|
-
"error",
|
|
38
|
-
requireFileExtension,
|
|
39
|
-
{
|
|
40
|
-
fix: true,
|
|
41
|
-
ignorePackages: true,
|
|
42
|
-
checkTypeImports: true
|
|
43
|
-
}
|
|
44
|
-
]
|
|
44
|
+
}]
|
|
45
45
|
};
|
|
46
46
|
return importXRules;
|
|
47
47
|
}
|
package/dist/rules/vue.cjs
CHANGED
|
@@ -12,9 +12,11 @@ function getVueRules(options) {
|
|
|
12
12
|
const nuxtUI = require__Users_shayan_Desktop_Dev_GitHub_eslint_config_src_utils_isEnabled.isEnabled(nuxt) ? nuxt.ui : void 0;
|
|
13
13
|
const nuxtUIPrefix = require__Users_shayan_Desktop_Dev_GitHub_eslint_config_src_utils_isEnabled.isEnabled(nuxt) && require__Users_shayan_Desktop_Dev_GitHub_eslint_config_src_utils_isEnabled.isEnabled(nuxt.ui) ? nuxt.ui.prefix : void 0;
|
|
14
14
|
const isScriptLangTS = blockLang.script === "ts";
|
|
15
|
+
const isStyleLangImplicit = blockLang.style === "implicit";
|
|
15
16
|
const vueRules = {
|
|
16
17
|
"no-undef": "off",
|
|
17
18
|
"no-useless-assignment": "off",
|
|
19
|
+
"import-x/default": "off",
|
|
18
20
|
"vue/comment-directive": ["error", { reportUnusedDisableDirectives: true }],
|
|
19
21
|
"vue/html-closing-bracket-newline": "warn",
|
|
20
22
|
"vue/singleline-html-element-content-newline": "off",
|
|
@@ -100,8 +102,8 @@ function getVueRules(options) {
|
|
|
100
102
|
"vue/block-lang": ["error", {
|
|
101
103
|
script: { lang: blockLang.script },
|
|
102
104
|
style: {
|
|
103
|
-
lang: blockLang.style,
|
|
104
|
-
allowNoLang:
|
|
105
|
+
lang: isStyleLangImplicit ? void 0 : blockLang.style,
|
|
106
|
+
allowNoLang: isStyleLangImplicit
|
|
105
107
|
}
|
|
106
108
|
}],
|
|
107
109
|
"vue/block-tag-newline": ["warn", {
|
package/dist/rules/vue.js
CHANGED
|
@@ -12,9 +12,11 @@ function getVueRules(options) {
|
|
|
12
12
|
const nuxtUI = isEnabled(nuxt) ? nuxt.ui : void 0;
|
|
13
13
|
const nuxtUIPrefix = isEnabled(nuxt) && isEnabled(nuxt.ui) ? nuxt.ui.prefix : void 0;
|
|
14
14
|
const isScriptLangTS = blockLang.script === "ts";
|
|
15
|
+
const isStyleLangImplicit = blockLang.style === "implicit";
|
|
15
16
|
const vueRules = {
|
|
16
17
|
"no-undef": "off",
|
|
17
18
|
"no-useless-assignment": "off",
|
|
19
|
+
"import-x/default": "off",
|
|
18
20
|
"vue/comment-directive": ["error", { reportUnusedDisableDirectives: true }],
|
|
19
21
|
"vue/html-closing-bracket-newline": "warn",
|
|
20
22
|
"vue/singleline-html-element-content-newline": "off",
|
|
@@ -100,8 +102,8 @@ function getVueRules(options) {
|
|
|
100
102
|
"vue/block-lang": ["error", {
|
|
101
103
|
script: { lang: blockLang.script },
|
|
102
104
|
style: {
|
|
103
|
-
lang: blockLang.style,
|
|
104
|
-
allowNoLang:
|
|
105
|
+
lang: isStyleLangImplicit ? void 0 : blockLang.style,
|
|
106
|
+
allowNoLang: isStyleLangImplicit
|
|
105
107
|
}
|
|
106
108
|
}],
|
|
107
109
|
"vue/block-tag-newline": ["warn", {
|
|
@@ -1,20 +1,29 @@
|
|
|
1
|
-
import { RuleOptions } from "../eslintRules.cjs";
|
|
2
1
|
import { ConfigWithOverrides } from "../index.cjs";
|
|
3
2
|
|
|
4
3
|
//#region src/types/configOptions/importX.d.ts
|
|
5
|
-
|
|
6
|
-
type RequireFileExtension = Exclude<RequireFileExtensionOptions, 'ignorePackages' | Record<string, unknown>>;
|
|
4
|
+
|
|
7
5
|
interface ImportXOptions extends ConfigWithOverrides {
|
|
8
6
|
/**
|
|
9
|
-
*
|
|
7
|
+
* Automatically remove unused imports.
|
|
8
|
+
*
|
|
9
|
+
* @default true
|
|
10
|
+
*
|
|
11
|
+
* @see [unused-imports/no-unused-imports](https://github.com/sweepline/eslint-plugin-unused-imports/blob/master/docs/rules/no-unused-imports.md)
|
|
12
|
+
*/
|
|
13
|
+
removeUnusedImports?: boolean;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Require file extensions within the import path.
|
|
10
17
|
*
|
|
11
18
|
* Imports from third-party packages are ignored.
|
|
12
19
|
*
|
|
13
|
-
*
|
|
20
|
+
* `import-x/extensions` rule is currently broken, so `import/extensions` is used as a temporary replacement.
|
|
21
|
+
*
|
|
22
|
+
* @default true
|
|
14
23
|
*
|
|
15
|
-
* @see [import
|
|
24
|
+
* @see [import/extensions](https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/extensions.md)
|
|
16
25
|
*/
|
|
17
|
-
requireFileExtension?:
|
|
26
|
+
requireFileExtension?: boolean;
|
|
18
27
|
}
|
|
19
28
|
//#endregion
|
|
20
29
|
export { type ImportXOptions };
|
|
@@ -1,20 +1,29 @@
|
|
|
1
|
-
import { RuleOptions } from "../eslintRules.js";
|
|
2
1
|
import { ConfigWithOverrides } from "../index.js";
|
|
3
2
|
|
|
4
3
|
//#region src/types/configOptions/importX.d.ts
|
|
5
|
-
|
|
6
|
-
type RequireFileExtension = Exclude<RequireFileExtensionOptions, 'ignorePackages' | Record<string, unknown>>;
|
|
4
|
+
|
|
7
5
|
interface ImportXOptions extends ConfigWithOverrides {
|
|
8
6
|
/**
|
|
9
|
-
*
|
|
7
|
+
* Automatically remove unused imports.
|
|
8
|
+
*
|
|
9
|
+
* @default true
|
|
10
|
+
*
|
|
11
|
+
* @see [unused-imports/no-unused-imports](https://github.com/sweepline/eslint-plugin-unused-imports/blob/master/docs/rules/no-unused-imports.md)
|
|
12
|
+
*/
|
|
13
|
+
removeUnusedImports?: boolean;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Require file extensions within the import path.
|
|
10
17
|
*
|
|
11
18
|
* Imports from third-party packages are ignored.
|
|
12
19
|
*
|
|
13
|
-
*
|
|
20
|
+
* `import-x/extensions` rule is currently broken, so `import/extensions` is used as a temporary replacement.
|
|
21
|
+
*
|
|
22
|
+
* @default true
|
|
14
23
|
*
|
|
15
|
-
* @see [import
|
|
24
|
+
* @see [import/extensions](https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/extensions.md)
|
|
16
25
|
*/
|
|
17
|
-
requireFileExtension?:
|
|
26
|
+
requireFileExtension?: boolean;
|
|
18
27
|
}
|
|
19
28
|
//#endregion
|
|
20
29
|
export { type ImportXOptions };
|