Skip to content

Commit

Permalink
chore: use eslint and yarn workspace
Browse files Browse the repository at this point in the history
  • Loading branch information
plantain-00 committed Jul 21, 2019
1 parent 707a411 commit ce89ccc
Show file tree
Hide file tree
Showing 15 changed files with 252 additions and 607 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
packages/@(core|vue|react|angular)/@(src|demo)/**/*.d.ts
36 changes: 36 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"prettier",
"prettier/@typescript-eslint"
],
"parserOptions": {
"project": "./tsconfig.base.json"
},
"plugins": [
"plantain"
],
"rules": {
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/no-use-before-define": "off",
"@typescript-eslint/explicit-member-accessibility": "off",
"@typescript-eslint/no-parameter-properties": "off",
"no-case-declarations": "off",
"no-useless-escape": "off",
"no-console": "off",
"plantain/promise-not-await": "error"
},
"env": {
"node": true
},
"overrides": [
{
"files": ["*.js"],
"rules": {
"@typescript-eslint/no-var-requires": "off"
}
}
]
}
6 changes: 2 additions & 4 deletions clean-scripts.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@ module.exports = {
revStaticCommand
],
lint: {
ts: `tslint ${tsFiles} --exclude ${excludeTsFiles}`,
js: `standard ${jsFiles}`,
ts: `eslint --ext .js,.ts ${tsFiles} ${jsFiles}`,
less: `stylelint ${lessFiles}`,
export: `no-unused-export ${tsFiles} ${lessFiles} --exclude ${excludeTsFiles}`,
commit: `commitlint --from=HEAD~1`,
Expand All @@ -84,8 +83,7 @@ module.exports = {
'karma start spec/karma.config.js'
],
fix: {
ts: `tslint --fix ${tsFiles} --exclude ${excludeTsFiles}`,
js: `standard --fix ${jsFiles}`,
ts: `eslint --ext .js,.ts ${tsFiles} ${jsFiles} --fix`,
less: `stylelint --fix ${lessFiles}`
},
watch: {
Expand Down
1 change: 1 addition & 0 deletions lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
}
},
"version": "5.6.1",
"useWorkspaces": true,
"npmClient": "yarn"
}
12 changes: 8 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,21 @@
"rollup-plugin-commonjs": "10.0.1",
"rollup-plugin-node-resolve": "5.2.0",
"rollup-plugin-uglify": "6.0.2",
"standard": "13.0.2",
"stylelint": "10.1.0",
"stylelint-config-standard": "18.3.0",
"tslint": "5.18.0",
"tslint-config-standard": "8.0.1",
"tslint-sonarts": "1.9.0",
"@typescript-eslint/eslint-plugin": "^1.9.0",
"@typescript-eslint/parser": "^1.9.0",
"eslint-config-prettier": "6.0.0",
"eslint-plugin-plantain": "0.1.2",
"eslint": "5.16.0",
"type-coverage": "2.1.0",
"typescript": "3.4.5",
"watch-then-execute": "1.1.1",
"webpack": "4.36.1",
"webpack-cli": "3.3.6"
},
"workspaces": [
"packages/*"
],
"dependencies": {}
}
1 change: 0 additions & 1 deletion packages/angular/src/index.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ export class Select2 implements ControlValueAccessor {
private searchInputElement!: HTMLElement
private resultsElement!: HTMLElement

// tslint:disable:member-ordering
private _stateChanges = new Subject<void>()

/** Whether the element is focused or not. */
Expand Down
60 changes: 0 additions & 60 deletions packages/angular/yarn.lock

This file was deleted.

10 changes: 4 additions & 6 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
export type Select2Group = {
export interface Select2Group {
label: string;
options: Select2Option[];
classes?: string;
}

export type Select2Option = {
export interface Select2Option {
value: Select2Value;
label: string;
disabled?: boolean;
Expand Down Expand Up @@ -178,7 +178,6 @@ export function valueIsNotInFilteredData(filteredData: Select2Data, value: Selec
return true
}

// tslint:disable-next-line:cognitive-complexity
export function getPreviousOption(filteredData: Select2Data, hoveringValue: Select2Value | null | undefined) {
let findIt = isNullOrUndefined(hoveringValue)
for (let i = filteredData.length - 1; i >= 0; i--) {
Expand All @@ -202,7 +201,6 @@ export function getPreviousOption(filteredData: Select2Data, hoveringValue: Sele
}
return findIt ? hoveringValue : null
}
// tslint:disable-next-line:cognitive-complexity
export function getNextOption(filteredData: Select2Data, hoveringValue: Select2Value | null | undefined) {
let findIt = isNullOrUndefined(hoveringValue)
for (const groupOrOption of filteredData) {
Expand Down Expand Up @@ -231,7 +229,7 @@ export function getNextOption(filteredData: Select2Data, hoveringValue: Select2V
return findIt ? hoveringValue : null
}

function isNullOrUndefined(value: any) {
function isNullOrUndefined<T>(value: T): value is (T extends null | undefined ? T : never) {
return value === null || value === undefined
}

Expand All @@ -245,7 +243,7 @@ export function getLastScrollTopIndex(
results.scrollTop = 0
return 0
} else {
const scrollTop = getScrollUpIndex(filteredData, hoveringValue!)
const scrollTop = getScrollUpIndex(filteredData, hoveringValue)
if (scrollTop - lastScrollTopIndex > 5) {
lastScrollTopIndex += scrollTop - lastScrollTopIndex - 5
const item = results.querySelectorAll('li').item(scrollTop)
Expand Down
13 changes: 0 additions & 13 deletions packages/core/yarn.lock

This file was deleted.

92 changes: 0 additions & 92 deletions packages/react/yarn.lock

This file was deleted.

2 changes: 0 additions & 2 deletions packages/vue/demo/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import Vue from 'vue'
import Component from 'vue-class-component'
// tslint:disable:no-duplicate-imports
import '../dist/'
import { Select2Option, Select2Data, Select2Group } from '../dist/'
import { data1, data2, data3, data5, data12 } from 'select2-component/demo/'
Expand Down Expand Up @@ -149,5 +148,4 @@ class App extends Vue {
}
}

// tslint:disable-next-line:no-unused-expression
new App({ el: '#container' })
18 changes: 0 additions & 18 deletions packages/vue/yarn.lock

This file was deleted.

2 changes: 1 addition & 1 deletion screenshots/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ import puppeteer from 'puppeteer'
await page.screenshot({ path: `screenshots/${type}-initial.png` })
}

browser.close()
await browser.close()
})()
9 changes: 0 additions & 9 deletions tslint.json

This file was deleted.

0 comments on commit ce89ccc

Please sign in to comment.