Skip to content

Commit

Permalink
build: eslint add rule of import order (#469)
Browse files Browse the repository at this point in the history
  • Loading branch information
danranVm authored Oct 9, 2021
1 parent d902ff5 commit 78738c2
Show file tree
Hide file tree
Showing 499 changed files with 3,474 additions and 754 deletions.
89 changes: 86 additions & 3 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
// eslint-disable-next-line @typescript-eslint/no-var-requires
const prettierConfig = require('./.prettierrc.js')

module.exports = {
root: true,
env: {
browser: true,
node: true,
},
plugins: ['jsdoc', 'import'],
extends: [
'plugin:vue/vue3-recommended',
'eslint:recommended',
Expand All @@ -19,6 +23,48 @@ module.exports = {
tsx: true,
},
},
overrides: [
{
files: ['*.ts', '*.tsx'],
parser: '@typescript-eslint/parser',
plugins: ['header'],
rules: {
'header/header': [
2,
'block',
[
'*',
' * @license',
' *',
' * Use of this source code is governed by an MIT-style license that can be',
' * found in the LICENSE file at https://github.com/IDuxFE/idux/blob/main/LICENSE',
' ',
],
2,
],
},
},
{
files: [
'scripts/**/*.ts',
'tests/**/*.ts',
'typings/**/*.ts',
'packages/site/**/*.ts',
'**/demo/*.ts',
'**/style/*.ts',
'*.spec.ts',
],
rules: {
'header/header': 'off',
},
},
{
files: ['**/style/*.ts'],
rules: {
'import/no-unassigned-import': 'off',
},
},
],
rules: {
// common
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
Expand All @@ -38,6 +84,15 @@ module.exports = {
quotes: ['error', 'single', { avoidEscape: true, allowTemplateLiterals: true }],
'prefer-const': ['error', { destructuring: 'all' }],
semi: ['error', 'never'],
'sort-imports': [
'error',
{
ignoreDeclarationSort: true,
},
],

// prettier
'prettier/prettier': ['error', prettierConfig],

// ts
'@typescript-eslint/brace-style': ['error', '1tbs'],
Expand Down Expand Up @@ -66,15 +121,43 @@ module.exports = {
},
],

// prettier
'prettier/prettier': 'error',

// vue
'vue/attribute-hyphenation': 'off',
'vue/html-closing-bracket-spacing': 'error',
'vue/max-attributes-per-line': 'off',
'vue/require-default-prop': 'error',
'vue/require-explicit-emits': 'error',

'jsdoc/newline-after-description': 1,
'import/no-duplicates': 'error',
'import/no-unused-modules': 'error',
'import/no-unassigned-import': 'error',
'import/order': [
'error',
{
alphabetize: { order: 'asc', caseInsensitive: false },
'newlines-between': 'always',
groups: ['type', 'builtin', 'external', 'internal', ['parent', 'sibling', 'index']],
pathGroups: [
{
pattern: '{vue,@vue/**}',
group: 'external',
position: 'before',
},
{
pattern: '{@juggle/**,@popperjs/**,dayjs,lodash-es}',
group: 'external',
position: 'before',
},
{
pattern: '@idux/**',
group: 'internal',
position: 'before',
},
],
pathGroupsExcludedImportTypes: ['type'],
},
],
},
ignorePatterns: ['dist', 'packages/site/src/router.ts', 'packages/site/src/sideNav.ts'],
}
11 changes: 0 additions & 11 deletions .prettierrc

This file was deleted.

13 changes: 13 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = {
printWidth: 120,
tabWidth: 2,
useTabs: false,
semi: false,
singleQuote: true,
trailingComma: 'all',
bracketSpacing: true,
arrowParens: 'avoid',
proseWrap: 'preserve',
endOfLine: 'lf',
htmlWhitespaceSensitivity: 'strict',
}
45 changes: 0 additions & 45 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -19,48 +19,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

MIT LICENSE

Copyright (c) 2018-present Ant UED, https://xtech.antfin.com/

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

The MIT License

Copyright (c) 2020 Google LLC.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@
"cz-conventional-changelog": "^3.3.0",
"esbuild": "^0.12.22",
"eslint": "^7.32.0",
"eslint-plugin-header": "~3.1.1",
"eslint-plugin-import": "~2.23.4",
"eslint-plugin-jsdoc": "~35.1.3",
"eslint-plugin-prettier": "^3.4.1",
"eslint-plugin-vue": "^7.16.0",
"figlet": "^1.5.2",
Expand Down
1 change: 1 addition & 0 deletions packages/cdk/breakpoint/demo/Basic.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

<script lang="ts">
import { defineComponent, watchEffect } from 'vue'
import { BREAKPOINTS, isMatched, useBreakpoints, useBreakpointsMatch, useScreens } from '@idux/cdk/breakpoint'
export default defineComponent({
Expand Down
7 changes: 7 additions & 0 deletions packages/cdk/breakpoint/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
/**
* @license
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://github.com/IDuxFE/idux/blob/main/LICENSE
*/

export { BREAKPOINTS, BREAKPOINTS_KEYS } from './src/breakpoints'
export { matchMedia } from './src/mediaMatcher'
export { isMatched, useBreakpoints, useBreakpointsMatch, useScreens } from './src/observe'
Expand Down
7 changes: 7 additions & 0 deletions packages/cdk/breakpoint/src/breakpoints.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
/**
* @license
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://github.com/IDuxFE/idux/blob/main/LICENSE
*/

export const BREAKPOINTS = {
xs: '(max-width: 767.99px)',
sm: '(min-width: 768px) and (max-width: 1023.99px)',
Expand Down
7 changes: 7 additions & 0 deletions packages/cdk/breakpoint/src/mediaMatcher.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
/**
* @license
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://github.com/IDuxFE/idux/blob/main/LICENSE
*/

/**
* @license
* Copyright Google LLC All Rights Reserved.
Expand Down
13 changes: 12 additions & 1 deletion packages/cdk/breakpoint/src/observe.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
import type { DeepReadonly, Ref } from 'vue'
/**
* @license
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://github.com/IDuxFE/idux/blob/main/LICENSE
*/

import type { BreakpointKey } from './breakpoints'
import type { DeepReadonly, Ref } from 'vue'

import { onBeforeUnmount, reactive, readonly, ref, watchEffect } from 'vue'

import { invert } from 'lodash-es'

import { convertArray } from '@idux/cdk/utils'

import { BREAKPOINTS } from './breakpoints'
import { matchMedia } from './mediaMatcher'

Expand Down Expand Up @@ -83,6 +93,7 @@ export function useScreens(): Screens {

/**
* Whether one or more media queries match the current viewport size.
*
* @param value One or more media queries to check.
* @returns Whether any of the media queries match.
*/
Expand Down
1 change: 1 addition & 0 deletions packages/cdk/click-outside/__tests__/clickOutside.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { mount } from '@vue/test-utils'

import { clickOutside } from '../src/useClickOutside'

describe('useClickOutside.ts', () => {
Expand Down
1 change: 1 addition & 0 deletions packages/cdk/click-outside/demo/Basic.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

<script lang="ts">
import { defineComponent } from 'vue'
import { useMessage } from '@idux/components/message'
export default defineComponent({
Expand Down
7 changes: 7 additions & 0 deletions packages/cdk/click-outside/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
/**
* @license
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://github.com/IDuxFE/idux/blob/main/LICENSE
*/

export * from './src/useClickOutside'
8 changes: 8 additions & 0 deletions packages/cdk/click-outside/src/useClickOutside.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
/**
* @license
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://github.com/IDuxFE/idux/blob/main/LICENSE
*/

import type { ObjectDirective } from 'vue'

import { isFunction, isObject } from 'lodash-es'

import { noop, on } from '@idux/cdk/utils'

interface ClickOutsideOptions {
Expand Down
1 change: 1 addition & 0 deletions packages/cdk/clipboard/__tests__/useClipboard.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { mount } from '@vue/test-utils'

import { useClipboard } from '../src/useClipboard'

const copyText = 'copy text'
Expand Down
1 change: 1 addition & 0 deletions packages/cdk/clipboard/demo/Basic.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

<script lang="ts">
import { defineComponent } from 'vue'
import { useClipboard } from '@idux/cdk/clipboard'
export default defineComponent({
Expand Down
7 changes: 7 additions & 0 deletions packages/cdk/clipboard/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
/**
* @license
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://github.com/IDuxFE/idux/blob/main/LICENSE
*/

export * from './src/useClipboard'
7 changes: 7 additions & 0 deletions packages/cdk/clipboard/src/clipboard.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
/**
* @license
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://github.com/IDuxFE/idux/blob/main/LICENSE
*/

import { PendingCopy } from './pendingCopy'

export class Clipboard {
Expand Down
7 changes: 7 additions & 0 deletions packages/cdk/clipboard/src/pendingCopy.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
/**
* @license
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://github.com/IDuxFE/idux/blob/main/LICENSE
*/

/**
* @license
* Copyright Google LLC All Rights Reserved.
Expand Down
8 changes: 8 additions & 0 deletions packages/cdk/clipboard/src/useClipboard.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
/**
* @license
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://github.com/IDuxFE/idux/blob/main/LICENSE
*/

import { onUnmounted } from 'vue'

import { Clipboard } from './clipboard'
import { PendingCopy } from './pendingCopy'

Expand Down
1 change: 1 addition & 0 deletions packages/cdk/forms/__tests__/abstractControl.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { flushPromises } from '@vue/test-utils'
import { Ref, ref, watch } from 'vue'

import { AbstractControl } from '../src/controls'
import { AsyncValidatorFn, ValidateErrors, ValidatorFn, ValidatorOptions } from '../src/types'
import { Validators } from '../src/validators'
Expand Down
1 change: 1 addition & 0 deletions packages/cdk/forms/__tests__/formArray.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { flushPromises } from '@vue/test-utils'

import { FormArray, FormControl, FormGroup } from '../src/controls'
import { ValidateErrors } from '../src/types'
import { Validators } from '../src/validators'
Expand Down
1 change: 1 addition & 0 deletions packages/cdk/forms/__tests__/formControl.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { flushPromises } from '@vue/test-utils'

import { FormControl } from '../src/controls'
import { ValidateErrors } from '../src/types'
import { Validators } from '../src/validators'
Expand Down
Loading

0 comments on commit 78738c2

Please sign in to comment.