Skip to content

Commit

Permalink
improve eslint and code
Browse files Browse the repository at this point in the history
  • Loading branch information
flodlc committed Sep 11, 2022
1 parent fe529ea commit e7033e2
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"@typescript-eslint/ban-ts-comment": "off",
"react/prop-types": "off",
"(@typescript-eslint/no-empty-interface": "off",
"no-unused-vars": "warn",
"@typescript-eslint/no-unused-vars": "warn",
"prefer-const": "error"
},
"settings": {
Expand Down
2 changes: 1 addition & 1 deletion packages/lib/src/SX.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { InputStyle } from './css';
import { Theme } from './theme';

// import { Theme } from './theme';
// type StyleObject = InputStyle | ((theme: Theme) => ThemeUICSSObject);

export type SX = InputStyle | (SX | undefined)[];
22 changes: 1 addition & 21 deletions packages/lib/src/css.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,7 @@
import * as CSS from 'csstype';
import get from 'lodash.get';

import { SCALES } from './rules';

const ALIASES = {
ml: 'marginLeft',
mr: 'marginRight',
mt: 'marginTop',
mb: 'marginBottom',
m: 'margin',
my: 'marginY',
mx: 'marginX',
pl: 'paddingLeft',
pr: 'paddingRight',
pt: 'paddingTop',
pb: 'paddingBottom',
p: 'padding',
py: 'paddingY',
px: 'paddingX',
} as const;
import { ALIASES, SCALES } from './rules';

type CSSProperties = CSS.Properties<number, string>;

Expand Down Expand Up @@ -62,7 +45,6 @@ type CSS =
export function css<
R extends Record<
string,
// eslint-disable-next-line no-unused-vars
{ transform: (value: never) => string | number | boolean | CSSProperties }
>
>({
Expand All @@ -76,7 +58,6 @@ export function css<
>;
SCALES: R;
breakpoints?: string[];
// eslint-disable-next-line no-unused-vars
}): (sx: InputStyle) => CSSProperties {
return (sx: InputStyle) => {
return computeProp(sx);
Expand All @@ -86,7 +67,6 @@ export function css<
const resolvedKey =
key in ALIASES ? ALIASES[key as keyof typeof ALIASES] : key;
const value = style[key as keyof InputStyle];
// console.log(sx, resolvedKey, key, value);
if (!value) return acc;

if (Array.isArray(value)) {
Expand Down
17 changes: 17 additions & 0 deletions packages/lib/src/rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,20 @@ export const SCALES = {
marginTop: { transform: marginTransform },
marginBottom: { transform: marginTransform },
};

export const ALIASES = {
ml: 'marginLeft',
mr: 'marginRight',
mt: 'marginTop',
mb: 'marginBottom',
m: 'margin',
my: 'marginY',
mx: 'marginX',
pl: 'paddingLeft',
pr: 'paddingRight',
pt: 'paddingTop',
pb: 'paddingBottom',
p: 'padding',
py: 'paddingY',
px: 'paddingX',
} as const;

0 comments on commit e7033e2

Please sign in to comment.