@rootreeweb/linting 4.2.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 +100 -0
- package/dist/esm/eslint/astro.d.ts +3 -0
- package/dist/esm/eslint/astro.d.ts.map +1 -0
- package/dist/esm/eslint/astro.js +29 -0
- package/dist/esm/eslint/astro.js.map +1 -0
- package/dist/esm/eslint/basic.d.ts +3 -0
- package/dist/esm/eslint/basic.d.ts.map +1 -0
- package/dist/esm/eslint/basic.js +155 -0
- package/dist/esm/eslint/basic.js.map +1 -0
- package/dist/esm/eslint/index.d.ts +15 -0
- package/dist/esm/eslint/index.d.ts.map +1 -0
- package/dist/esm/eslint/index.js +23 -0
- package/dist/esm/eslint/index.js.map +1 -0
- package/dist/esm/eslint/jsdoc.d.ts +3 -0
- package/dist/esm/eslint/jsdoc.d.ts.map +1 -0
- package/dist/esm/eslint/jsdoc.js +33 -0
- package/dist/esm/eslint/jsdoc.js.map +1 -0
- package/dist/esm/eslint/next.d.ts +3 -0
- package/dist/esm/eslint/next.d.ts.map +1 -0
- package/dist/esm/eslint/next.js +15 -0
- package/dist/esm/eslint/next.js.map +1 -0
- package/dist/esm/eslint/patches/index.d.ts +10 -0
- package/dist/esm/eslint/patches/index.d.ts.map +1 -0
- package/dist/esm/eslint/patches/index.js +16 -0
- package/dist/esm/eslint/patches/index.js.map +1 -0
- package/dist/esm/eslint/patches/sonarjs.d.ts +14 -0
- package/dist/esm/eslint/patches/sonarjs.d.ts.map +1 -0
- package/dist/esm/eslint/patches/sonarjs.js +83 -0
- package/dist/esm/eslint/patches/sonarjs.js.map +1 -0
- package/dist/esm/eslint/patches/types.d.ts +30 -0
- package/dist/esm/eslint/patches/types.d.ts.map +1 -0
- package/dist/esm/eslint/patches/types.js +2 -0
- package/dist/esm/eslint/patches/types.js.map +1 -0
- package/dist/esm/eslint/plugins.d.ts +3 -0
- package/dist/esm/eslint/plugins.d.ts.map +1 -0
- package/dist/esm/eslint/plugins.js +3 -0
- package/dist/esm/eslint/plugins.js.map +1 -0
- package/dist/esm/eslint/react.d.ts +3 -0
- package/dist/esm/eslint/react.d.ts.map +1 -0
- package/dist/esm/eslint/react.js +59 -0
- package/dist/esm/eslint/react.js.map +1 -0
- package/dist/esm/eslint/tailwind.d.ts +7 -0
- package/dist/esm/eslint/tailwind.d.ts.map +1 -0
- package/dist/esm/eslint/tailwind.js +69 -0
- package/dist/esm/eslint/tailwind.js.map +1 -0
- package/dist/esm/eslint/turbo.d.ts +3 -0
- package/dist/esm/eslint/turbo.d.ts.map +1 -0
- package/dist/esm/eslint/turbo.js +5 -0
- package/dist/esm/eslint/turbo.js.map +1 -0
- package/dist/esm/eslint/utils.d.ts +11 -0
- package/dist/esm/eslint/utils.d.ts.map +1 -0
- package/dist/esm/eslint/utils.js +32 -0
- package/dist/esm/eslint/utils.js.map +1 -0
- package/dist/esm/index.d.ts +6 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +6 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/knip.d.ts +20 -0
- package/dist/esm/knip.d.ts.map +1 -0
- package/dist/esm/knip.js +25 -0
- package/dist/esm/knip.js.map +1 -0
- package/dist/esm/lintStaged.d.ts +32 -0
- package/dist/esm/lintStaged.d.ts.map +1 -0
- package/dist/esm/lintStaged.js +88 -0
- package/dist/esm/lintStaged.js.map +1 -0
- package/dist/esm/prettier.d.ts +28 -0
- package/dist/esm/prettier.d.ts.map +1 -0
- package/dist/esm/prettier.js +62 -0
- package/dist/esm/prettier.js.map +1 -0
- package/dist/esm/stylelint/basic.d.ts +5 -0
- package/dist/esm/stylelint/basic.d.ts.map +1 -0
- package/dist/esm/stylelint/basic.js +17 -0
- package/dist/esm/stylelint/basic.js.map +1 -0
- package/dist/esm/stylelint/index.d.ts +3 -0
- package/dist/esm/stylelint/index.d.ts.map +1 -0
- package/dist/esm/stylelint/index.js +3 -0
- package/dist/esm/stylelint/index.js.map +1 -0
- package/dist/esm/stylelint/tailwind.d.ts +3 -0
- package/dist/esm/stylelint/tailwind.d.ts.map +1 -0
- package/dist/esm/stylelint/tailwind.js +37 -0
- package/dist/esm/stylelint/tailwind.js.map +1 -0
- package/package.json +107 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { Rule } from "eslint";
|
|
2
|
+
import type ts from "typescript";
|
|
3
|
+
/**
|
|
4
|
+
* Contract that every ESLint plugin patch must satisfy. Patches receive the
|
|
5
|
+
* full plugin map and apply mutations in-place.
|
|
6
|
+
*/
|
|
7
|
+
export type ESLintPatch = {
|
|
8
|
+
apply(plugins: Record<string, ESLintPlugin>): void;
|
|
9
|
+
readonly name: string;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Represents a structural subset of a standard ESLint plugin object. Used as a
|
|
13
|
+
* boundary type when passing plugins into the patch system.
|
|
14
|
+
*/
|
|
15
|
+
export type ESLintPlugin = {
|
|
16
|
+
configs?: Record<string, unknown>;
|
|
17
|
+
processors?: Record<string, unknown>;
|
|
18
|
+
rules?: Record<string, Rule.RuleModule>;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Represents a simplified, type-safe subset of the TypeScript-ESLint parser
|
|
22
|
+
* services that are required for type-aware custom rule creation.
|
|
23
|
+
*/
|
|
24
|
+
export type TypeAwareParserServices = {
|
|
25
|
+
esTreeNodeToTSNodeMap: {
|
|
26
|
+
get(node: Rule.Node): ts.Node | undefined;
|
|
27
|
+
};
|
|
28
|
+
program: ts.Program;
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/eslint/patches/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AACnC,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAEjC;;;GAGG;AACH,MAAM,MAAM,WAAW,GAAG;IACzB,KAAK,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,GAAG,IAAI,CAAC;IACnD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACrC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;CACxC,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,uBAAuB,GAAG;IACrC,qBAAqB,EAAE;QACtB,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,GAAG,EAAE,CAAC,IAAI,GAAG,SAAS,CAAC;KAC1C,CAAC;IACF,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC;CACpB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/eslint/patches/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Rule } from \"eslint\";\nimport type ts from \"typescript\";\n\n/**\n * Contract that every ESLint plugin patch must satisfy. Patches receive the\n * full plugin map and apply mutations in-place.\n */\nexport type ESLintPatch = {\n\tapply(plugins: Record<string, ESLintPlugin>): void;\n\treadonly name: string;\n};\n\n/**\n * Represents a structural subset of a standard ESLint plugin object. Used as a\n * boundary type when passing plugins into the patch system.\n */\nexport type ESLintPlugin = {\n\tconfigs?: Record<string, unknown>;\n\tprocessors?: Record<string, unknown>;\n\trules?: Record<string, Rule.RuleModule>;\n};\n\n/**\n * Represents a simplified, type-safe subset of the TypeScript-ESLint parser\n * services that are required for type-aware custom rule creation.\n */\nexport type TypeAwareParserServices = {\n\tesTreeNodeToTSNodeMap: {\n\t\tget(node: Rule.Node): ts.Node | undefined;\n\t};\n\tprogram: ts.Program;\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugins.d.ts","sourceRoot":"","sources":["../../../src/eslint/plugins.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,wBAAwB,CAAC;AAE7C,OAAO,EAAE,OAAO,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugins.js","sourceRoot":"","sources":["../../../src/eslint/plugins.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,wBAAwB,CAAC;AAE7C,OAAO,EAAE,OAAO,EAAE,CAAC","sourcesContent":["import jsxA11y from \"eslint-plugin-jsx-a11y\";\n\nexport { jsxA11y };\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react.d.ts","sourceRoot":"","sources":["../../../src/eslint/react.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AASrC,eAAO,MAAM,KAAK,EAAE,MAAM,CAAC,MAAM,EAkDhC,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import pluginQuery from "@tanstack/eslint-plugin-query";
|
|
2
|
+
import reactLint from "eslint-plugin-react";
|
|
3
|
+
import reactCompiler from "eslint-plugin-react-compiler";
|
|
4
|
+
import reactHooks from "eslint-plugin-react-hooks";
|
|
5
|
+
import reactYouMightNotNeedAnEffect from "eslint-plugin-react-you-might-not-need-an-effect";
|
|
6
|
+
import testingLibrary from "eslint-plugin-testing-library";
|
|
7
|
+
import { jsxA11y } from "./plugins.js";
|
|
8
|
+
export const react = [
|
|
9
|
+
...pluginQuery.configs["flat/recommended"],
|
|
10
|
+
{
|
|
11
|
+
...jsxA11y.flatConfigs.recommended,
|
|
12
|
+
files: ["**/*.{js,jsx,ts,tsx}"],
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
plugins: {
|
|
16
|
+
"react-compiler": reactCompiler,
|
|
17
|
+
},
|
|
18
|
+
rules: {
|
|
19
|
+
"react-compiler/react-compiler": "error",
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
reactHooks.configs.flat["recommended-latest"],
|
|
23
|
+
reactYouMightNotNeedAnEffect.configs.recommended,
|
|
24
|
+
{
|
|
25
|
+
files: ["**/*.js", "**/*.jsx", "**/*.ts", "**/*.tsx"],
|
|
26
|
+
plugins: {
|
|
27
|
+
react: reactLint,
|
|
28
|
+
},
|
|
29
|
+
rules: {
|
|
30
|
+
"react/boolean-prop-naming": "warn",
|
|
31
|
+
"react/button-has-type": "warn",
|
|
32
|
+
"react/jsx-max-depth": ["warn", { max: 4 }],
|
|
33
|
+
"react/jsx-no-target-blank": "off",
|
|
34
|
+
"react/jsx-no-useless-fragment": "warn",
|
|
35
|
+
"react/no-unstable-nested-components": "warn",
|
|
36
|
+
"react/no-unused-prop-types": "warn",
|
|
37
|
+
"react/react-in-jsx-scope": "off",
|
|
38
|
+
"sonarjs/jsx-no-leaked-render": "off",
|
|
39
|
+
},
|
|
40
|
+
settings: {
|
|
41
|
+
react: {
|
|
42
|
+
version: "19.0.0",
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
...testingLibrary.configs["flat/react"],
|
|
48
|
+
files: [
|
|
49
|
+
"tests/**/*.js",
|
|
50
|
+
"tests/**/*.jsx",
|
|
51
|
+
"tests/**/*.ts",
|
|
52
|
+
"tests/**/*.tsx",
|
|
53
|
+
],
|
|
54
|
+
rules: {
|
|
55
|
+
"testing-library/no-node-access": "warn",
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
];
|
|
59
|
+
//# sourceMappingURL=react.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react.js","sourceRoot":"","sources":["../../../src/eslint/react.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,+BAA+B,CAAC;AAExD,OAAO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eAAe;YACf,gBAAgB;SAChB;QACD,KAAK,EAAE;YACN,gCAAgC,EAAE,MAAM;SACxC;KACD;CACD,CAAC","sourcesContent":["import pluginQuery from \"@tanstack/eslint-plugin-query\";\nimport type { Linter } from \"eslint\";\nimport reactLint from \"eslint-plugin-react\";\nimport reactCompiler from \"eslint-plugin-react-compiler\";\nimport reactHooks from \"eslint-plugin-react-hooks\";\nimport reactYouMightNotNeedAnEffect from \"eslint-plugin-react-you-might-not-need-an-effect\";\nimport testingLibrary from \"eslint-plugin-testing-library\";\n\nimport { jsxA11y } from \"./plugins.js\";\n\nexport const react: Linter.Config[] = [\n\t...pluginQuery.configs[\"flat/recommended\"],\n\t{\n\t\t...jsxA11y.flatConfigs.recommended,\n\t\tfiles: [\"**/*.{js,jsx,ts,tsx}\"],\n\t},\n\t{\n\t\tplugins: {\n\t\t\t\"react-compiler\": reactCompiler,\n\t\t},\n\t\trules: {\n\t\t\t\"react-compiler/react-compiler\": \"error\",\n\t\t},\n\t},\n\treactHooks.configs.flat[\"recommended-latest\"],\n\treactYouMightNotNeedAnEffect.configs.recommended,\n\t{\n\t\tfiles: [\"**/*.js\", \"**/*.jsx\", \"**/*.ts\", \"**/*.tsx\"],\n\t\tplugins: {\n\t\t\treact: reactLint,\n\t\t},\n\t\trules: {\n\t\t\t\"react/boolean-prop-naming\": \"warn\",\n\t\t\t\"react/button-has-type\": \"warn\",\n\t\t\t\"react/jsx-max-depth\": [\"warn\", { max: 4 }],\n\t\t\t\"react/jsx-no-target-blank\": \"off\",\n\t\t\t\"react/jsx-no-useless-fragment\": \"warn\",\n\t\t\t\"react/no-unstable-nested-components\": \"warn\",\n\t\t\t\"react/no-unused-prop-types\": \"warn\",\n\t\t\t\"react/react-in-jsx-scope\": \"off\",\n\t\t\t\"sonarjs/jsx-no-leaked-render\": \"off\",\n\t\t},\n\t\tsettings: {\n\t\t\treact: {\n\t\t\t\tversion: \"19.0.0\",\n\t\t\t},\n\t\t},\n\t},\n\t{\n\t\t...testingLibrary.configs[\"flat/react\"],\n\t\tfiles: [\n\t\t\t\"tests/**/*.js\",\n\t\t\t\"tests/**/*.jsx\",\n\t\t\t\"tests/**/*.ts\",\n\t\t\t\"tests/**/*.tsx\",\n\t\t],\n\t\trules: {\n\t\t\t\"testing-library/no-node-access\": \"warn\",\n\t\t},\n\t},\n];\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tailwind.d.ts","sourceRoot":"","sources":["../../../src/eslint/tailwind.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAqCrC,MAAM,MAAM,eAAe,GAAG;IAC7B,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,eAAO,MAAM,WAAW,YAAa,eAAe,KAAG,MAAM,CAAC,MAAM,EA+BnE,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import tailwindLint from "eslint-plugin-tailwindcss";
|
|
3
|
+
/**
|
|
4
|
+
* Patch eslint-plugin-tailwindcss rules that call `context.getSourceCode()`,
|
|
5
|
+
* which was removed in ESLint 10 in favor of `context.sourceCode`. Affected
|
|
6
|
+
* rules: enforces-shorthand, classnames-order, migration-from-tailwind-2.
|
|
7
|
+
*/
|
|
8
|
+
const rulesToPatch = [
|
|
9
|
+
"enforces-shorthand",
|
|
10
|
+
"classnames-order",
|
|
11
|
+
"migration-from-tailwind-2",
|
|
12
|
+
];
|
|
13
|
+
const rules = tailwindLint.rules;
|
|
14
|
+
if (rules) {
|
|
15
|
+
for (const ruleName of rulesToPatch) {
|
|
16
|
+
const rule = rules[ruleName];
|
|
17
|
+
if (!rule)
|
|
18
|
+
continue;
|
|
19
|
+
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
20
|
+
const originalCreate = rule.create;
|
|
21
|
+
rule.create = function (context) {
|
|
22
|
+
if (!context.getSourceCode && context.sourceCode) {
|
|
23
|
+
const patchedContext = new Proxy(context, {
|
|
24
|
+
get(target, prop) {
|
|
25
|
+
if (prop === "getSourceCode") {
|
|
26
|
+
return () => target.sourceCode;
|
|
27
|
+
}
|
|
28
|
+
return target[prop];
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
return originalCreate(patchedContext);
|
|
32
|
+
}
|
|
33
|
+
return originalCreate(context);
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
export const getTailwind = (options) => {
|
|
38
|
+
const { twCallees: callees = [], twConfig } = options;
|
|
39
|
+
const config = path.isAbsolute(twConfig) ? twConfig : path.resolve(twConfig);
|
|
40
|
+
return [
|
|
41
|
+
...tailwindLint.configs["flat/recommended"],
|
|
42
|
+
{
|
|
43
|
+
rules: {
|
|
44
|
+
"tailwindcss/classnames-order": "off", // Conflicts with prettier
|
|
45
|
+
"tailwindcss/no-custom-classname": [
|
|
46
|
+
"warn",
|
|
47
|
+
{
|
|
48
|
+
callees: ["twMerge", ...callees],
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
},
|
|
52
|
+
settings: {
|
|
53
|
+
tailwindcss: {
|
|
54
|
+
callees: ["classnames", "clsx", "ctl", "twMerge", ...callees],
|
|
55
|
+
config,
|
|
56
|
+
cssFiles: [
|
|
57
|
+
"**/*.css",
|
|
58
|
+
"!**/node_modules",
|
|
59
|
+
"!**/vendor",
|
|
60
|
+
"!**/.*",
|
|
61
|
+
"!**/dist",
|
|
62
|
+
"!**/build",
|
|
63
|
+
],
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
];
|
|
68
|
+
};
|
|
69
|
+
//# sourceMappingURL=tailwind.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tailwind.js","sourceRoot":"","sources":["../../../src/eslint/tailwind.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OA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IAC7E,OAAO;QACN,GAAG,YAAY,CAAC,OAAO,CAAC,kBAAkB,CAAC;QAC3C;YACC,KAAK,EAAE;gBACN,8BAA8B,EAAE,KAAK,EAAE,0BAA0B;gBACjE,iCAAiC,EAAE;oBAClC,MAAM;oBACN;wBACC,OAAO,EAAE,CAAC,SAAS,EAAE,GAAG,OAAO,CAAC;qBAChC;iBACD;aACD;YACD,QAAQ,EAAE;gBACT,WAAW,EAAE;oBACZ,OAAO,EAAE,CAAC,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;oBAC7D,MAAM;oBACN,QAAQ,EAAE;wBACT,UAAU;wBACV,kBAAkB;wBAClB,YAAY;wBACZ,QAAQ;wBACR,UAAU;wBACV,WAAW;qBACX;iBACD;aACD;SACD;KACD,CAAC;AACH,CAAC,CAAC","sourcesContent":["import path from \"path\";\nimport type { Linter } from \"eslint\";\nimport tailwindLint from \"eslint-plugin-tailwindcss\";\n\n/**\n * Patch eslint-plugin-tailwindcss rules that call `context.getSourceCode()`,\n * which was removed in ESLint 10 in favor of `context.sourceCode`. Affected\n * rules: enforces-shorthand, classnames-order, migration-from-tailwind-2.\n */\nconst rulesToPatch = [\n\t\"enforces-shorthand\",\n\t\"classnames-order\",\n\t\"migration-from-tailwind-2\",\n] as const;\n\nconst rules = tailwindLint.rules;\nif (rules) {\n\tfor (const ruleName of rulesToPatch) {\n\t\tconst rule = rules[ruleName];\n\t\tif (!rule) continue;\n\t\t// eslint-disable-next-line @typescript-eslint/unbound-method\n\t\tconst originalCreate = rule.create;\n\t\trule.create = function (context: any) {\n\t\t\tif (!context.getSourceCode && context.sourceCode) {\n\t\t\t\tconst patchedContext = new Proxy(context, {\n\t\t\t\t\tget(target, prop) {\n\t\t\t\t\t\tif (prop === \"getSourceCode\") {\n\t\t\t\t\t\t\treturn () => target.sourceCode;\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn target[prop as keyof typeof target];\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t\treturn originalCreate(patchedContext);\n\t\t\t}\n\t\t\treturn originalCreate(context);\n\t\t};\n\t}\n}\nexport type TailwindOptions = {\n\ttwCallees?: string[];\n\ttwConfig: string;\n};\n\nexport const getTailwind = (options: TailwindOptions): Linter.Config[] => {\n\tconst { twCallees: callees = [], twConfig } = options;\n\tconst config = path.isAbsolute(twConfig) ? twConfig : path.resolve(twConfig);\n\treturn [\n\t\t...tailwindLint.configs[\"flat/recommended\"],\n\t\t{\n\t\t\trules: {\n\t\t\t\t\"tailwindcss/classnames-order\": \"off\", // Conflicts with prettier\n\t\t\t\t\"tailwindcss/no-custom-classname\": [\n\t\t\t\t\t\"warn\",\n\t\t\t\t\t{\n\t\t\t\t\t\tcallees: [\"twMerge\", ...callees],\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t},\n\t\t\tsettings: {\n\t\t\t\ttailwindcss: {\n\t\t\t\t\tcallees: [\"classnames\", \"clsx\", \"ctl\", \"twMerge\", ...callees],\n\t\t\t\t\tconfig,\n\t\t\t\t\tcssFiles: [\n\t\t\t\t\t\t\"**/*.css\",\n\t\t\t\t\t\t\"!**/node_modules\",\n\t\t\t\t\t\t\"!**/vendor\",\n\t\t\t\t\t\t\"!**/.*\",\n\t\t\t\t\t\t\"!**/dist\",\n\t\t\t\t\t\t\"!**/build\",\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t];\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"turbo.d.ts","sourceRoot":"","sources":["../../../src/eslint/turbo.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGrC,eAAO,MAAM,KAAK,EAAE,MAAM,CAAC,MAAM,EAEhC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"turbo.js","sourceRoot":"","sources":["../../../src/eslint/turbo.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAE9C,MAAM,CAAC,MAAM,KAAK,GAAoB;IACrC,OAAO,EAAE,CAAC,kBAAkB,CAAkB;CAC9C,CAAC","sourcesContent":["import type { Linter } from \"eslint\";\nimport { configs } from \"eslint-plugin-turbo\";\n\nexport const turbo: Linter.Config[] = [\n\tconfigs?.[\"flat/recommended\"] as Linter.Config,\n];\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Linter } from "eslint";
|
|
2
|
+
/**
|
|
3
|
+
* Deduplicates plugins in an ESLint flat configuration array. If multiple
|
|
4
|
+
* configs define the same plugin name with different objects, the first one
|
|
5
|
+
* encountered will be used.
|
|
6
|
+
*
|
|
7
|
+
* @param configs The configuration array to deduplicate.
|
|
8
|
+
* @returns The deduplicated configuration array.
|
|
9
|
+
*/
|
|
10
|
+
export declare function deduplicatePlugins(configs: Linter.Config[]): Linter.Config[];
|
|
11
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/eslint/utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAErC;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,CAoB5E"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deduplicates plugins in an ESLint flat configuration array. If multiple
|
|
3
|
+
* configs define the same plugin name with different objects, the first one
|
|
4
|
+
* encountered will be used.
|
|
5
|
+
*
|
|
6
|
+
* @param configs The configuration array to deduplicate.
|
|
7
|
+
* @returns The deduplicated configuration array.
|
|
8
|
+
*/
|
|
9
|
+
export function deduplicatePlugins(configs) {
|
|
10
|
+
const pluginsMap = new Map();
|
|
11
|
+
return configs.map((config) => {
|
|
12
|
+
if (!config.plugins)
|
|
13
|
+
return config;
|
|
14
|
+
const newPlugins = { ...config.plugins };
|
|
15
|
+
let modified = false;
|
|
16
|
+
for (const name of Object.getOwnPropertyNames(newPlugins)) {
|
|
17
|
+
const plugin = newPlugins[name];
|
|
18
|
+
if (pluginsMap.has(name)) {
|
|
19
|
+
const existing = pluginsMap.get(name);
|
|
20
|
+
if (existing !== plugin) {
|
|
21
|
+
newPlugins[name] = existing;
|
|
22
|
+
modified = true;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
pluginsMap.set(name, plugin);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return modified ? { ...config, plugins: newPlugins } : config;
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/eslint/utils.ts"],"names":[],"mappings":"AAGA;;;;;;;GAOG;AACH,MAAM,UAAU,kBAAkB,CAAC,OAAwB;IAC1D,MAAM,UAAU,GAAG,IAAI,GAAG,EAAe,CAAC;IAC1C,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE;QAC7B,IAAI,CAAC,MAAM,CAAC,OAAO;YAAE,OAAO,MAAM,CAAC;QACnC,MAAM,UAAU,GAAG,EAAE,GAAG,MAAM,CAAC,OAAO,EAAE,CAAC;QACzC,IAAI,QAAQ,GAAG,KAAK,CAAC;QACrB,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,mBAAmB,CAAC,UAAU,CAAC,EAAE,CAAC;YAC3D,MAAM,MAAM,GAAI,UAAkB,CAAC,IAAI,CAAC,CAAC;YACzC,IAAI,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;gBAC1B,MAAM,QAAQ,GAAG,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;gBACtC,IAAI,QAAQ,KAAK,MAAM,EAAE,CAAC;oBACzB,UAAU,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC;oBAC5B,QAAQ,GAAG,IAAI,CAAC;gBACjB,CAAC;YACF,CAAC;iBAAM,CAAC;gBACP,UAAU,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;YAC9B,CAAC;QACF,CAAC;QACD,OAAO,QAAQ,CAAC,CAAC,CAAC,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;IAC/D,CAAC,CAAC,CAAC;AACJ,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access */\nimport type { Linter } from \"eslint\";\n\n/**\n * Deduplicates plugins in an ESLint flat configuration array. If multiple\n * configs define the same plugin name with different objects, the first one\n * encountered will be used.\n *\n * @param configs The configuration array to deduplicate.\n * @returns The deduplicated configuration array.\n */\nexport function deduplicatePlugins(configs: Linter.Config[]): Linter.Config[] {\n\tconst pluginsMap = new Map<string, any>();\n\treturn configs.map((config) => {\n\t\tif (!config.plugins) return config;\n\t\tconst newPlugins = { ...config.plugins };\n\t\tlet modified = false;\n\t\tfor (const name of Object.getOwnPropertyNames(newPlugins)) {\n\t\t\tconst plugin = (newPlugins as any)[name];\n\t\t\tif (pluginsMap.has(name)) {\n\t\t\t\tconst existing = pluginsMap.get(name);\n\t\t\t\tif (existing !== plugin) {\n\t\t\t\t\tnewPlugins[name] = existing;\n\t\t\t\t\tmodified = true;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tpluginsMap.set(name, plugin);\n\t\t\t}\n\t\t}\n\t\treturn modified ? { ...config, plugins: newPlugins } : config;\n\t});\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC","sourcesContent":["export * from \"./eslint/index.js\";\nexport * from \"./knip.js\";\nexport * from \"./lintStaged.js\";\nexport * from \"./prettier.js\";\nexport * from \"./stylelint/index.js\";\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export declare const knipJS: {
|
|
2
|
+
entry: string[];
|
|
3
|
+
ignoreDependencies: string[];
|
|
4
|
+
prettier: {};
|
|
5
|
+
project: string[];
|
|
6
|
+
stylelint: {};
|
|
7
|
+
tags: string[];
|
|
8
|
+
vitest: {};
|
|
9
|
+
};
|
|
10
|
+
export declare const knipWebpack: {
|
|
11
|
+
entry: string[];
|
|
12
|
+
ignoreDependencies: string[];
|
|
13
|
+
prettier: {};
|
|
14
|
+
project: string[];
|
|
15
|
+
stylelint: {};
|
|
16
|
+
tags: string[];
|
|
17
|
+
vitest: {};
|
|
18
|
+
webpack: {};
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=knip.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"knip.d.ts","sourceRoot":"","sources":["../../src/knip.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,MAAM;;;;;;;;CAQG,CAAC;AAEvB,eAAO,MAAM,WAAW;;;;;;;;;CASF,CAAC"}
|
package/dist/esm/knip.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
const ignoreDependencies = [
|
|
2
|
+
"prettier-plugin-*",
|
|
3
|
+
"stylelint-config-*",
|
|
4
|
+
"stylelint-prettier",
|
|
5
|
+
];
|
|
6
|
+
export const knipJS = {
|
|
7
|
+
entry: ["src/index.ts"],
|
|
8
|
+
ignoreDependencies,
|
|
9
|
+
prettier: {},
|
|
10
|
+
project: ["src/**/*", "tests/**/*"],
|
|
11
|
+
stylelint: {},
|
|
12
|
+
tags: ["-lintignore"],
|
|
13
|
+
vitest: {},
|
|
14
|
+
};
|
|
15
|
+
export const knipWebpack = {
|
|
16
|
+
entry: ["js/index.ts"],
|
|
17
|
+
ignoreDependencies,
|
|
18
|
+
prettier: {},
|
|
19
|
+
project: ["js/**/*", "tests/**/*"],
|
|
20
|
+
stylelint: {},
|
|
21
|
+
tags: ["-lintignore"],
|
|
22
|
+
vitest: {},
|
|
23
|
+
webpack: {},
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=knip.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"knip.js","sourceRoot":"","sources":["../../src/knip.ts"],"names":[],"mappings":"AAEA,MAAM,kBAAkB,GAAG;IAC1B,mBAAmB;IACnB,oBAAoB;IACpB,oBAAoB;CACpB,CAAC;AACF,MAAM,CAAC,MAAM,MAAM,GAAG;IACrB,KAAK,EAAE,CAAC,cAAc,CAAC;IACvB,kBAAkB;IAClB,QAAQ,EAAE,EAAE;IACZ,OAAO,EAAE,CAAC,UAAU,EAAE,YAAY,CAAC;IACnC,SAAS,EAAE,EAAE;IACb,IAAI,EAAE,CAAC,aAAa,CAAC;IACrB,MAAM,EAAE,EAAE;CACW,CAAC;AAEvB,MAAM,CAAC,MAAM,WAAW,GAAG;IAC1B,KAAK,EAAE,CAAC,aAAa,CAAC;IACtB,kBAAkB;IAClB,QAAQ,EAAE,EAAE;IACZ,OAAO,EAAE,CAAC,SAAS,EAAE,YAAY,CAAC;IAClC,SAAS,EAAE,EAAE;IACb,IAAI,EAAE,CAAC,aAAa,CAAC;IACrB,MAAM,EAAE,EAAE;IACV,OAAO,EAAE,EAAE;CACU,CAAC","sourcesContent":["import type { KnipConfig } from \"knip\";\n\nconst ignoreDependencies = [\n\t\"prettier-plugin-*\",\n\t\"stylelint-config-*\",\n\t\"stylelint-prettier\",\n];\nexport const knipJS = {\n\tentry: [\"src/index.ts\"],\n\tignoreDependencies,\n\tprettier: {},\n\tproject: [\"src/**/*\", \"tests/**/*\"],\n\tstylelint: {},\n\ttags: [\"-lintignore\"],\n\tvitest: {},\n} satisfies KnipConfig;\n\nexport const knipWebpack = {\n\tentry: [\"js/index.ts\"],\n\tignoreDependencies,\n\tprettier: {},\n\tproject: [\"js/**/*\", \"tests/**/*\"],\n\tstylelint: {},\n\ttags: [\"-lintignore\"],\n\tvitest: {},\n\twebpack: {},\n} satisfies KnipConfig;\n"]}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gets the name of the currently checked-out git branch.
|
|
3
|
+
*
|
|
4
|
+
* @returns The branch name.
|
|
5
|
+
*/
|
|
6
|
+
export declare function getBranchName(): string;
|
|
7
|
+
declare const tasks: {
|
|
8
|
+
all: {
|
|
9
|
+
[x: string]: string[];
|
|
10
|
+
};
|
|
11
|
+
main: {
|
|
12
|
+
[x: string]: string[];
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Determines if a tsconfig file is present.
|
|
17
|
+
*
|
|
18
|
+
* @returns True if a tsconfig.json is present.
|
|
19
|
+
*/
|
|
20
|
+
export declare function hasTsconfig(): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Checks if there are tasks for the given branch
|
|
23
|
+
*
|
|
24
|
+
* @param name The name of the branch to check
|
|
25
|
+
* @returns True if the branch has rules defined.
|
|
26
|
+
*/
|
|
27
|
+
export declare function isDefinedBranch(name: string): name is keyof typeof tasks;
|
|
28
|
+
export declare const lintStagedBase: {
|
|
29
|
+
[x: string]: string[];
|
|
30
|
+
};
|
|
31
|
+
export {};
|
|
32
|
+
//# sourceMappingURL=lintStaged.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lintStaged.d.ts","sourceRoot":"","sources":["../../src/lintStaged.ts"],"names":[],"mappings":"AAMA;;;;GAIG;AACH,wBAAgB,aAAa,IAAI,MAAM,CAqBtC;AAUD,QAAA,MAAM,KAAK;;;;;;;CAaV,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,WAAW,IAAI,OAAO,CAQrC;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,IAAI,MAAM,OAAO,KAAK,CAExE;AAYD,eAAO,MAAM,cAAc;;CAAS,CAAC"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { execSync, spawnSync } from "child_process";
|
|
2
|
+
import { statSync } from "fs";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import { safeishGetProperty } from "@rootreeweb/js-lib";
|
|
5
|
+
/**
|
|
6
|
+
* Gets the name of the currently checked-out git branch.
|
|
7
|
+
*
|
|
8
|
+
* @returns The branch name.
|
|
9
|
+
*/
|
|
10
|
+
export function getBranchName() {
|
|
11
|
+
let hasGit = false;
|
|
12
|
+
let isRepo = false;
|
|
13
|
+
try {
|
|
14
|
+
// Check if Git is installed
|
|
15
|
+
const gitCheck = spawnSync("which", ["git"]);
|
|
16
|
+
hasGit = gitCheck.status === 0;
|
|
17
|
+
// Check if the current directory is a Git repository
|
|
18
|
+
if (hasGit) {
|
|
19
|
+
const repoCheck = spawnSync("git", [
|
|
20
|
+
"rev-parse",
|
|
21
|
+
"--is-inside-work-tree",
|
|
22
|
+
]);
|
|
23
|
+
isRepo = repoCheck.status === 0;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
catch (e) {
|
|
27
|
+
console.error("Not a repository or git not available", e); // Do nothing.
|
|
28
|
+
}
|
|
29
|
+
if (!hasGit || !isRepo)
|
|
30
|
+
return "none";
|
|
31
|
+
return execSync("git rev-parse --abbrev-ref HEAD").toString().trim();
|
|
32
|
+
}
|
|
33
|
+
const patterns = {
|
|
34
|
+
all: "*",
|
|
35
|
+
eslint: "*.{js,ts,jsx,tsx,cjs,mjs,astro}",
|
|
36
|
+
php: "*.php",
|
|
37
|
+
stylelint: "*.{css,scss}",
|
|
38
|
+
typeCheck: "*.{ts,tsx,json,astro}",
|
|
39
|
+
};
|
|
40
|
+
const tasks = {
|
|
41
|
+
all: {
|
|
42
|
+
[patterns.all]: ["prettier --ignore-unknown --write --cache"],
|
|
43
|
+
[patterns.php]: [
|
|
44
|
+
"./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php",
|
|
45
|
+
"./vendor/bin/phpcbf --standard=phpcs.xml -d error_reporting=24575",
|
|
46
|
+
],
|
|
47
|
+
},
|
|
48
|
+
main: {
|
|
49
|
+
[patterns.eslint]: ["eslint --fix --cache"],
|
|
50
|
+
[patterns.stylelint]: ["stylelint --fix --cache"],
|
|
51
|
+
[patterns.typeCheck]: ["sh -c 'tsc --noEmit'"],
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Determines if a tsconfig file is present.
|
|
56
|
+
*
|
|
57
|
+
* @returns True if a tsconfig.json is present.
|
|
58
|
+
*/
|
|
59
|
+
export function hasTsconfig() {
|
|
60
|
+
try {
|
|
61
|
+
const result = statSync(path.resolve("tsconfig.json"));
|
|
62
|
+
return result.isFile();
|
|
63
|
+
// eslint-disable-next-line sonarjs/no-ignored-exceptions
|
|
64
|
+
}
|
|
65
|
+
catch (_) {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Checks if there are tasks for the given branch
|
|
71
|
+
*
|
|
72
|
+
* @param name The name of the branch to check
|
|
73
|
+
* @returns True if the branch has rules defined.
|
|
74
|
+
*/
|
|
75
|
+
export function isDefinedBranch(name) {
|
|
76
|
+
return name in tasks;
|
|
77
|
+
}
|
|
78
|
+
const branch = getBranchName();
|
|
79
|
+
const output = tasks.all;
|
|
80
|
+
if (isDefinedBranch(branch)) {
|
|
81
|
+
Object.assign(output, safeishGetProperty(tasks, branch));
|
|
82
|
+
}
|
|
83
|
+
if (!hasTsconfig() && patterns.typeCheck in output) {
|
|
84
|
+
// eslint-disable-next-line
|
|
85
|
+
delete output[patterns.typeCheck];
|
|
86
|
+
}
|
|
87
|
+
export const lintStagedBase = output;
|
|
88
|
+
//# sourceMappingURL=lintStaged.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lintStaged.js","sourceRoot":"","sources":["../../src/lintStaged.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AAC9B,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAExD;;;;GAIG;AACH,MAAM,UAAU,aAAa;IAC5B,IAAI,MAAM,GAAG,KAAK,CAAC;IACnB,IAAI,MAAM,GAAG,KAAK,CAAC;IACnB,IAAI,CAAC;QACJ,4BAA4B;QAC5B,MAAM,QAAQ,GAAG,SAAS,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;QAC7C,MAAM,GAAG,QAAQ,CAAC,MAAM,KAAK,CAAC,CAAC;QAE/B,qDAAqD;QACrD,IAAI,MAAM,EAAE,CAAC;YACZ,MAAM,SAAS,GAAG,SAAS,CAAC,KAAK,EAAE;gBAClC,WAAW;gBACX,uBAAuB;aACvB,CAAC,CAAC;YACH,MAAM,GAAG,SAAS,CAAC,MAAM,KAAK,CAAC,CAAC;QACjC,CAAC;IACF,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACZ,OAAO,CAAC,KAAK,CAAC,uCAAuC,EAAE,CAAC,CAAC,CAAC,CAAC,cAAc;IAC1E,CAAC;IACD,IAAI,CAAC,MAAM,IAAI,CAAC,MAAM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AM,CAAC,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC;AAC1D,CAAC;AACD,IAAI,CAAC,WAAW,EAAE,IAAI,QAAQ,CAAC,SAAS,IAAI,MAAM,EAAE,CAAC;IACpD,2BAA2B;IAC3B,OAAO,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;AACnC,CAAC;AACD,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC","sourcesContent":["import { execSync, spawnSync } from \"child_process\";\nimport { statSync } from \"fs\";\nimport path from \"path\";\n\nimport { safeishGetProperty } from \"@rootreeweb/js-lib\";\n\n/**\n * Gets the name of the currently checked-out git branch.\n *\n * @returns The branch name.\n */\nexport function getBranchName(): string {\n\tlet hasGit = false;\n\tlet isRepo = false;\n\ttry {\n\t\t// Check if Git is installed\n\t\tconst gitCheck = spawnSync(\"which\", [\"git\"]);\n\t\thasGit = gitCheck.status === 0;\n\n\t\t// Check if the current directory is a Git repository\n\t\tif (hasGit) {\n\t\t\tconst repoCheck = spawnSync(\"git\", [\n\t\t\t\t\"rev-parse\",\n\t\t\t\t\"--is-inside-work-tree\",\n\t\t\t]);\n\t\t\tisRepo = repoCheck.status === 0;\n\t\t}\n\t} catch (e) {\n\t\tconsole.error(\"Not a repository or git not available\", e); // Do nothing.\n\t}\n\tif (!hasGit || !isRepo) return \"none\";\n\treturn execSync(\"git rev-parse --abbrev-ref HEAD\").toString().trim();\n}\n\nconst patterns = {\n\tall: \"*\",\n\teslint: \"*.{js,ts,jsx,tsx,cjs,mjs,astro}\",\n\tphp: \"*.php\",\n\tstylelint: \"*.{css,scss}\",\n\ttypeCheck: \"*.{ts,tsx,json,astro}\",\n};\n\nconst tasks = {\n\tall: {\n\t\t[patterns.all]: [\"prettier --ignore-unknown --write --cache\"],\n\t\t[patterns.php]: [\n\t\t\t\"./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php\",\n\t\t\t\"./vendor/bin/phpcbf --standard=phpcs.xml -d error_reporting=24575\",\n\t\t],\n\t},\n\tmain: {\n\t\t[patterns.eslint]: [\"eslint --fix --cache\"],\n\t\t[patterns.stylelint]: [\"stylelint --fix --cache\"],\n\t\t[patterns.typeCheck]: [\"sh -c 'tsc --noEmit'\"],\n\t},\n};\n\n/**\n * Determines if a tsconfig file is present.\n *\n * @returns True if a tsconfig.json is present.\n */\nexport function hasTsconfig(): boolean {\n\ttry {\n\t\tconst result = statSync(path.resolve(\"tsconfig.json\"));\n\t\treturn result.isFile();\n\t\t// eslint-disable-next-line sonarjs/no-ignored-exceptions\n\t} catch (_) {\n\t\treturn false;\n\t}\n}\n\n/**\n * Checks if there are tasks for the given branch\n *\n * @param name The name of the branch to check\n * @returns True if the branch has rules defined.\n */\nexport function isDefinedBranch(name: string): name is keyof typeof tasks {\n\treturn name in tasks;\n}\n\nconst branch = getBranchName();\n\nconst output = tasks.all;\nif (isDefinedBranch(branch)) {\n\tObject.assign(output, safeishGetProperty(tasks, branch));\n}\nif (!hasTsconfig() && patterns.typeCheck in output) {\n\t// eslint-disable-next-line\n\tdelete output[patterns.typeCheck];\n}\nexport const lintStagedBase = output;\n"]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Config, Plugin } from "prettier";
|
|
2
|
+
export declare const prettier: Config;
|
|
3
|
+
export type PrettierTailwindOptions = {
|
|
4
|
+
functions?: string[];
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Provides a prettier config for Astro projects.
|
|
8
|
+
*
|
|
9
|
+
* @param params The tailwindcss info.
|
|
10
|
+
* @returns The configuration.
|
|
11
|
+
*/
|
|
12
|
+
export declare function prettierAstro(...params: Parameters<typeof prettierTailwind>): Config;
|
|
13
|
+
/**
|
|
14
|
+
* Creates a prettier configuration for tailwind.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* import { prettierTailwind } from "@rootreeweb/linting";
|
|
18
|
+
*
|
|
19
|
+
* export default prettierTailwind("./src/app/globals.css");
|
|
20
|
+
*
|
|
21
|
+
* @param tailwindStylesheet The path to the stylesheet that imports Tailwind.
|
|
22
|
+
* @param options Additional options for generating the configuration.
|
|
23
|
+
* @returns The configuration.
|
|
24
|
+
*/
|
|
25
|
+
export declare function prettierTailwind(tailwindStylesheet: string, options?: PrettierTailwindOptions): Config & {
|
|
26
|
+
plugins: Plugin[];
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=prettier.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prettier.d.ts","sourceRoot":"","sources":["../../src/prettier.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAQ/C,eAAO,MAAM,QAAQ,EAAE,MAatB,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IAAE,SAAS,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC;AAE/D;;;;;GAKG;AACH,wBAAgB,aAAa,CAC5B,GAAG,MAAM,EAAE,UAAU,CAAC,OAAO,gBAAgB,CAAC,GAC5C,MAAM,CAeR;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAC/B,kBAAkB,EAAE,MAAM,EAC1B,OAAO,CAAC,EAAE,uBAAuB,GAC/B,MAAM,GAAG;IAAE,OAAO,EAAE,MAAM,EAAE,CAAA;CAAE,CAQhC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
const plugins = [
|
|
2
|
+
"prettier-plugin-packagejson",
|
|
3
|
+
"@ianvs/prettier-plugin-sort-imports",
|
|
4
|
+
"prettier-plugin-jsdoc",
|
|
5
|
+
];
|
|
6
|
+
export const prettier = {
|
|
7
|
+
importOrder: [
|
|
8
|
+
"<BUILTIN_MODULES>",
|
|
9
|
+
"<THIRD_PARTY_MODULES>",
|
|
10
|
+
"",
|
|
11
|
+
"^@rootreeweb/(.*)$",
|
|
12
|
+
"",
|
|
13
|
+
"^@/(.*)$",
|
|
14
|
+
"^[../]",
|
|
15
|
+
"^[./]",
|
|
16
|
+
],
|
|
17
|
+
plugins,
|
|
18
|
+
useTabs: true,
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Provides a prettier config for Astro projects.
|
|
22
|
+
*
|
|
23
|
+
* @param params The tailwindcss info.
|
|
24
|
+
* @returns The configuration.
|
|
25
|
+
*/
|
|
26
|
+
export function prettierAstro(...params) {
|
|
27
|
+
const base = prettierTailwind(...params);
|
|
28
|
+
return {
|
|
29
|
+
...base,
|
|
30
|
+
overrides: [
|
|
31
|
+
...(base.overrides ?? []),
|
|
32
|
+
{
|
|
33
|
+
files: "*.astro",
|
|
34
|
+
options: {
|
|
35
|
+
parser: "astro",
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
plugins: ["prettier-plugin-astro", ...base.plugins],
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Creates a prettier configuration for tailwind.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* import { prettierTailwind } from "@rootreeweb/linting";
|
|
47
|
+
*
|
|
48
|
+
* export default prettierTailwind("./src/app/globals.css");
|
|
49
|
+
*
|
|
50
|
+
* @param tailwindStylesheet The path to the stylesheet that imports Tailwind.
|
|
51
|
+
* @param options Additional options for generating the configuration.
|
|
52
|
+
* @returns The configuration.
|
|
53
|
+
*/
|
|
54
|
+
export function prettierTailwind(tailwindStylesheet, options) {
|
|
55
|
+
return {
|
|
56
|
+
...prettier,
|
|
57
|
+
plugins: [...plugins, "prettier-plugin-tailwindcss"],
|
|
58
|
+
tailwindFunctions: ["twMerge", ...(options?.functions ?? [])],
|
|
59
|
+
tailwindStylesheet,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=prettier.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prettier.js","sourceRoot":"","sources":["../../src/prettier.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,GAAmC;IAC/C,6BAA6B;IAC7B,qCAAqC;IACrC,uBAAuB;CACvB,CAAC;AAEF,MAAM,CAAC,MAAM,QAAQ,GAAW;IAC/B,WAAW,EAAE;QACZ,mBAAmB;QACnB,uBAAuB;QACvB,EAAE;QACF,oBAAoB;QACpB,EAAE;QACF,UAAU;QACV,QAAQ;QACR,OAAO;KACP;IACD,OAAO;IACP,OAAO,EAAE,IAAI;CACb,CAAC;AAIF;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAC5B,GAAG,MAA2C;IAE9C,MAAM,IAAI,GAAG,gBAAgB,CAAC,GAAG,MAAM,CAAC,CAAC;IACzC,OAAO;QACN,GAAG,IAAI;QACP,SAAS,EAAE;YACV,GAAG,CAAC,IAAI,CAAC,SAAS,IAAI,EAAE,CAAC;YACzB;gBACC,KAAK,EAAE,SAAS;gBAChB,OAAO,EAAE;oBACR,MAAM,EAAE,OAAO;iBACf;aACD;SACD;QACD,OAAO,EAAE,CAAC,uBAAuB,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC;KACnD,CAAC;AACH,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,gBAAgB,CAC/B,kBAA0B,EAC1B,OAAiC;IAEjC,OAAO;QACN,GAAG,QAAQ;QACX,OAAO,EAAE,CAAC,GAAG,OAAO,EAAE,6BAA6B,CAAC;QACpD,iBAAiB,EAAE,CAAC,SAAS,EAAE,GAAG,CAAC,OAAO,EAAE,SAAS,IAAI,EAAE,CAAC,CAAC;QAE7D,kBAAkB;KAClB,CAAC;AACH,CAAC","sourcesContent":["import type { Config, Plugin } from \"prettier\";\n\nconst plugins: NonNullable<Config[\"plugins\"]> = [\n\t\"prettier-plugin-packagejson\",\n\t\"@ianvs/prettier-plugin-sort-imports\",\n\t\"prettier-plugin-jsdoc\",\n];\n\nexport const prettier: Config = {\n\timportOrder: [\n\t\t\"<BUILTIN_MODULES>\",\n\t\t\"<THIRD_PARTY_MODULES>\",\n\t\t\"\",\n\t\t\"^@rootreeweb/(.*)$\",\n\t\t\"\",\n\t\t\"^@/(.*)$\",\n\t\t\"^[../]\",\n\t\t\"^[./]\",\n\t],\n\tplugins,\n\tuseTabs: true,\n};\n\nexport type PrettierTailwindOptions = { functions?: string[] };\n\n/**\n * Provides a prettier config for Astro projects.\n *\n * @param params The tailwindcss info.\n * @returns The configuration.\n */\nexport function prettierAstro(\n\t...params: Parameters<typeof prettierTailwind>\n): Config {\n\tconst base = prettierTailwind(...params);\n\treturn {\n\t\t...base,\n\t\toverrides: [\n\t\t\t...(base.overrides ?? []),\n\t\t\t{\n\t\t\t\tfiles: \"*.astro\",\n\t\t\t\toptions: {\n\t\t\t\t\tparser: \"astro\",\n\t\t\t\t},\n\t\t\t},\n\t\t],\n\t\tplugins: [\"prettier-plugin-astro\", ...base.plugins],\n\t};\n}\n\n/**\n * Creates a prettier configuration for tailwind.\n *\n * @example\n * \timport { prettierTailwind } from \"@rootreeweb/linting\";\n *\n * \texport default prettierTailwind(\"./src/app/globals.css\");\n *\n * @param tailwindStylesheet The path to the stylesheet that imports Tailwind.\n * @param options Additional options for generating the configuration.\n * @returns The configuration.\n */\nexport function prettierTailwind(\n\ttailwindStylesheet: string,\n\toptions?: PrettierTailwindOptions,\n): Config & { plugins: Plugin[] } {\n\treturn {\n\t\t...prettier,\n\t\tplugins: [...plugins, \"prettier-plugin-tailwindcss\"],\n\t\ttailwindFunctions: [\"twMerge\", ...(options?.functions ?? [])],\n\n\t\ttailwindStylesheet,\n\t};\n}\n"]}
|