js-style-kit 0.5.3 → 0.6.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 +169 -357
- package/dist/index.d.ts +4 -1
- package/dist/index.js +84 -17
- package/dist/index.js.map +1 -1
- package/package.json +13 -12
package/dist/index.js
CHANGED
|
@@ -17,6 +17,7 @@ var configNames = {
|
|
|
17
17
|
nextjs: "nextjs",
|
|
18
18
|
perfectionist: "perfectionist",
|
|
19
19
|
preferArrowFunction: "prefer-arrow-function",
|
|
20
|
+
query: "@tanstack/query",
|
|
20
21
|
react: "react",
|
|
21
22
|
reactRefresh: "react-refresh",
|
|
22
23
|
storybook: "storybook:stories",
|
|
@@ -28,6 +29,7 @@ var configNames = {
|
|
|
28
29
|
unicorn: "unicorn"
|
|
29
30
|
};
|
|
30
31
|
var pluginPrefixMap = /* @__PURE__ */ new Map([
|
|
32
|
+
["@tanstack/query", configNames.query],
|
|
31
33
|
["@typescript-eslint", configNames.typescript],
|
|
32
34
|
["import", configNames.import],
|
|
33
35
|
["import-x", configNames.import],
|
|
@@ -827,6 +829,32 @@ var processCustomRules = (customRules) => {
|
|
|
827
829
|
}, {});
|
|
828
830
|
};
|
|
829
831
|
|
|
832
|
+
// src/eslint/query/config.ts
|
|
833
|
+
import queryPlugin from "@tanstack/eslint-plugin-query";
|
|
834
|
+
|
|
835
|
+
// src/eslint/query/rules.ts
|
|
836
|
+
var queryRules = {
|
|
837
|
+
"@tanstack/query/exhaustive-deps": "warn",
|
|
838
|
+
"@tanstack/query/infinite-query-property-order": "warn",
|
|
839
|
+
"@tanstack/query/mutation-property-order": "warn",
|
|
840
|
+
"@tanstack/query/no-rest-destructuring": "warn",
|
|
841
|
+
"@tanstack/query/no-unstable-deps": "warn",
|
|
842
|
+
"@tanstack/query/no-void-query-fn": "warn",
|
|
843
|
+
"@tanstack/query/stable-query-client": "warn"
|
|
844
|
+
};
|
|
845
|
+
|
|
846
|
+
// src/eslint/query/config.ts
|
|
847
|
+
var queryConfig = (customRules) => ({
|
|
848
|
+
name: configNames.query,
|
|
849
|
+
plugins: {
|
|
850
|
+
"@tanstack/query": queryPlugin
|
|
851
|
+
},
|
|
852
|
+
rules: {
|
|
853
|
+
...queryRules,
|
|
854
|
+
...customRules ?? {}
|
|
855
|
+
}
|
|
856
|
+
});
|
|
857
|
+
|
|
830
858
|
// src/eslint/react-refresh/config.ts
|
|
831
859
|
import reactRefresh from "eslint-plugin-react-refresh";
|
|
832
860
|
|
|
@@ -863,7 +891,11 @@ import pluginReactHooks from "eslint-plugin-react-hooks";
|
|
|
863
891
|
import globals from "globals";
|
|
864
892
|
|
|
865
893
|
// src/eslint/react/rules.ts
|
|
866
|
-
var reactRules = (
|
|
894
|
+
var reactRules = ({
|
|
895
|
+
functionStyle,
|
|
896
|
+
reactCompiler,
|
|
897
|
+
typescript
|
|
898
|
+
}) => {
|
|
867
899
|
const functionStyleMap = {
|
|
868
900
|
arrow: "arrow-function",
|
|
869
901
|
declaration: "function-declaration",
|
|
@@ -874,9 +906,39 @@ var reactRules = (functionStyle, typescript) => {
|
|
|
874
906
|
* Disabled in favor of TypeScript for type checking
|
|
875
907
|
*/
|
|
876
908
|
...typescript ? {} : { "react/prop-types": "warn" },
|
|
909
|
+
/**
|
|
910
|
+
* Core React Hooks rules
|
|
911
|
+
*/
|
|
877
912
|
"react-hooks/exhaustive-deps": "warn",
|
|
878
|
-
"react-hooks/react-compiler": "warn",
|
|
879
913
|
"react-hooks/rules-of-hooks": "warn",
|
|
914
|
+
/**
|
|
915
|
+
* React compiler rules
|
|
916
|
+
*/
|
|
917
|
+
...reactCompiler ? {
|
|
918
|
+
/**
|
|
919
|
+
* Does not seem to be working, and overlaps with static-components
|
|
920
|
+
*/
|
|
921
|
+
// "react-hooks/component-hook-factories": "warn",
|
|
922
|
+
/**
|
|
923
|
+
* seems unecessary unless you're rolling your own React setup, users can always enable
|
|
924
|
+
*/
|
|
925
|
+
// "react-hooks/config": "warn",
|
|
926
|
+
"react-hooks/error-boundaries": "warn",
|
|
927
|
+
"react-hooks/globals": "warn",
|
|
928
|
+
"react-hooks/immutability": "warn",
|
|
929
|
+
"react-hooks/incompatible-library": "warn",
|
|
930
|
+
"react-hooks/preserve-manual-memoization": "warn",
|
|
931
|
+
"react-hooks/purity": "warn",
|
|
932
|
+
"react-hooks/refs": "warn",
|
|
933
|
+
"react-hooks/set-state-in-effect": "warn",
|
|
934
|
+
"react-hooks/set-state-in-render": "warn",
|
|
935
|
+
/**
|
|
936
|
+
* overlaps with react/no-unstable-nested-components
|
|
937
|
+
*/
|
|
938
|
+
// "react-hooks/static-components": "warn",
|
|
939
|
+
"react-hooks/unsupported-syntax": "warn",
|
|
940
|
+
"react-hooks/use-memo": "warn"
|
|
941
|
+
} : {},
|
|
880
942
|
/**
|
|
881
943
|
* Require an explicit type when using button elements.
|
|
882
944
|
*
|
|
@@ -897,12 +959,6 @@ var reactRules = (functionStyle, typescript) => {
|
|
|
897
959
|
unnamedComponents: functionStyle === "arrow" ? "arrow-function" : "function-expression"
|
|
898
960
|
}
|
|
899
961
|
],
|
|
900
|
-
/**
|
|
901
|
-
* Require destructuring and symmetric naming of `useState` hook value and setter variables.
|
|
902
|
-
*
|
|
903
|
-
* 🚫 Not fixable - https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/hook-use-state.md
|
|
904
|
-
*/
|
|
905
|
-
"react/hook-use-state": "warn",
|
|
906
962
|
/**
|
|
907
963
|
* Require consistent boolean attributes notation in JSX.
|
|
908
964
|
*
|
|
@@ -993,7 +1049,12 @@ var reactRules = (functionStyle, typescript) => {
|
|
|
993
1049
|
};
|
|
994
1050
|
|
|
995
1051
|
// src/eslint/react/config.ts
|
|
996
|
-
var reactEslintConfig = (
|
|
1052
|
+
var reactEslintConfig = ({
|
|
1053
|
+
customRules,
|
|
1054
|
+
functionStyle,
|
|
1055
|
+
reactCompiler,
|
|
1056
|
+
typescript
|
|
1057
|
+
}) => {
|
|
997
1058
|
return {
|
|
998
1059
|
languageOptions: {
|
|
999
1060
|
globals: {
|
|
@@ -1011,7 +1072,7 @@ var reactEslintConfig = (functionStyle, typescript, customRules) => {
|
|
|
1011
1072
|
"react-hooks": pluginReactHooks
|
|
1012
1073
|
},
|
|
1013
1074
|
rules: {
|
|
1014
|
-
...reactRules(functionStyle, typescript),
|
|
1075
|
+
...reactRules({ functionStyle, reactCompiler, typescript }),
|
|
1015
1076
|
...customRules ?? {}
|
|
1016
1077
|
},
|
|
1017
1078
|
settings: {
|
|
@@ -1036,7 +1097,7 @@ var storybookConfig = (customRules) => [
|
|
|
1036
1097
|
},
|
|
1037
1098
|
rules: {
|
|
1038
1099
|
// Default Storybook rules
|
|
1039
|
-
"import/no-anonymous-default-export": "off",
|
|
1100
|
+
"import-x/no-anonymous-default-export": "off",
|
|
1040
1101
|
"react-hooks/rules-of-hooks": "off",
|
|
1041
1102
|
"storybook/await-interactions": "warn",
|
|
1042
1103
|
"storybook/context-in-play-function": "warn",
|
|
@@ -1496,6 +1557,7 @@ var eslintConfig = ({
|
|
|
1496
1557
|
ignores = [],
|
|
1497
1558
|
importPlugin = true,
|
|
1498
1559
|
jsdoc: jsdoc2 = { requireJsdoc: false },
|
|
1560
|
+
query = false,
|
|
1499
1561
|
react: react2 = false,
|
|
1500
1562
|
rules: rules2,
|
|
1501
1563
|
sorting = true,
|
|
@@ -1541,10 +1603,11 @@ var eslintConfig = ({
|
|
|
1541
1603
|
);
|
|
1542
1604
|
}
|
|
1543
1605
|
if (react2) {
|
|
1606
|
+
const reactOptions = isObject(react2) ? react2 : {};
|
|
1544
1607
|
const shouldUseReactRefresh = (
|
|
1545
1608
|
// Explicit setting takes precedence
|
|
1546
|
-
|
|
1547
|
-
|
|
1609
|
+
reactOptions.reactRefresh === true || // Framework-based default (vite/none use reactRefresh by default)
|
|
1610
|
+
(reactOptions.framework === "vite" || reactOptions.framework === "none") && reactOptions.reactRefresh !== false
|
|
1548
1611
|
);
|
|
1549
1612
|
if (shouldUseReactRefresh) {
|
|
1550
1613
|
configs.push(
|
|
@@ -1552,16 +1615,20 @@ var eslintConfig = ({
|
|
|
1552
1615
|
);
|
|
1553
1616
|
}
|
|
1554
1617
|
configs.push(
|
|
1555
|
-
reactEslintConfig(
|
|
1618
|
+
reactEslintConfig({
|
|
1619
|
+
customRules: categorizedRules[configNames.react],
|
|
1556
1620
|
functionStyle,
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
)
|
|
1621
|
+
reactCompiler: reactOptions.reactCompiler ?? true,
|
|
1622
|
+
typescript: Boolean(typescript)
|
|
1623
|
+
})
|
|
1560
1624
|
);
|
|
1561
1625
|
if (usingNextjs) {
|
|
1562
1626
|
configs.push(nextjsConfig(categorizedRules[configNames.nextjs]));
|
|
1563
1627
|
}
|
|
1564
1628
|
}
|
|
1629
|
+
if (query) {
|
|
1630
|
+
configs.push(queryConfig(categorizedRules[configNames.query]));
|
|
1631
|
+
}
|
|
1565
1632
|
if (testing !== false) {
|
|
1566
1633
|
const mergedTestingConfig = isObject(testing) ? { ...defaultTestingConfig, ...testing } : defaultTestingConfig;
|
|
1567
1634
|
const { filenamePattern, files, formattingRules, framework, itOrTest } = mergedTestingConfig;
|