Browse Source

chore: add cssinjs linter (#40001)

pull/40005/head
MadCcc 2 years ago
committed by GitHub
parent
commit
7b06b662d1
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      .dumi/theme/layouts/GlobalLayout.tsx
  2. 2
      package.json
  3. 8
      tests/shared/demoTest.tsx

4
.dumi/theme/layouts/GlobalLayout.tsx

@ -1,7 +1,7 @@
import React, { startTransition, useCallback, useEffect, useMemo } from 'react';
import { createSearchParams, useOutlet, useSearchParams } from 'dumi';
import { ConfigProvider, theme as antdTheme } from 'antd';
import { createCache, StyleProvider } from '@ant-design/cssinjs';
import { createCache, StyleProvider, logicalPropertiesLinter } from '@ant-design/cssinjs';
import type { DirectionType } from 'antd/es/config-provider';
import ThemeSwitch from '../common/ThemeSwitch';
import type { ThemeName } from '../common/ThemeSwitch';
@ -102,7 +102,7 @@ const GlobalLayout: React.FC = () => {
);
return (
<StyleProvider cache={styleCache}>
<StyleProvider cache={styleCache} linters={[logicalPropertiesLinter]}>
<SiteContext.Provider value={siteContextValue}>
<ConfigProvider
theme={{

2
package.json

@ -108,7 +108,7 @@
],
"dependencies": {
"@ant-design/colors": "^6.0.0",
"@ant-design/cssinjs": "^1.3.0",
"@ant-design/cssinjs": "^1.4.0",
"@ant-design/icons": "^4.7.0",
"@ant-design/react-slick": "~1.0.0",
"@babel/runtime": "^7.18.3",

8
tests/shared/demoTest.tsx

@ -2,7 +2,7 @@
import * as React from 'react';
import { renderToString } from 'react-dom/server';
import glob from 'glob';
import { StyleProvider, createCache } from '@ant-design/cssinjs';
import { StyleProvider, createCache, logicalPropertiesLinter } from '@ant-design/cssinjs';
import { excludeWarning } from './excludeWarning';
import { render } from '../utils';
import { TriggerMockContext } from './demoTestContext';
@ -72,7 +72,11 @@ function baseText(doInject: boolean, component: string, options: Options = {}) {
Demo = typeof Demo === 'function' ? <Demo /> : Demo;
// Inject cssinjs cache to avoid create <style /> element
Demo = <StyleProvider cache={createCache()}>{Demo}</StyleProvider>;
Demo = (
<StyleProvider cache={createCache()} linters={[logicalPropertiesLinter]}>
{Demo}
</StyleProvider>
);
render(Demo);

Loading…
Cancel
Save