@mrshmllw/campfire 2.1.1 → 2.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/dist/configs/eslint-rules/no-color-prop/no-color-prop.d.ts +2 -0
- package/dist/configs/eslint-rules/no-color-prop/no-color-prop.js +75 -0
- package/dist/configs/eslint-rules/no-theme-colors/no-theme-colors.d.ts +2 -0
- package/dist/configs/eslint-rules/no-theme-colors/no-theme-colors.js +27 -0
- package/dist/configs/eslint.config.d.ts +8 -0
- package/dist/configs/eslint.config.js +12 -0
- package/package.json +9 -8
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { ESLintUtils } from '@typescript-eslint/utils';
|
|
2
|
+
const COLOR_KEYS = [
|
|
3
|
+
'lollipop',
|
|
4
|
+
'marshmallowPink',
|
|
5
|
+
'bubblegum',
|
|
6
|
+
'fairyFloss',
|
|
7
|
+
'boba',
|
|
8
|
+
'liquorice',
|
|
9
|
+
'sesame',
|
|
10
|
+
'chia',
|
|
11
|
+
'custard',
|
|
12
|
+
'mascarpone',
|
|
13
|
+
'coconut',
|
|
14
|
+
'cream',
|
|
15
|
+
'spearmint',
|
|
16
|
+
'feijoa',
|
|
17
|
+
'blueberry',
|
|
18
|
+
'macaroon',
|
|
19
|
+
'pistachio',
|
|
20
|
+
'matcha',
|
|
21
|
+
'caramel',
|
|
22
|
+
'peanut',
|
|
23
|
+
'marzipan',
|
|
24
|
+
'oatmeal',
|
|
25
|
+
'satsuma',
|
|
26
|
+
'strawberry',
|
|
27
|
+
'watermelon',
|
|
28
|
+
'apple',
|
|
29
|
+
'mint',
|
|
30
|
+
'lemon',
|
|
31
|
+
'sherbert',
|
|
32
|
+
'tangerine',
|
|
33
|
+
'compareTheMarket',
|
|
34
|
+
'confused',
|
|
35
|
+
'onfido',
|
|
36
|
+
'x',
|
|
37
|
+
'premfina',
|
|
38
|
+
'checkout',
|
|
39
|
+
'meta',
|
|
40
|
+
'stripe',
|
|
41
|
+
'intercom',
|
|
42
|
+
'ravelin',
|
|
43
|
+
'rac',
|
|
44
|
+
'hometree',
|
|
45
|
+
];
|
|
46
|
+
export const noColorPropRule = ESLintUtils.RuleCreator((name) => `${name}`)({
|
|
47
|
+
name: 'no-color-prop',
|
|
48
|
+
meta: {
|
|
49
|
+
type: 'problem',
|
|
50
|
+
docs: {
|
|
51
|
+
description: 'Disallow Color props (any prop) on design system components',
|
|
52
|
+
},
|
|
53
|
+
messages: {
|
|
54
|
+
noColorProp: 'Passing a design-system `Color` ("{{val}}") as a prop is deprecated. Use styled-components theme tokens instead.',
|
|
55
|
+
},
|
|
56
|
+
schema: [],
|
|
57
|
+
},
|
|
58
|
+
defaultOptions: [],
|
|
59
|
+
create(context) {
|
|
60
|
+
return {
|
|
61
|
+
JSXAttribute(node) {
|
|
62
|
+
if (node.value?.type === 'Literal') {
|
|
63
|
+
const val = String(node.value.value);
|
|
64
|
+
if (COLOR_KEYS.includes(val)) {
|
|
65
|
+
context.report({
|
|
66
|
+
node,
|
|
67
|
+
messageId: 'noColorProp',
|
|
68
|
+
data: { val },
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
},
|
|
75
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ESLintUtils } from '@typescript-eslint/utils';
|
|
2
|
+
export const noThemeColorsRule = ESLintUtils.RuleCreator((name) => `${name}`)({
|
|
3
|
+
name: 'no-theme-colors',
|
|
4
|
+
meta: {
|
|
5
|
+
type: 'problem',
|
|
6
|
+
docs: {
|
|
7
|
+
description: 'Disallow usage of theme.colors',
|
|
8
|
+
},
|
|
9
|
+
messages: {
|
|
10
|
+
noThemeColors: 'Usage of `theme.colors` is deprecated. Use the new styled-components theme instead.',
|
|
11
|
+
},
|
|
12
|
+
schema: [],
|
|
13
|
+
},
|
|
14
|
+
defaultOptions: [],
|
|
15
|
+
create(context) {
|
|
16
|
+
return {
|
|
17
|
+
MemberExpression(node) {
|
|
18
|
+
if (node.object.type === 'Identifier' &&
|
|
19
|
+
node.object.name === 'theme' &&
|
|
20
|
+
node.property.type === 'Identifier' &&
|
|
21
|
+
node.property.name === 'colors') {
|
|
22
|
+
context.report({ node, messageId: 'noThemeColors' });
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
},
|
|
27
|
+
});
|
|
@@ -10,6 +10,12 @@ declare const config: (import("eslint").Linter.Config<import("eslint").Linter.Ru
|
|
|
10
10
|
meta: import("@typescript-eslint/utils/ts-eslint").FlatConfig.PluginMeta;
|
|
11
11
|
rules: typeof import("@typescript-eslint/eslint-plugin/use-at-your-own-risk/rules");
|
|
12
12
|
};
|
|
13
|
+
campfire: {
|
|
14
|
+
rules: {
|
|
15
|
+
'no-color-prop': import("@typescript-eslint/utils/ts-eslint").RuleModule<"noColorProp", [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
16
|
+
'no-theme-colors': import("@typescript-eslint/utils/ts-eslint").RuleModule<"noThemeColors", [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
13
19
|
};
|
|
14
20
|
rules: {
|
|
15
21
|
'@typescript-eslint/no-explicit-any': string;
|
|
@@ -19,6 +25,8 @@ declare const config: (import("eslint").Linter.Config<import("eslint").Linter.Ru
|
|
|
19
25
|
})[];
|
|
20
26
|
'no-console': string;
|
|
21
27
|
strict: string[];
|
|
28
|
+
'campfire/no-color-prop': string;
|
|
29
|
+
'campfire/no-theme-colors': string;
|
|
22
30
|
};
|
|
23
31
|
})[];
|
|
24
32
|
import tsParser from '@typescript-eslint/parser';
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import typescriptEslintPlugin from '@typescript-eslint/eslint-plugin';
|
|
2
2
|
import tsParser from '@typescript-eslint/parser';
|
|
3
3
|
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
|
|
4
|
+
import { noColorPropRule } from './eslint-rules/no-color-prop/no-color-prop.js';
|
|
5
|
+
import { noThemeColorsRule } from './eslint-rules/no-theme-colors/no-theme-colors.js';
|
|
6
|
+
const campfireEslintPlugin = {
|
|
7
|
+
rules: {
|
|
8
|
+
'no-color-prop': noColorPropRule,
|
|
9
|
+
'no-theme-colors': noThemeColorsRule,
|
|
10
|
+
},
|
|
11
|
+
};
|
|
4
12
|
const config = [
|
|
5
13
|
eslintPluginPrettierRecommended,
|
|
6
14
|
{
|
|
@@ -13,6 +21,7 @@ const config = [
|
|
|
13
21
|
},
|
|
14
22
|
plugins: {
|
|
15
23
|
'@typescript-eslint': typescriptEslintPlugin,
|
|
24
|
+
campfire: campfireEslintPlugin,
|
|
16
25
|
},
|
|
17
26
|
rules: {
|
|
18
27
|
'@typescript-eslint/no-explicit-any': 'warn', // Warns on use of 'any'
|
|
@@ -23,6 +32,9 @@ const config = [
|
|
|
23
32
|
],
|
|
24
33
|
'no-console': 'warn', // Warns on console.log and similar calls
|
|
25
34
|
strict: ['error', 'never'],
|
|
35
|
+
// Custom campfire rules
|
|
36
|
+
'campfire/no-color-prop': 'warn',
|
|
37
|
+
'campfire/no-theme-colors': 'warn',
|
|
26
38
|
},
|
|
27
39
|
},
|
|
28
40
|
];
|
package/package.json
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mrshmllw/campfire",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"description": "Collection of toasty utils and configs used by Marshmallow Technology",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"scripts": {
|
|
9
9
|
"clean": "rimraf ./dist",
|
|
10
|
-
"test": "
|
|
11
|
-
"test:watch": "node --test --watch",
|
|
10
|
+
"test": "vitest run",
|
|
12
11
|
"check-types": "tsc --noEmit",
|
|
13
12
|
"build": "npm run clean && tsc --p tsconfig.build.json",
|
|
14
13
|
"prepublishOnly": "npm run build",
|
|
@@ -36,14 +35,14 @@
|
|
|
36
35
|
],
|
|
37
36
|
"dependencies": {
|
|
38
37
|
"@commitlint/types": "^19.0.0",
|
|
39
|
-
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
|
40
|
-
"@typescript-eslint/parser": "^8.0.0",
|
|
41
|
-
"eslint-plugin-prettier": "^5.0.0",
|
|
42
38
|
"@semantic-release/changelog": "^6.0.0",
|
|
43
39
|
"@semantic-release/git": "^10.0.0",
|
|
44
40
|
"@semantic-release/github": "^11.0.0",
|
|
45
41
|
"@semantic-release/npm": "^12.0.0",
|
|
46
|
-
"
|
|
42
|
+
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
|
43
|
+
"@typescript-eslint/parser": "^8.0.0",
|
|
44
|
+
"conventional-changelog-conventionalcommits": "^9.0.0",
|
|
45
|
+
"eslint-plugin-prettier": "^5.0.0"
|
|
47
46
|
},
|
|
48
47
|
"peerDependencies": {
|
|
49
48
|
"@commitlint/cli": "^19.0.0",
|
|
@@ -82,6 +81,7 @@
|
|
|
82
81
|
"@semantic-release/npm": "^12.0.1",
|
|
83
82
|
"@typescript-eslint/eslint-plugin": "^8.34.0",
|
|
84
83
|
"@typescript-eslint/parser": "^8.33.0",
|
|
84
|
+
"@typescript-eslint/rule-tester": "^8.45.0",
|
|
85
85
|
"conventional-changelog-conventionalcommits": "^9.0.0",
|
|
86
86
|
"eslint": "^9.28.0",
|
|
87
87
|
"eslint-config-prettier": "^10.1.5",
|
|
@@ -91,7 +91,8 @@
|
|
|
91
91
|
"prettier": "^3.5.3",
|
|
92
92
|
"rimraf": "^6.0.1",
|
|
93
93
|
"semantic-release": "^24.2.5",
|
|
94
|
-
"typescript": "^5.8.3"
|
|
94
|
+
"typescript": "^5.8.3",
|
|
95
|
+
"vitest": "^3.2.4"
|
|
95
96
|
},
|
|
96
97
|
"repository": {
|
|
97
98
|
"type": "git",
|