eslint-config-gorgon 2.0.0 → 2.0.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/dist/index.d.ts +16 -0
- package/dist/index.js +1 -0
- package/package.json +3 -3
- package/src/configs/base.ts +0 -12
- package/src/configs/import.ts +0 -22
- package/src/configs/index.tsx +0 -6
- package/src/configs/jsx-a11y.ts +0 -5
- package/src/configs/prettier.ts +0 -4
- package/src/configs/tailwind.ts +0 -3
- package/src/configs/typescript.ts +0 -7
- package/src/constants.ts +0 -9
- package/src/index.ts +0 -52
- package/src/rules/react.ts +0 -8
- package/src/types.d.ts +0 -5
- package/src/utils/check-react.ts +0 -17
- package/src/utils/check-tailwindcss.ts +0 -17
- package/src/utils/check-typescript.ts +0 -8
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { TSESLint } from '@typescript-eslint/utils';
|
|
2
|
+
import eslint from 'eslint';
|
|
3
|
+
|
|
4
|
+
declare const initialConfigs: eslint.Linter.Config[];
|
|
5
|
+
type InitConfigProps = {
|
|
6
|
+
a11y?: boolean;
|
|
7
|
+
ignores?: string[];
|
|
8
|
+
prettier?: boolean;
|
|
9
|
+
react?: boolean;
|
|
10
|
+
tailwind?: boolean;
|
|
11
|
+
typescript?: boolean;
|
|
12
|
+
};
|
|
13
|
+
type InitConfigReturnType = eslint.Linter.Config | TSESLint.FlatConfig.Config;
|
|
14
|
+
declare const init: (configs?: InitConfigProps) => InitConfigReturnType[];
|
|
15
|
+
|
|
16
|
+
export { initialConfigs as default, init };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var k=Object.create;var a=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var C=Object.getOwnPropertyNames;var T=Object.getPrototypeOf,R=Object.prototype.hasOwnProperty;var S=(o,e)=>()=>(e||o((e={exports:{}}).exports,e),e.exports);var P=(o,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of C(e))!R.call(o,i)&&i!==t&&a(o,i,{get:()=>e[i],enumerable:!(n=h(e,i))||n.enumerable});return o};var q=(o,e,t)=>(t=o!=null?k(T(o)):{},P(e||!o||!o.__esModule?a(t,"default",{value:o,enumerable:!0}):t,o));var m=S((X,l)=>{"use strict";var F=!process.env.ESLINT_CONFIG_PRETTIER_NO_DEPRECATED,f=0;l.exports={rules:{curly:f,"no-unexpected-multiline":f,"@typescript-eslint/lines-around-comment":f,"@typescript-eslint/quotes":f,"babel/quotes":f,"unicorn/template-indent":f,"vue/html-self-closing":f,"vue/max-len":f,"@babel/object-curly-spacing":"off","@babel/semi":"off","@typescript-eslint/block-spacing":"off","@typescript-eslint/brace-style":"off","@typescript-eslint/comma-dangle":"off","@typescript-eslint/comma-spacing":"off","@typescript-eslint/func-call-spacing":"off","@typescript-eslint/indent":"off","@typescript-eslint/key-spacing":"off","@typescript-eslint/keyword-spacing":"off","@typescript-eslint/member-delimiter-style":"off","@typescript-eslint/no-extra-parens":"off","@typescript-eslint/no-extra-semi":"off","@typescript-eslint/object-curly-spacing":"off","@typescript-eslint/semi":"off","@typescript-eslint/space-before-blocks":"off","@typescript-eslint/space-before-function-paren":"off","@typescript-eslint/space-infix-ops":"off","@typescript-eslint/type-annotation-spacing":"off","babel/object-curly-spacing":"off","babel/semi":"off","flowtype/boolean-style":"off","flowtype/delimiter-dangle":"off","flowtype/generic-spacing":"off","flowtype/object-type-curly-spacing":"off","flowtype/object-type-delimiter":"off","flowtype/quotes":"off","flowtype/semi":"off","flowtype/space-after-type-colon":"off","flowtype/space-before-generic-bracket":"off","flowtype/space-before-type-colon":"off","flowtype/union-intersection-spacing":"off","react/jsx-child-element-spacing":"off","react/jsx-closing-bracket-location":"off","react/jsx-closing-tag-location":"off","react/jsx-curly-newline":"off","react/jsx-curly-spacing":"off","react/jsx-equals-spacing":"off","react/jsx-first-prop-new-line":"off","react/jsx-indent":"off","react/jsx-indent-props":"off","react/jsx-max-props-per-line":"off","react/jsx-newline":"off","react/jsx-one-expression-per-line":"off","react/jsx-props-no-multi-spaces":"off","react/jsx-tag-spacing":"off","react/jsx-wrap-multilines":"off","standard/array-bracket-even-spacing":"off","standard/computed-property-even-spacing":"off","standard/object-curly-even-spacing":"off","unicorn/empty-brace-spaces":"off","unicorn/no-nested-ternary":"off","unicorn/number-literal-case":"off","vue/array-bracket-newline":"off","vue/array-bracket-spacing":"off","vue/array-element-newline":"off","vue/arrow-spacing":"off","vue/block-spacing":"off","vue/block-tag-newline":"off","vue/brace-style":"off","vue/comma-dangle":"off","vue/comma-spacing":"off","vue/comma-style":"off","vue/dot-location":"off","vue/func-call-spacing":"off","vue/html-closing-bracket-newline":"off","vue/html-closing-bracket-spacing":"off","vue/html-end-tags":"off","vue/html-indent":"off","vue/html-quotes":"off","vue/key-spacing":"off","vue/keyword-spacing":"off","vue/max-attributes-per-line":"off","vue/multiline-html-element-content-newline":"off","vue/multiline-ternary":"off","vue/mustache-interpolation-spacing":"off","vue/no-extra-parens":"off","vue/no-multi-spaces":"off","vue/no-spaces-around-equal-signs-in-attribute":"off","vue/object-curly-newline":"off","vue/object-curly-spacing":"off","vue/object-property-newline":"off","vue/operator-linebreak":"off","vue/quote-props":"off","vue/script-indent":"off","vue/singleline-html-element-content-newline":"off","vue/space-in-parens":"off","vue/space-infix-ops":"off","vue/space-unary-ops":"off","vue/template-curly-spacing":"off",...F&&{"space-unary-word-ops":"off","generator-star":"off","no-comma-dangle":"off","no-reserved-keys":"off","no-space-before-semi":"off","no-wrap-func":"off","space-after-function-name":"off","space-before-function-parentheses":"off","space-in-brackets":"off","no-arrow-condition":"off","space-after-keywords":"off","space-before-keywords":"off","space-return-throw-case":"off","no-spaced-func":"off","indent-legacy":"off","array-bracket-newline":"off","array-bracket-spacing":"off","array-element-newline":"off","arrow-parens":"off","arrow-spacing":"off","block-spacing":"off","brace-style":"off","comma-dangle":"off","comma-spacing":"off","comma-style":"off","computed-property-spacing":"off","dot-location":"off","eol-last":"off","func-call-spacing":"off","function-call-argument-newline":"off","function-paren-newline":"off","generator-star-spacing":"off","implicit-arrow-linebreak":"off",indent:"off","jsx-quotes":"off","key-spacing":"off","keyword-spacing":"off","linebreak-style":"off","lines-around-comment":f,"max-len":f,"max-statements-per-line":"off","multiline-ternary":"off","new-parens":"off","newline-per-chained-call":"off","no-confusing-arrow":f,"no-extra-parens":"off","no-extra-semi":"off","no-floating-decimal":"off","no-mixed-operators":f,"no-mixed-spaces-and-tabs":"off","no-multi-spaces":"off","no-multiple-empty-lines":"off","no-tabs":f,"no-trailing-spaces":"off","no-whitespace-before-property":"off","nonblock-statement-body-position":"off","object-curly-newline":"off","object-curly-spacing":"off","object-property-newline":"off","one-var-declaration-per-line":"off","operator-linebreak":"off","padded-blocks":"off","quote-props":"off",quotes:f,"rest-spread-spacing":"off",semi:"off","semi-spacing":"off","semi-style":"off","space-before-blocks":"off","space-before-function-paren":"off","space-in-parens":"off","space-infix-ops":"off","space-unary-ops":"off","switch-colon-spacing":"off","template-curly-spacing":"off","template-tag-spacing":"off","wrap-iife":"off","wrap-regex":"off","yield-star-spacing":"off","react/jsx-space-before-closing":"off"}}}});import K from"typescript-eslint";import E from"eslint-plugin-perfectionist";var c=[E.configs["recommended-natural"],{rules:{"no-console":"warn","no-unused-vars":"warn","perfectionist/sort-enums":"warn"}}];import I from"eslint-plugin-jsx-a11y";var p=[I.flatConfigs.recommended];var u=q(m(),1);import H from"eslint-plugin-prettier/recommended";var y=[H,u.default];import D from"eslint-plugin-tailwindcss";var g=[...D.configs["flat/recommended"]];import d from"fs";import L from"path";var _=()=>{let o=L.join(process.cwd(),"package.json");if(d.existsSync(o)){let e=JSON.parse(d.readFileSync(o,"utf-8")),t=e.dependencies||{},n=e.devDependencies||{};return"react"in t||"react"in n}return!1},b=_;import N from"fs";import A from"path";var J=()=>["tailwind.config.js","tailwind.config.cjs","tailwind.config.mjs","tailwind.config.ts","tailwind.config.mts"].some(t=>N.existsSync(A.join(process.cwd(),t))),w=J;import O from"fs";import G from"path";var z=G.join(process.cwd(),"tsconfig.json"),B=()=>O.existsSync(z),x=B;var s=b(),v=w(),j=x();var r=[...c],ve=o=>{let e=r;if((o?.a11y??s)&&e.push(...p),(o?.tailwind??v)&&e.push(...g),(o?.prettier??s)&&e.push(...y),o?.typescript??j){let t=["**/node_modules/**","dist/**","output/**"];e=[...r,...K.configs.recommended].map(n=>({...n,files:["**/*.ts","**/*.tsx",...n?.files?.flat(1/0)??[]],ignores:[...t,...o?.ignores??[]]}))}return e},je=r;export{je as default,ve as init};
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-config-gorgon",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"main": "
|
|
5
|
+
"main": "dist/index.js",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"keywords": [
|
|
8
8
|
"eslint",
|
|
9
9
|
"config"
|
|
10
10
|
],
|
|
11
11
|
"files": [
|
|
12
|
-
"
|
|
12
|
+
"dist/*"
|
|
13
13
|
],
|
|
14
14
|
"dependencies": {
|
|
15
15
|
"eslint-plugin-import": "^2.30.0",
|
package/src/configs/base.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import perfectionist from "eslint-plugin-perfectionist";
|
|
2
|
-
|
|
3
|
-
export default [
|
|
4
|
-
perfectionist.configs["recommended-natural"],
|
|
5
|
-
{
|
|
6
|
-
rules: {
|
|
7
|
-
"no-console": "warn", // handle console
|
|
8
|
-
"no-unused-vars": "warn", // unused
|
|
9
|
-
"perfectionist/sort-enums": "warn", // sort enums
|
|
10
|
-
},
|
|
11
|
-
},
|
|
12
|
-
];
|
package/src/configs/import.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import importPlugin from "eslint-plugin-import";
|
|
2
|
-
|
|
3
|
-
export default [
|
|
4
|
-
{
|
|
5
|
-
plugins: { import: importPlugin },
|
|
6
|
-
rules: {
|
|
7
|
-
"import/first": "error",
|
|
8
|
-
"import/newline-after-import": "error",
|
|
9
|
-
"import/no-duplicates": "error",
|
|
10
|
-
},
|
|
11
|
-
settings: {
|
|
12
|
-
// This will do the trick
|
|
13
|
-
"import/parsers": {
|
|
14
|
-
espree: [".js", ".cjs", ".mjs", ".jsx"],
|
|
15
|
-
},
|
|
16
|
-
"import/resolver": {
|
|
17
|
-
node: true,
|
|
18
|
-
typescript: true,
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
];
|
package/src/configs/index.tsx
DELETED
package/src/configs/jsx-a11y.ts
DELETED
package/src/configs/prettier.ts
DELETED
package/src/configs/tailwind.ts
DELETED
package/src/constants.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import checkHasReact from "./utils/check-react";
|
|
2
|
-
import checkHasTailwindcss from "./utils/check-tailwindcss";
|
|
3
|
-
import checkHasTypeScript from "./utils/check-typescript";
|
|
4
|
-
|
|
5
|
-
const hasReact = checkHasReact();
|
|
6
|
-
const hasTailwindcss = checkHasTailwindcss();
|
|
7
|
-
const hasTypeScript = checkHasTypeScript();
|
|
8
|
-
|
|
9
|
-
export { hasReact, hasTailwindcss, hasTypeScript };
|
package/src/index.ts
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import type { TSESLint } from "@typescript-eslint/utils";
|
|
2
|
-
import type eslint from "eslint";
|
|
3
|
-
|
|
4
|
-
import tseslint from "typescript-eslint";
|
|
5
|
-
|
|
6
|
-
import base from "./configs/base";
|
|
7
|
-
import jsxA11y from "./configs/jsx-a11y";
|
|
8
|
-
// import _import from "./configs/import";
|
|
9
|
-
import prettier from "./configs/prettier";
|
|
10
|
-
import tailwind from "./configs/tailwind";
|
|
11
|
-
import { hasReact, hasTailwindcss, hasTypeScript } from "./constants";
|
|
12
|
-
|
|
13
|
-
const initialConfigs: eslint.Linter.Config[] = [...base];
|
|
14
|
-
|
|
15
|
-
type InitConfigProps = {
|
|
16
|
-
a11y?: boolean;
|
|
17
|
-
ignores?: string[];
|
|
18
|
-
prettier?: boolean;
|
|
19
|
-
react?: boolean;
|
|
20
|
-
tailwind?: boolean;
|
|
21
|
-
typescript?: boolean;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
type InitConfigReturnType = eslint.Linter.Config | TSESLint.FlatConfig.Config;
|
|
25
|
-
|
|
26
|
-
export const init = (configs?: InitConfigProps): InitConfigReturnType[] => {
|
|
27
|
-
let reasonConfigs: InitConfigReturnType[] = initialConfigs;
|
|
28
|
-
// 判断是否存在 a11y
|
|
29
|
-
if (configs?.a11y ?? hasReact) reasonConfigs.push(...jsxA11y);
|
|
30
|
-
// 判断是否存在 tailwindcss
|
|
31
|
-
if (configs?.tailwind ?? hasTailwindcss) reasonConfigs.push(...tailwind);
|
|
32
|
-
// 判断是否存在 prettier
|
|
33
|
-
if (configs?.prettier ?? hasReact) reasonConfigs.push(...prettier);
|
|
34
|
-
// 判断是否存在 typescript
|
|
35
|
-
if (configs?.typescript ?? hasTypeScript) {
|
|
36
|
-
const defaultIgnores = ["**/node_modules/**", "dist/**", "output/**"];
|
|
37
|
-
reasonConfigs = [...initialConfigs, ...tseslint.configs.recommended].map(
|
|
38
|
-
(config) => ({
|
|
39
|
-
...config,
|
|
40
|
-
files: [
|
|
41
|
-
"**/*.ts",
|
|
42
|
-
"**/*.tsx",
|
|
43
|
-
...(config?.files?.flat(Infinity) ?? []),
|
|
44
|
-
],
|
|
45
|
-
ignores: [...defaultIgnores, ...(configs?.ignores ?? [])],
|
|
46
|
-
}),
|
|
47
|
-
);
|
|
48
|
-
}
|
|
49
|
-
return reasonConfigs;
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
export default initialConfigs;
|
package/src/rules/react.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
// /** @type {import('eslint').Linter.Config} */
|
|
2
|
-
// export default {
|
|
3
|
-
// extends: ["plugin:react-hooks/recommended", "plugin:jsx-a11y/recommended"],
|
|
4
|
-
// plugins: ["react"],
|
|
5
|
-
// rules: {
|
|
6
|
-
// "react/self-closing-comp": "warn", // 要求没有子元素的组件使用自闭合标签
|
|
7
|
-
// },
|
|
8
|
-
// };
|
package/src/types.d.ts
DELETED
package/src/utils/check-react.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import fs from "fs";
|
|
2
|
-
import path from "path";
|
|
3
|
-
|
|
4
|
-
const checkHasReact = () => {
|
|
5
|
-
const packageJsonPath = path.join(process.cwd(), "package.json");
|
|
6
|
-
if (fs.existsSync(packageJsonPath)) {
|
|
7
|
-
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf-8"));
|
|
8
|
-
const dependencies = packageJson.dependencies || {};
|
|
9
|
-
const devDependencies = packageJson.devDependencies || {};
|
|
10
|
-
const isReactProject =
|
|
11
|
-
"react" in dependencies || "react" in devDependencies;
|
|
12
|
-
return isReactProject;
|
|
13
|
-
}
|
|
14
|
-
return false;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export default checkHasReact;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import fs from "fs";
|
|
2
|
-
import path from "path";
|
|
3
|
-
|
|
4
|
-
const checkHasTailwindcss = () => {
|
|
5
|
-
const possibleConfigFiles = [
|
|
6
|
-
"tailwind.config.js",
|
|
7
|
-
"tailwind.config.cjs",
|
|
8
|
-
"tailwind.config.mjs",
|
|
9
|
-
"tailwind.config.ts",
|
|
10
|
-
"tailwind.config.mts",
|
|
11
|
-
];
|
|
12
|
-
const configFileExists = possibleConfigFiles.some((file) =>
|
|
13
|
-
fs.existsSync(path.join(process.cwd(), file)),
|
|
14
|
-
);
|
|
15
|
-
return configFileExists;
|
|
16
|
-
};
|
|
17
|
-
export default checkHasTailwindcss;
|