Skip to content

Commit

Permalink
Beta 3.0.0 lint (#235)
Browse files Browse the repository at this point in the history
* chore: add ko-lint-config

* feat: remove eslint disable

* chore: prettier fix

* chore: eslint fix

* chore: stylelint fix

* ci: lint ci

Co-authored-by: liuyi <liuyi@dtstack.com>
  • Loading branch information
liuxy0551 and liuyi committed Oct 20, 2022
1 parent b0a7ac6 commit 632a8df
Show file tree
Hide file tree
Showing 172 changed files with 5,783 additions and 5,053 deletions.
38 changes: 19 additions & 19 deletions .babelrc.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
const config = {
presets: [
[
'@babel/preset-env',
{
modules: false,
},
presets: [
[
'@babel/preset-env',
{
modules: false,
},
],
'@babel/preset-react',
'@babel/preset-typescript',
],
'@babel/preset-react',
'@babel/preset-typescript',
],
plugins: [
[
'@babel/plugin-proposal-decorators',
{
legacy: true,
},
plugins: [
[
'@babel/plugin-proposal-decorators',
{
legacy: true,
},
],
'@babel/plugin-proposal-class-properties',
'@babel/plugin-proposal-object-rest-spread',
'@babel/plugin-transform-modules-commonjs',
],
'@babel/plugin-proposal-class-properties',
'@babel/plugin-proposal-object-rest-spread',
'@babel/plugin-transform-modules-commonjs',
],
};

if (process.env.NODE_ENV === 'prod') config.plugins.unshift('./css-plugin');
Expand Down
4 changes: 2 additions & 2 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ debug.log
yarn-error.log
package-lock.json
dist/
gulpfile.js
index.tsx
esm/
lib/
3 changes: 3 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
extends: [require.resolve('ko-lint-config/.eslintrc')],
};
78 changes: 0 additions & 78 deletions .eslintrc.json

This file was deleted.

54 changes: 48 additions & 6 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
if: steps.node_modules_cache_id.outputs.cache-hit != 'true'
run: yarn

check-types:
eslint:
needs: [setup]
runs-on: ubuntu-latest
steps:
Expand All @@ -67,10 +67,10 @@ jobs:
path: node_modules
key: node_modules-${{ hashFiles('**/package.json') }}-${{ hashFiles('**/package-temp-dir/yarn.lock') }}

- name: Run Check Types
run: yarn check-types
- name: Run ESlint
run: yarn eslint

eslint:
stylelint:
needs: [setup]
runs-on: ubuntu-latest
steps:
Expand All @@ -88,8 +88,50 @@ jobs:
path: node_modules
key: node_modules-${{ hashFiles('**/package.json') }}-${{ hashFiles('**/package-temp-dir/yarn.lock') }}

- name: Run ESlint
run: yarn lint
- name: Run Stylelint
run: yarn stylelint

lint-doc:
needs: [setup]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Restore cache from yarn.lock
uses: actions/cache@v2
with:
path: package-temp-dir
key: lock-${{ github.sha }}

- name: Restore cache from node_modules
uses: actions/cache@v2
with:
path: node_modules
key: node_modules-${{ hashFiles('**/package.json') }}-${{ hashFiles('**/package-temp-dir/yarn.lock') }}

- name: Run Doc Lint
run: yarn lint-doc

check-types:
needs: [setup]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Restore cache from yarn.lock
uses: actions/cache@v2
with:
path: package-temp-dir
key: lock-${{ github.sha }}

- name: Restore cache from node_modules
uses: actions/cache@v2
with:
path: node_modules
key: node_modules-${{ hashFiles('**/package.json') }}-${{ hashFiles('**/package-temp-dir/yarn.lock') }}

- name: Run Check Types
run: yarn check-types

test:
runs-on: ubuntu-latest
Expand Down
16 changes: 16 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
*.md
storybook-static/
node_modules/
.cache-loader/
.history
npm-error.log
npm-debug.log
debug.log
yarn-error.log
package-lock.json
dist/
esm/
lib/

# 特殊的
src/components/mxGraph/factory.tsx
5 changes: 5 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const prettier = require('ko-lint-config/.prettierrc');

module.exports = {
...prettier,
};
2 changes: 1 addition & 1 deletion .storybook/addons.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ import '@storybook/addon-storysource/register';
import '@storybook/addon-notes/register';
import '@storybook/addon-options/register';
import '@storybook/addon-knobs/register';
import '@storybook/addon-actions/register';
import '@storybook/addon-actions/register';
36 changes: 19 additions & 17 deletions .storybook/config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { configure, addDecorator, addParameters, setAddon } from '@storybook/react';
// 避免jest识别webpack context 报错
import { configure, addDecorator, addParameters, setAddon } from '@storybook/react';
// 避免jest识别webpack context 报错
import requireContext from 'require-context.macro';
import { withNotes } from '@storybook/addon-notes';
import { withKnobs } from '@storybook/addon-knobs';
Expand All @@ -11,7 +11,7 @@ setAddon(chaptersAddon);
addDecorator(withNotes);
addDecorator(withKnobs);
// addReadme与withInfo不能共存
addDecorator(withInfo);
addDecorator(withInfo);
/**
* 全局设置 info 样式
* info-addons源样式
Expand All @@ -22,35 +22,37 @@ addParameters({
info: {
inline: true,
source: false,
styles: stylesheet => ({
styles: (stylesheet) => ({
// Setting the style with a function
...stylesheet,
infoBody: {
...stylesheet.infoBody,
padding: '20px 40px 20px'
padding: '20px 40px 20px',
},
header: {
...stylesheet.header,
h1: {
...stylesheet.header.h1,
},
...stylesheet.header,
h1: {
...stylesheet.header.h1,
},
},
}),
}
},
});

addDecorator(withOptions({
name: `组件库 v${version}`,
url: repository,
sidebarAnimations: true,
}))
addDecorator(
withOptions({
name: `组件库 v${version}`,
url: repository,
sidebarAnimations: true,
})
);
/**
* 动态加载所有stories
*/
function loadStories() {
const req = requireContext('../src/stories', true, /\.stories\.(ts|tsx)$/);
const allExport = [require('../src/stories/index.stories')]; // 第一排序
req.keys().forEach(fileName => allExport.push(req(fileName)));
req.keys().forEach((fileName) => allExport.push(req(fileName)));
return allExport;
}
configure(loadStories, module);
configure(loadStories, module);
Loading

0 comments on commit 632a8df

Please sign in to comment.