1

For example, I have the following code

https://github.com/kenpeter/mb/blob/master/lib/Processor.js

I used 2 spaces in vim and it is working nicely in vim. When the code is on github, it is not formatedly. Anyone know how to resolve it? The code looks like this in github page.

'use strict';

const Employee = require('./Employee');
const Util = require('./Util');

let util = new Util();
let Processor = function() {};

Processor.prototype.process = async function(taxObj, csvArr, fileName='../data/output.csv') {
    DEBUG && console.log('process');

    let item;
    let currTaxObj;
    let rightTaxSlot;
    let edge;
    let base;
    let taxRate;
    let buf = [];
    let employee;

    csvArr.map((item) => {
        employee = new Employee();

        // fill employee model
    employee.firstName = item.firstName;
    employee.lastName = item.lastName;
    employee.annualSalary = item.annualSalary;
    employee.superRate = util.percentToNum(item.superRate);
    employee.timePeriod = item.timePeriod;
    employee.startPeriod = util.parseTimePeriod(item.timePeriod)[0] + ' ' + TIME_PERIOD_YEAR;
    employee.endPeriod = util.parseTimePeriod(item.timePeriod)[1] + ' ' + TIME_PERIOD_YEAR;

        // get right tax slot
    currTaxObj = util.getTaxData(taxObj, employee.startPeriod, employee.endPeriod);
    rightTaxSlot = util.getRightTaxSlot(currTaxObj, employee.annualSalary);

    employee.grossIncome = util.buildGrossIncome(employee.annualSalary);
    employee.fullName = employee.buildFullName();

    // build income tax
    base = rightTaxSlot['base'];
    edge = rightTaxSlot['edge'];
    taxRate = rightTaxSlot['rate'];

    employee.incomeTax = util.buildIncomeTax(employee.annualSalary, base, edge, taxRate);
    employee.netIncome = util.buildNetIncome(employee.grossIncome, employee.incomeTax);
    employee.mySuper = util.buildMySuper(employee.grossIncome, employee.superRate);

    buf.push(employee); 
    }); 

    return await util.print(buf, fileName);
}

module.exports = Processor;
kenpeter
  • 7,404
  • 14
  • 64
  • 95

1 Answers1

1

I don't see any format issue in your GitHub page.
The comments are properly aligned.

I checked for any tabulation instead of space by adding ?ts=4 to the URL, but nothing changed (meaning, only spaces are used)

Check your vim settings, as described here.
Especially set tabstop=4 and set expandtab.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250