Skip to content

Commit 82460f5

Browse files
authored
Merge pull request #33 from component-driven/components
Add components package
2 parents a8de73e + a068558 commit 82460f5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+2875
-496
lines changed

.changeset/gold-countries-admire.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@component-driven/mixins": major
3+
---
4+
5+
Convert to TypeScript

.changeset/stale-ligers-listen.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@component-driven/components": major
3+
---
4+
5+
Add components package

.eslintignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
node_modules/
22
build/
3+
packages/components
4+
packages/**/dist

.eslintrc

Lines changed: 267 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,277 @@
11
{
2+
"root": true,
23
"parser": "babel-eslint",
4+
"plugins": ["react", "react-hooks", "jest", "import"],
5+
"env": {
6+
"browser": true,
7+
"commonjs": true,
8+
"es6": true,
9+
"node": true
10+
},
311
"parserOptions": {
412
"ecmaVersion": 2018,
513
"sourceType": "module",
614
"ecmaFeatures": {
715
"jsx": true
816
}
917
},
10-
"env": { "es6": true, "node": true, "browser": true },
11-
"extends": ["eslint:recommended", "plugin:react/recommended"]
18+
"settings": {
19+
"react": {
20+
"version": "detect"
21+
}
22+
},
23+
"overrides": [
24+
{
25+
"files": ["test/**/*.test.js"],
26+
"extends": ["plugin:jest/recommended"],
27+
"rules": {
28+
"jest/expect-expect": "off",
29+
"jest/no-disabled-tests": "off"
30+
}
31+
},
32+
{ "files": ["**/__tests__/**"], "env": { "jest": true } },
33+
{
34+
"files": ["**/*.ts", "**/*.tsx"],
35+
"parser": "@typescript-eslint/parser",
36+
"parserOptions": {
37+
"ecmaVersion": 2018,
38+
"sourceType": "module",
39+
"ecmaFeatures": {
40+
"jsx": true
41+
},
42+
"warnOnUnsupportedTypeScriptVersion": false
43+
},
44+
"plugins": ["@typescript-eslint"],
45+
"rules": {
46+
// Already handled by TS
47+
"no-dupe-class-members": "off",
48+
"no-undef": "off",
49+
50+
// Add TypeScript specific rules (and turn off ESLint equivalents)
51+
"@typescript-eslint/consistent-type-assertions": "warn",
52+
"no-array-constructor": "off",
53+
"@typescript-eslint/no-array-constructor": "warn",
54+
"@typescript-eslint/no-namespace": "error",
55+
"no-use-before-define": "off",
56+
"@typescript-eslint/no-use-before-define": [
57+
"warn",
58+
{
59+
"functions": false,
60+
"classes": false,
61+
"variables": false,
62+
"typedefs": false
63+
}
64+
],
65+
"no-unused-vars": "off",
66+
"@typescript-eslint/no-unused-vars": [
67+
"warn",
68+
{
69+
"args": "none",
70+
"ignoreRestSiblings": true
71+
}
72+
],
73+
"no-unused-expressions": "off",
74+
"@typescript-eslint/no-unused-expressions": [
75+
"error",
76+
{
77+
"allowShortCircuit": true,
78+
"allowTernary": true,
79+
"allowTaggedTemplates": true
80+
}
81+
],
82+
"no-useless-constructor": "off",
83+
"@typescript-eslint/no-useless-constructor": "warn"
84+
}
85+
},
86+
{
87+
"files": [
88+
"test/**/*",
89+
"examples/**/*",
90+
"packages/create-next-app/templates/**/*"
91+
],
92+
"rules": { "react/react-in-jsx-scope": "off" }
93+
},
94+
{
95+
"files": ["examples/**/*"],
96+
"rules": {
97+
"import/no-anonymous-default-export": [
98+
"error",
99+
{
100+
// React components:
101+
"allowArrowFunction": false,
102+
"allowAnonymousClass": false,
103+
"allowAnonymousFunction": false,
104+
105+
// Non-React stuff:
106+
"allowArray": true,
107+
"allowCallExpression": true,
108+
"allowLiteral": true,
109+
"allowObject": true
110+
}
111+
]
112+
}
113+
},
114+
{
115+
"files": ["packages/**"],
116+
"rules": {
117+
"no-shadow": ["warn", { "builtinGlobals": false }],
118+
"import/no-extraneous-dependencies": [
119+
"error",
120+
{ "devDependencies": false }
121+
]
122+
}
123+
},
124+
{
125+
"files": ["packages/**/*.tsx", "packages/**/*.ts"],
126+
"rules": {
127+
"@typescript-eslint/no-unused-vars": [
128+
"warn",
129+
{
130+
"args": "all",
131+
"argsIgnorePattern": "^_",
132+
"ignoreRestSiblings": true
133+
}
134+
]
135+
}
136+
}
137+
],
138+
"rules": {
139+
"array-callback-return": "warn",
140+
"default-case": ["warn", { "commentPattern": "^no default$" }],
141+
"dot-location": ["warn", "property"],
142+
"eqeqeq": ["warn", "smart"],
143+
"new-parens": "warn",
144+
"no-array-constructor": "warn",
145+
"no-caller": "warn",
146+
"no-cond-assign": ["warn", "except-parens"],
147+
"no-const-assign": "warn",
148+
"no-control-regex": "warn",
149+
"no-delete-var": "warn",
150+
"no-dupe-args": "warn",
151+
"no-dupe-class-members": "warn",
152+
"no-dupe-keys": "warn",
153+
"no-duplicate-case": "warn",
154+
"no-empty-character-class": "warn",
155+
"no-empty-pattern": "warn",
156+
"no-eval": "warn",
157+
"no-ex-assign": "warn",
158+
"no-extend-native": "warn",
159+
"no-extra-bind": "warn",
160+
"no-extra-label": "warn",
161+
"no-fallthrough": "warn",
162+
"no-func-assign": "warn",
163+
"no-implied-eval": "warn",
164+
"no-invalid-regexp": "warn",
165+
"no-iterator": "warn",
166+
"no-label-var": "warn",
167+
"no-labels": ["warn", { "allowLoop": true, "allowSwitch": false }],
168+
"no-lone-blocks": "warn",
169+
"no-loop-func": "warn",
170+
"no-mixed-operators": [
171+
"warn",
172+
{
173+
"groups": [
174+
["&", "|", "^", "~", "<<", ">>", ">>>"],
175+
["==", "!=", "===", "!==", ">", ">=", "<", "<="],
176+
["&&", "||"],
177+
["in", "instanceof"]
178+
],
179+
"allowSamePrecedence": false
180+
}
181+
],
182+
"no-multi-str": "warn",
183+
"no-native-reassign": "warn",
184+
"no-negated-in-lhs": "warn",
185+
"no-new-func": "warn",
186+
"no-new-object": "warn",
187+
"no-new-symbol": "warn",
188+
"no-new-wrappers": "warn",
189+
"no-obj-calls": "warn",
190+
"no-octal": "warn",
191+
"no-octal-escape": "warn",
192+
"no-redeclare": ["warn", { "builtinGlobals": false }],
193+
"no-regex-spaces": "warn",
194+
"no-restricted-syntax": ["warn", "WithStatement"],
195+
"no-script-url": "warn",
196+
"no-self-assign": "warn",
197+
"no-self-compare": "warn",
198+
"no-sequences": "warn",
199+
"no-shadow-restricted-names": "warn",
200+
"no-sparse-arrays": "warn",
201+
"no-template-curly-in-string": "error",
202+
"no-this-before-super": "warn",
203+
"no-throw-literal": "warn",
204+
"no-undef": "error",
205+
"no-unexpected-multiline": "warn",
206+
"no-unreachable": "warn",
207+
"no-unused-expressions": [
208+
"error",
209+
{
210+
"allowShortCircuit": true,
211+
"allowTernary": true,
212+
"allowTaggedTemplates": true
213+
}
214+
],
215+
"no-unused-labels": "warn",
216+
"no-unused-vars": [
217+
"warn",
218+
{
219+
"args": "none",
220+
"ignoreRestSiblings": true
221+
}
222+
],
223+
"no-use-before-define": [
224+
"warn",
225+
{
226+
"functions": false,
227+
"classes": false,
228+
"variables": false
229+
}
230+
],
231+
"no-useless-computed-key": "warn",
232+
"no-useless-concat": "warn",
233+
"no-useless-constructor": "warn",
234+
"no-useless-escape": "warn",
235+
"no-useless-rename": [
236+
"warn",
237+
{
238+
"ignoreDestructuring": false,
239+
"ignoreImport": false,
240+
"ignoreExport": false
241+
}
242+
],
243+
"no-with": "warn",
244+
"no-whitespace-before-property": "warn",
245+
"react-hooks/exhaustive-deps": "warn",
246+
"require-yield": "warn",
247+
"rest-spread-spacing": ["warn", "never"],
248+
"strict": ["warn", "never"],
249+
"unicode-bom": ["warn", "never"],
250+
"use-isnan": "warn",
251+
"valid-typeof": "warn",
252+
"getter-return": "warn",
253+
"react/forbid-foreign-prop-types": ["warn", { "allowInPropTypes": true }],
254+
"react/jsx-no-comment-textnodes": "warn",
255+
"react/jsx-no-duplicate-props": "warn",
256+
"react/jsx-no-target-blank": "warn",
257+
"react/jsx-no-undef": "error",
258+
"react/jsx-pascal-case": [
259+
"warn",
260+
{
261+
"allowAllCaps": true,
262+
"ignore": []
263+
}
264+
],
265+
"react/jsx-uses-react": "warn",
266+
"react/jsx-uses-vars": "warn",
267+
"react/no-danger-with-children": "warn",
268+
"react/no-deprecated": "warn",
269+
"react/no-direct-mutation-state": "warn",
270+
"react/no-is-mounted": "warn",
271+
"react/no-typos": "error",
272+
"react/react-in-jsx-scope": "error",
273+
"react/require-render-return": "error",
274+
"react/style-prop-object": "warn",
275+
"react-hooks/rules-of-hooks": "error"
276+
}
12277
}

