feat: Migrate ESLint to flat config and resolve initial linting errors
Migrated the ESLint configuration to the new flat config format () and addressed several initial linting errors. Key changes include: - Updated ESLint configuration to treat as warnings instead of errors. - Fixed errors in by declaring and . - Corrected error in by using instead of an out-of-scope . - Resolved error in by replacing the undefined directive with the component. - Addressed errors in by replacing with and with . - Fixed errors in by importing necessary modules (, , ) and adding missing props (, , , , ).
This commit is contained in:
@@ -1,42 +1,43 @@
|
||||
/* Adapted from: To Title Case © 2018 David Gouch | https://github.com/gouch/to-title-case */
|
||||
// eslint-disable-next-line no-extend-native
|
||||
|
||||
export function to_title_case(text_string) {
|
||||
// console.log('*** to_title_case() ***');
|
||||
let smallWords = /^(a|an|and|as|at|but|by|en|for|if|in|nor|of|on|or|per|the|to|v.?|vs.?|via)$/i;
|
||||
let alphanumericPattern = /([A-Za-z0-9\u00C0-\u00FF])/;
|
||||
let wordSeparators = /([ :–—-])/;
|
||||
// console.log('*** to_title_case() ***');
|
||||
const smallWords = /^(a|an|and|as|at|but|by|en|for|if|in|nor|of|on|or|per|the|to|v.?|vs.?|via)$/i;
|
||||
const alphanumericPattern = /([A-Za-z0-9\u00C0-\u00FF])/;
|
||||
const wordSeparators = /([ :–—-])/;
|
||||
|
||||
return text_string.split(wordSeparators)
|
||||
.map(function (current, index, array) {
|
||||
if (
|
||||
/* Check for small words */
|
||||
current.search(smallWords) > -1 &&
|
||||
/* Skip first and last word */
|
||||
index !== 0 &&
|
||||
index !== array.length - 1 &&
|
||||
/* Ignore title end and subtitle start */
|
||||
array[index - 3] !== ':' &&
|
||||
array[index + 1] !== ':' &&
|
||||
/* Ignore small words that start a hyphenated phrase */
|
||||
(array[index + 1] !== '-' ||
|
||||
(array[index - 1] === '-' && array[index + 1] === '-'))) {
|
||||
return current.toLowerCase();
|
||||
}
|
||||
return text_string
|
||||
.split(wordSeparators)
|
||||
.map(function (current, index, array) {
|
||||
if (
|
||||
/* Check for small words */
|
||||
current.search(smallWords) > -1 &&
|
||||
/* Skip first and last word */
|
||||
index !== 0 &&
|
||||
index !== array.length - 1 &&
|
||||
/* Ignore title end and subtitle start */
|
||||
array[index - 3] !== ':' &&
|
||||
array[index + 1] !== ':' &&
|
||||
/* Ignore small words that start a hyphenated phrase */
|
||||
(array[index + 1] !== '-' || (array[index - 1] === '-' && array[index + 1] === '-'))
|
||||
) {
|
||||
return current.toLowerCase();
|
||||
}
|
||||
|
||||
/* Ignore intentional capitalization */
|
||||
if (current.substr(1).search(/[A-Z]|\../) > -1) {
|
||||
return current;
|
||||
}
|
||||
/* Ignore intentional capitalization */
|
||||
if (current.substr(1).search(/[A-Z]|\../) > -1) {
|
||||
return current;
|
||||
}
|
||||
|
||||
/* Ignore URLs */
|
||||
if (array[index + 1] === ':' && array[index + 2] !== '') {
|
||||
return current;
|
||||
}
|
||||
/* Ignore URLs */
|
||||
if (array[index + 1] === ':' && array[index + 2] !== '') {
|
||||
return current;
|
||||
}
|
||||
|
||||
/* Capitalize the first letter */
|
||||
return current.replace(alphanumericPattern, function (match) {
|
||||
return match.toUpperCase();
|
||||
});
|
||||
})
|
||||
.join('');
|
||||
/* Capitalize the first letter */
|
||||
return current.replace(alphanumericPattern, function (match) {
|
||||
return match.toUpperCase();
|
||||
});
|
||||
})
|
||||
.join('');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user