From a70f411ee1973494b6b6e6d9643cd5e84f395aa2 Mon Sep 17 00:00:00 2001 From: Ed Sanders Date: Wed, 27 Mar 2024 12:45:21 +0000 Subject: [PATCH] Setup grunt-tyops and fix Change-Id: I372c3cc5bedaf800716bff68cadb2846a399a42a --- Gruntfile.js | 19 ++++++++++++++++++- includes/CommentFormatter.php | 6 +++--- package-lock.json | 13 +++++++++++++ package.json | 1 + typos.json | 25 +++++++++++++++++++++++++ 5 files changed, 60 insertions(+), 4 deletions(-) create mode 100644 typos.json diff --git a/Gruntfile.js b/Gruntfile.js index df98f663d..38b5595c7 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -5,6 +5,7 @@ module.exports = function ( grunt ) { grunt.loadNpmTasks( 'grunt-banana-checker' ); grunt.loadNpmTasks( 'grunt-eslint' ); grunt.loadNpmTasks( 'grunt-stylelint' ); + grunt.loadNpmTasks( 'grunt-tyops' ); grunt.initConfig( { eslint: { @@ -20,9 +21,25 @@ module.exports = function ( grunt ) { 'modules/**/*.{css,less}' ] }, + tyops: { + options: { + typos: 'typos.json' + }, + src: [ + '**/*.{js,json,less,css,txt,php,md,sh}', + '!package-lock.json', + '!typos.json', + '!i18n/**', + 'i18n/en.json', + 'i18n/qqq.json', + '!lib/**', + '!{docs,node_modules,vendor}/**', + '!.git/**' + ] + }, banana: conf.MessagesDirs } ); - grunt.registerTask( 'test', [ 'eslint', 'stylelint', 'banana' ] ); + grunt.registerTask( 'test', [ 'tyops', 'eslint', 'stylelint', 'banana' ] ); grunt.registerTask( 'default', 'test' ); }; diff --git a/includes/CommentFormatter.php b/includes/CommentFormatter.php index 69ad09ad5..54adaf025 100644 --- a/includes/CommentFormatter.php +++ b/includes/CommentFormatter.php @@ -971,9 +971,9 @@ class CommentFormatter { // Check fallback languages $fallbackLanguages = $userLang->getFallbackLanguages(); - foreach ( $fallbackLanguages as $fallbackLangauge ) { - if ( isset( $languages[ $fallbackLangauge ] ) ) { - return (bool)$languages[ $fallbackLangauge ]; + foreach ( $fallbackLanguages as $fallbackLanguage ) { + if ( isset( $languages[ $fallbackLanguage ] ) ) { + return (bool)$languages[ $fallbackLanguage ]; } } diff --git a/package-lock.json b/package-lock.json index 2bff859d6..f5d3049e8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,6 +13,7 @@ "grunt-banana-checker": "0.11.1", "grunt-eslint": "24.3.0", "grunt-stylelint": "0.19.0", + "grunt-tyops": "0.1.1", "stylelint-config-wikimedia": "0.16.1" } }, @@ -2515,6 +2516,12 @@ "stylelint": "15.x" } }, + "node_modules/grunt-tyops": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/grunt-tyops/-/grunt-tyops-0.1.1.tgz", + "integrity": "sha512-fLTY6Ai1JpIv1INYCWq3/gNZKsvGrcg6M2XxBsmwdciY//3+12/dlKZy5C5HjjupwpcpScggilgSyvwnU+I1Fg==", + "dev": true + }, "node_modules/grunt/node_modules/argparse": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", @@ -7046,6 +7053,12 @@ "chalk": "^4.1.2" } }, + "grunt-tyops": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/grunt-tyops/-/grunt-tyops-0.1.1.tgz", + "integrity": "sha512-fLTY6Ai1JpIv1INYCWq3/gNZKsvGrcg6M2XxBsmwdciY//3+12/dlKZy5C5HjjupwpcpScggilgSyvwnU+I1Fg==", + "dev": true + }, "hard-rejection": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/hard-rejection/-/hard-rejection-2.1.0.tgz", diff --git a/package.json b/package.json index c0b12c577..e5fbaa613 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ "grunt-banana-checker": "0.11.1", "grunt-eslint": "24.3.0", "grunt-stylelint": "0.19.0", + "grunt-tyops": "0.1.1", "stylelint-config-wikimedia": "0.16.1" } } diff --git a/typos.json b/typos.json new file mode 100644 index 000000000..b83608583 --- /dev/null +++ b/typos.json @@ -0,0 +1,25 @@ +{ + "caseInsensitive": [ + [ "paralell", "parallel" ], + [ "properites", "properties" ], + [ "visiblit(ies|y)", "visibilit$1" ], + [ "movablilties", "movabilities" ], + [ "inpsect(ors?|ion)", "inspect$1" ], + [ "\bteh\b", "the" ], + [ "intialization", "initialization" ], + [ "durring", "during" ], + [ "contian", "contain" ], + [ "occured", "occurred" ], + [ "pgk", "pkg" ], + [ "arrray", "array" ], + [ "overriden", "overridden" ], + [ "begining", "beginning" ], + [ "detatched", "detached" ], + [ "paramter", "parameter" ], + [ "descendent", "descendant" ], + [ "sepcific", "specific" ], + [ "connet", "connect" ], + [ "emtpy", "empty" ], + [ "langauge", "language" ] + ] +}