.prettierrc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
{
22
"printWidth": 100,
33
"trailingComma": "none",
4-
"singleQuote": true,
54
"semi": false,
6-
"jsxBracketSameLine": false,
7-
"bracketSpacing": true,
5+
"arrowParens": "always",
86
"overrides": [
97
{
108
"files": "*.md",

.styleguidist/StyleguideProvider.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import * as React from "react"
2+
import { ThemeProvider } from "styled-components"
3+
import theme from "../packages/components/src/theme"
4+
5+
const StyleguideProvider: React.FC = ({ children }) => {
6+
return <ThemeProvider theme={theme}>{children}</ThemeProvider>
7+
}
8+
9+
export default StyleguideProvider

.styleguidist/setup.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import * as components from "../packages/components/src"
2+
3+
// Expose all components to the global scope for styleguide examples
4+
// so it behaves more like Playroom without the need to import components
5+
Object.entries(components).forEach(([key, value]) => {
6+
global[key] = value
7+
})

babel.config.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
module.exports = {
22
presets: [
33
[
4-
'@babel/preset-env',
4+
"@babel/preset-env",
55
{
66
targets: {
7-
browsers: ['ie >= 11']
7+
browsers: ["ie >= 11"]
88
},
9-
exclude: ['transform-async-to-generator', 'transform-regenerator'],
9+
exclude: ["transform-async-to-generator", "transform-regenerator"],
1010
modules: false,
1111
loose: true
1212
}
1313
],
14-
'@babel/react'
14+
"@babel/react",
15+
"@babel/preset-typescript"
1516
],
16-
plugins: ['@babel/plugin-proposal-class-properties']
17+
plugins: ["@babel/plugin-proposal-class-properties"]
1718
}

0 commit comments

Comments
 (0)