Skip to content

Commit

Permalink
chore: update eslint, fix files formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
t1m0n committed Oct 12, 2021
1 parent 5858242 commit 0d4bfb3
Show file tree
Hide file tree
Showing 11 changed files with 135 additions and 133 deletions.
61 changes: 30 additions & 31 deletions .eslintrc.js
@@ -1,3 +1,5 @@
let tabSize = 4;

module.exports = {
'env': {
'browser': true,
Expand All @@ -20,41 +22,38 @@ module.exports = {
'sourceType': 'module'
},
'rules': {
'indent': [
'error',
4,
{
SwitchCase: 1
}
],
'linebreak-style': "off",
'quotes': [
'error',
'single'
],
'semi': [
'warn',
'always'
],
indent: ['error', tabSize, {ignoredNodes: ['TemplateLiteral'], SwitchCase: 1}], // игнорируем string template из-за ошибки в пакетах
quotes: ['error', 'single'],
semi: ['warn', 'always'],
curly: ['error', 'multi-line'],
'arrow-parens': ['error', 'as-needed', {requireForBlockBody: true}],
'curly': ['error', 'multi-line'],
'no-unused-vars': [
'error',
'warn',
{
'ignoreRestSiblings': true,
'argsIgnorePattern': '^e$', // Allow to use 'e'(events) argument
ignoreRestSiblings: true,
argsIgnorePattern: '^e$',
varsIgnorePattern: '^_$',
}
},
],
'max-len': [
'error',
{
'code': 120,
'ignoreStrings': true,
'ignoreTrailingComments': true,
'ignoreComments': true,
'ignoreTemplateLiterals': true
}
]
'max-len': ['error', {code: 120, ignoreStrings: true, ignoreComments: true}],
'object-curly-spacing': ['error', 'never'],
'array-bracket-spacing': ['error', 'never'],
'comma-style': ['error', 'last'],
'comma-spacing': ['error', {'before': false, 'after': true}],
'space-infix-ops': 'error',
'space-in-parens': ['error', 'never'],
'space-before-function-paren': ['error', {
'anonymous': 'always',
'named': 'never',
'asyncArrow': 'always'
}],
'keyword-spacing': 'error',
'arrow-spacing': 'error',
'space-before-blocks': 'error',
'no-magic-numbers': ['warn', {
ignore: [0, 1, -1],
ignoreArrayIndexes: true,
ignoreDefaultValues: true,
}],
},
};
2 changes: 1 addition & 1 deletion docs/.eslintrc.js
Expand Up @@ -23,7 +23,7 @@ module.exports = {
},
plugins: ['react'],
rules: {
indent: ['error', tabSize, {ignoredNodes: ['TemplateLiteral']}], // игнорируем string template из-за ошибки в пакетах
indent: ['error', tabSize, {ignoredNodes: ['TemplateLiteral'], SwitchCase: 1}], // игнорируем string template из-за ошибки в пакетах
quotes: ['error', 'single'],
semi: ['warn', 'always'],
curly: ['error', 'multi-line'],
Expand Down
3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -7,6 +7,7 @@
"prod": "set NODE_ENV=production&& webpack",
"browser": "open-cli http://localhost:8080 -- 'chrome' ",
"build": "node scripts/build.js",
"lint-js": "eslint --fix ./src/*.js",
"test": "jest"
},
"devDependencies": {
Expand All @@ -22,7 +23,7 @@
"chalk": "^4.1.1",
"css-loader": "^3.5.3",
"ejs": "^3.1.6",
"eslint": "^6.8.0",
"eslint": "^7.32.0",
"eslint-loader": "^4.0.2",
"express": "^4.17.1",
"glob": "^7.1.7",
Expand Down
36 changes: 18 additions & 18 deletions src/datepickerBody.js
Expand Up @@ -38,7 +38,7 @@ export default class DatepickerBody {
this.init();
}

init(){
init() {
this._buildBaseHtml();
if (this.type === consts.days) {
this.renderDayNames();
Expand All @@ -48,7 +48,7 @@ export default class DatepickerBody {
this._bindDatepickerEvents();
}

_bindEvents(){
_bindEvents() {
let {range, dynamicRange} = this.opts;

addEventListener(this.$el, 'mouseover', this.onMouseOverCell);
Expand All @@ -63,7 +63,7 @@ export default class DatepickerBody {

}

_bindDatepickerEvents(){
_bindDatepickerEvents() {
this.dp.on(consts.eventChangeViewDate, this.onChangeViewDate);
this.dp.on(consts.eventChangeCurrentView, this.onChangeCurrentView);
}
Expand Down Expand Up @@ -99,7 +99,7 @@ export default class DatepickerBody {
return html;
}

_getDaysCells(){
_getDaysCells() {
let {viewDate, locale: {firstDay}} = this.dp,
totalMonthDays = getDaysCount(viewDate),
{year, month} = getParsedDate(viewDate),
Expand All @@ -117,7 +117,7 @@ export default class DatepickerBody {
{year:renderYear, month: renderMonth} = getParsedDate(firstRenderDate),
i = 0;

while(i < totalRenderDays) {
while (i < totalRenderDays) {
let date = new Date(renderYear, renderMonth, firstRenderDayDate + i);
this._generateCell(date);
i++;
Expand All @@ -139,38 +139,38 @@ export default class DatepickerBody {
return cell;
}

_generateDayCells(){
_generateDayCells() {
this._getDaysCells();
}

_generateMonthCells(){
_generateMonthCells() {
let totalMonths = 12,
{year} = this.dp.parsedViewDate,
currentMonth = 0;

while(currentMonth < totalMonths) {
while (currentMonth < totalMonths) {
this.cells.push(this._generateCell(new Date(year, currentMonth)));
currentMonth++;
}
}

_generateYearCells(){
_generateYearCells() {
let decade = getDecade(this.dp.viewDate),
firstYear = decade[0] - 1,
lastYear = decade[1] + 1,
year = firstYear;

while(year <= lastYear) {
while (year <= lastYear) {
this.cells.push(this._generateCell(new Date(year, 0)));
year++;
}
}

renderDayNames(){
renderDayNames() {
this.$names.innerHTML = this._getDayNamesHtml();
}

_generateCells(){
_generateCells() {
switch (this.type) {
case consts.days:
this._generateDayCells();
Expand All @@ -194,11 +194,11 @@ export default class DatepickerBody {
this.$el.classList.add('-hidden-');
}

destroyCells(){
this.cells.forEach(c=>c.destroy());
destroyCells() {
this.cells.forEach(c => c.destroy());
}

handleClick = (e) =>{
handleClick = (e) => {
let $cell = closest(e.target, '.air-datepicker-cell');
if (!$cell) return;
let cell = $cell.adpCell;
Expand All @@ -218,7 +218,7 @@ export default class DatepickerBody {
}
}

onChangeCurrentView = (view) =>{
onChangeCurrentView = (view) => {
if (view !== this.type) {
this.hide();
} else {
Expand All @@ -240,7 +240,7 @@ export default class DatepickerBody {
this.handleClick(e);
}

onMouseDown = (e) =>{
onMouseDown = (e) => {
this.pressed = true;

let $cell = closest(e.target, '.air-datepicker-cell'),
Expand Down Expand Up @@ -329,7 +329,7 @@ export default class DatepickerBody {
this.$cells.innerHTML = '';

this._generateCells();
this.cells.forEach((c)=>{
this.cells.forEach((c) => {
this.$cells.appendChild(c.render());
});
}
Expand Down
16 changes: 8 additions & 8 deletions src/datepickerButtons.js
Expand Up @@ -6,17 +6,17 @@ import './datepickerButtons.scss';
export default class DatepickerButtons {
constructor({dp, opts}) {
this.dp = dp;
this.opts= opts;
this.opts = opts;

this.init();
}

init(){
init() {
this.createElement();
this.render();
}

createElement(){
createElement() {
this.$el = createElement({className: 'air-datepicker-buttons'});
}

Expand All @@ -29,14 +29,14 @@ export default class DatepickerButtons {
return this;
}

generateButtons(){
generateButtons() {
let {buttons} = this.opts;

if (!Array.isArray(buttons)) {
buttons = [buttons];
}

buttons.forEach((b)=>{
buttons.forEach((b) => {
let data = b;

if (typeof b === 'string' && buttonPresets[b]) {
Expand All @@ -54,7 +54,7 @@ export default class DatepickerButtons {
}

attachEventToButton(button, onClick) {
button.addEventListener('click', ()=>{
button.addEventListener('click', () => {
onClick(this.dp);
});
}
Expand All @@ -66,7 +66,7 @@ export default class DatepickerButtons {
* @param {String} [tagName=button]
* @return HTMLElement
*/
createButton({content, className, tagName='button'}){
createButton({content, className, tagName = 'button'}) {
let _content = typeof content === 'function' ? content(this.dp) : content;

return createElement({
Expand All @@ -76,7 +76,7 @@ export default class DatepickerButtons {
});
}

render(){
render() {
this.generateButtons();
}
}

0 comments on commit 0d4bfb3

Please sign in to comment.