Skip to content

Commit

Permalink
fix: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
鲲尘 authored and ClarkXia committed Nov 14, 2022
1 parent 962ac36 commit bc43ca3
Show file tree
Hide file tree
Showing 24 changed files with 275 additions and 344 deletions.
4 changes: 2 additions & 2 deletions .commitlintrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
const { getCommitlintConfig } = require('@iceworks/spec');
const { getCommitlintConfig } = require('@applint/spec');

module.exports = getCommitlintConfig('common');
module.exports = getCommitlintConfig('common');
28 changes: 6 additions & 22 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { getESLintConfig } = require('@iceworks/spec');
const { getESLintConfig } = require('@applint/spec');

const commonRules = {
'react/jsx-filename-extension': 0,
Expand All @@ -15,13 +15,10 @@ const commonRules = {
'jsx-a11y/html-has-lang': 0,
'react/static-property-placement': 0,
'no-multiple-empty-lines': 1,
'react/jsx-no-bind': 0
'react/jsx-no-bind': 0,
};

const jsRules = getESLintConfig('react', {
rules: commonRules
});
const tsRules = getESLintConfig('react-ts', {
module.exports = getESLintConfig('react-ts', {
rules: {
...commonRules,
'@typescript-eslint/ban-types': 0,
Expand All @@ -31,24 +28,11 @@ const tsRules = getESLintConfig('react-ts', {
'@typescript-eslint/explicit-function-return-type': 0,
'@typescript-eslint/no-var-requires': 0,
'@typescript-eslint/explicit-module-boundary-types': 0,
'@typescript-eslint/prefer-for-of': 0,
'id-length': 0,
'no-use-before-define': 0,
'no-unused-vars': 0,
'@typescript-eslint/no-unused-vars': 1,
'@typescript-eslint/ban-ts-ignore': 0,
}
});

delete tsRules.root;

module.exports = {
...jsRules,
overrides: [
{
...tsRules,
files: ['**/*.ts', '**/*.tsx'],
},
],
env: {
jest: true,
},
};
});
11 changes: 9 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,23 @@ jobs:
- name: Echo branch name
run: echo ${BRANCH_NAME}
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
registry-url: https://registry.npmjs.org/
- name: Cache .pnpm-store
id: cache
uses: actions/cache@v1
with:
path: ~/.pnpm-store
key: ${{ runner.os }}-node${{ matrix.node-version }}-${{ hashFiles('**/pnpm-lock.yaml') }}
- name: Install pnpm
run: npm i pnpm -g
- run: npm run setup
- run: npm run dependency:check
- run: npm run lint
- run: npm run test
- run: npm run version:check
- run: npm run coverage
env:
ACCESS_KEY_ID: ${{ secrets.ACCESS_KEY_ID }}
ACCESS_KEY_SECRET: ${{ secrets.ACCESS_KEY_SECRET }}
Expand Down
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npm run lint
npm run lint:diff
8 changes: 0 additions & 8 deletions .prettierrc

This file was deleted.

2 changes: 2 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
const { getPrettierConfig } = require('@applint/spec');
module.exports = getPrettierConfig('common');
4 changes: 2 additions & 2 deletions examples/basic-vite/mock/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
status,
data: {
group: 'ice.js',
url: 'https://github.com/ice-lab/ice.js'
}
url: 'https://github.com/ice-lab/ice.js',
},
},
};
3 changes: 2 additions & 1 deletion examples/basic-vite/src/app.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { runApp, IAppConfig } from 'ice';
import type { IAppConfig } from 'ice';
import { runApp } from 'ice';

const appConfig: IAppConfig = {
app: {
Expand Down
1 change: 1 addition & 0 deletions examples/basic-vite/src/pages/Home/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ function App() {
const [count, setCount] = useState<number>(0);
const [titleState] = store.useModel('title');


return (
<div className="App">
<Head>
Expand Down
4 changes: 2 additions & 2 deletions examples/basic-vite/src/pages/Home/models/title.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
export default {
state: {
title: '🚀 Vite + Icejs'
title: '🚀 Vite + Icejs',
},
reducers: {
update(prevState, payload) {
return { title: payload };
},
}
},
};
17 changes: 9 additions & 8 deletions examples/basic-vite/src/routes.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import { IRouterConfig, lazy } from 'ice';
import type { IRouterConfig } from 'ice';
import { lazy } from 'ice';
import DashboardLayout from '@/pages/Dashboard';
import Dashboard1 from '@/pages/Dashboard/Page1';
import Dashboard2 from '@/pages/Dashboard/Page2';
import Layout from '@/Layout';

const Home = lazy(() => import('@/pages/Home'));
const Home = lazy(async () => import('@/pages/Home'));

const routes: IRouterConfig[] = [
{
path: '/',
component: Home,
exact: true
exact: true,
},
{
path: '/',
Expand All @@ -23,16 +24,16 @@ const routes: IRouterConfig[] = [
{
path: '/a',
component: Dashboard1,
exact: true
exact: true,
},
{
path: '/b',
component: Dashboard2,
exact: true
}
]
exact: true,
},
],
},
]
],
},

];
Expand Down
6 changes: 3 additions & 3 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ module.exports = {
collectCoverage: true,
collectCoverageFrom: ['packages/*/lib/*.{js,jsx}'],
coveragePathIgnorePatterns: [
'<rootDir>/node_modules/'
'<rootDir>/node_modules/',
],
// copy from jest config

testEnvironment: 'node',
transform: {
'^.+\\.jsx?$': 'babel-jest',
'^.+\\.tsx?$': 'ts-jest'
'^.+\\.tsx?$': 'ts-jest',
},
roots: [
'<rootDir>/packages',
Expand All @@ -26,7 +26,7 @@ module.exports = {
testPathIgnorePatterns: [
'/node_modules/',
'/lib/',
'create-cli-utils/'
'create-cli-utils/',
],
testMatch: ['**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[jt]s?(x)'],
// For ts-jest use rootDir's tsconfig.json, while unable to resolve references.
Expand Down
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
"watch": "esmo ./scripts/watch.ts",
"build": "esmo ./scripts/build.ts",
"clean": "rimraf packages/*/lib",
"dependency:check": "esmo ./scripts/dependencyCheck.ts",
"version:check": "esmo ./scripts/versionCheck.ts",
"lint:diff": "esmo ./scripts/lintDiff.ts",
"lint": "eslint --cache --ext .js,.jsx,.ts,.tsx ./",
"lint:fix": "npm run lint -- --fix",
"test": "jest --forceExit --ci",
Expand All @@ -17,15 +20,17 @@
"author": "[email protected]",
"license": "MIT",
"devDependencies": {
"@applint/spec": "^1.0.1",
"@commitlint/cli": "^16.1.0",
"@iceworks/spec": "^1.5.0",
"@types/cross-spawn": "^6.0.2",
"@types/eslint": "^8.4.1",
"@types/fs-extra": "^9.0.13",
"@types/glob": "^7.2.0",
"@types/jest": "^27.4.0",
"@types/node": "^17.0.12",
"@types/pify": "^5.0.1",
"@types/semver": "^7.3.9",
"chalk": "^5.0.0",
"chokidar": "^3.5.3",
"dependency-check": "^4.1.0",
"eslint": "^8.7.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/icejs/src/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export default () => 'ice';
export default () => 'ice';
Loading

0 comments on commit bc43ca3

Please sign in to comment.