Skip to content

Commit

Permalink
autofix some eslint unicorn/prefer-string-slice
Browse files Browse the repository at this point in the history
I removed a couple of the autofixes because I don't like how it added Math.max(), which is complicated to read. I kept the helpful ones.
  • Loading branch information
NovemLinguae committed Nov 30, 2024
1 parent e7d4c6c commit 6591c7d
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
"space-before-function-paren": "off",
"space-in-parens": "off",
"template-curly-spacing": "off",
"unicorn/prefer-string-slice": "off",

"no-nested-ternary": "error",
"no-restricted-syntax": [
Expand Down Expand Up @@ -62,6 +61,7 @@
"no-use-before-define": "warn",
"no-useless-concat": "warn",
"no-var": "warn",
"prefer-const": "warn"
"prefer-const": "warn",
"unicorn/prefer-string-slice": "warn"
}
}
2 changes: 1 addition & 1 deletion modules/twinkleconfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -1496,7 +1496,7 @@ Twinkle.config.listDialog.save = function twinkleconfigListDialogSave($button, $
// reset/restore defaults

Twinkle.config.resetPrefLink = function twinkleconfigResetPrefLink(e) {
const wantedpref = e.target.id.substring(21); // "twinkle-config-reset-" prefix is stripped
const wantedpref = e.target.id.slice(21); // "twinkle-config-reset-" prefix is stripped

// search tactics
$(Twinkle.config.sections).each((sectionkey, section) => {
Expand Down
8 changes: 4 additions & 4 deletions modules/twinklewarn.js
Original file line number Diff line number Diff line change
Expand Up @@ -1918,7 +1918,7 @@ Twinkle.warn.callbacks = {
const customProcess = function(template) {
template = template.split('|')[0];
let prefix;
switch (template.substr(-1)) {
switch (template.slice(-1)) {
case '1':
prefix = 'General note';
break;
Expand All @@ -1932,7 +1932,7 @@ Twinkle.warn.callbacks = {
prefix = 'Final warning';
break;
case 'm':
if (template.substr(-3) === '4im') {
if (template.slice(-3) === '4im') {
prefix = 'Only warning';
break;
}
Expand All @@ -1950,9 +1950,9 @@ Twinkle.warn.callbacks = {
} else {
// Normalize kitchensink to the 1-4im style
if (params.main_group === 'kitchensink' && !/^D+$/.test(params.sub_group)) {
let sub = params.sub_group.substr(-1);
let sub = params.sub_group.slice(-1);
if (sub === 'm') {
sub = params.sub_group.substr(-3);
sub = params.sub_group.slice(-3);
}
// Don't overwrite uw-3rr, technically unnecessary
if (/\d/.test(sub)) {
Expand Down
6 changes: 3 additions & 3 deletions morebits.js
Original file line number Diff line number Diff line change
Expand Up @@ -1421,15 +1421,15 @@ Morebits.string = {
*/
toUpperCaseFirstChar: function(str) {
str = str.toString();
return str.substr(0, 1).toUpperCase() + str.substr(1);
return str.slice(0, 1).toUpperCase() + str.slice(1);
},
/**
* @param {string} str
* @return {string}
*/
toLowerCaseFirstChar: function(str) {
str = str.toString();
return str.substr(0, 1).toLowerCase() + str.substr(1);
return str.slice(0, 1).toLowerCase() + str.slice(1);
},

/**
Expand Down Expand Up @@ -4830,7 +4830,7 @@ Morebits.wikitext.parseTemplate = function(text, start) {
function findParam(final) {
// Nothing found yet, this must be the template name
if (count === -1) {
result.name = current.substring(2).trim();
result.name = current.slice(2).trim();
++count;
} else {
// In a parameter
Expand Down

0 comments on commit 6591c7d

Please sign in to comment.