lib/rules/max-len.js
function computeLineLength(line, tabWidth) {
            let extraCharacterCount = 0;

            line.replace(/\t/gu, (match, offset) => {
                const totalOffset = offset + extraCharacterCount,
                    previousTabStopOffset = tabWidth ? totalOffset % tabWidth : 0,
                    spaceCount = tabWidth - previousTabStopOffset;

                extraCharacterCount += spaceCount - 1; // -1 for the replaced tab
            });
            return Array.from(line).length + extraCharacterCount;
        }
function computeLineLength(line, tabWidth) {
            let extraCharacterCount = 0;

            line.replace(/\t/gu, (match, offset) => {
                const totalOffset = offset + extraCharacterCount,
                    previousTabStopOffset = tabWidth ? totalOffset % tabWidth : 0,
                    spaceCount = tabWidth - previousTabStopOffset;

                extraCharacterCount += spaceCount - 1; // -1 for the replaced tab
            });
            return Array.from(line).length + extraCharacterCount;
        }
function computeLineLength ( line , tabWidth ) { let extraCharacterCount = 0 ; line . replace ( / \t / gu , ( match , offset ) => { const totalOffset = offset + extraCharacterCount , previousTabStopOffset = tabWidth ? totalOffset % tabWidth : 0 , spaceCount = tabWidth - previousTabStopOffset ; extraCharacterCount += spaceCount - 1 ; // -1 for the replaced tab } ) ; return Array . from ( line ) . length + extraCharacterCount ; }
Computes the length of a line that may contain tabs. The width of each
tab will be the number of spaces to the next tab stop.
@param {string} line The line.
@param {int} tabWidth The width of each tab stop in spaces.
@returns {int} The computed line length.
@private
Computes the length of a line that may contain tabs . The width of each tab will be the number of spaces to the next tab stop .