Siebrand has uploaded a new change for review.
https://gerrit.wikimedia.org/r/275532
Change subject: Use mediawiki-codesniffer 0.6.0
......................................................................
Use mediawiki-codesniffer 0.6.0
Also update other automatic tests.
Change-Id: Ia97e34b1734cda40ce46269333dfda0377c78c78
---
M .gitignore
A .jshintignore
A .jshintrc
M CharInsert.body.php
M Gruntfile.js
A composer.json
M package.json
A phpcs.xml
8 files changed, 69 insertions(+), 22 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CharInsert
refs/changes/32/275532/1
diff --git a/.gitignore b/.gitignore
index e7e3181..bc0d546 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,4 +3,7 @@
*.kate-swp
.*.swp
.idea
-node_modules/
+.project
+composer.lock
+vendor
+node_modules
diff --git a/.jshintignore b/.jshintignore
new file mode 100644
index 0000000..3c3629e
--- /dev/null
+++ b/.jshintignore
@@ -0,0 +1 @@
+node_modules
diff --git a/.jshintrc b/.jshintrc
new file mode 100644
index 0000000..d43c482
--- /dev/null
+++ b/.jshintrc
@@ -0,0 +1,20 @@
+{
+ // Enforcing
+ "bitwise": true,
+ "eqeqeq": true,
+ "es3": true,
+ "latedef": true,
+ "noarg": true,
+ "nonew": true,
+ "undef": true,
+ "unused": true,
+ "strict": false,
+
+ // Environment
+ "browser": true,
+
+ "globals": {
+ "mw": false,
+ "$": false
+ }
+}
diff --git a/CharInsert.body.php b/CharInsert.body.php
index 993d1c8..b8edb5c 100644
--- a/CharInsert.body.php
+++ b/CharInsert.body.php
@@ -18,7 +18,7 @@
$addModules = true;
} else {
$action = Action::getActionName( $out );
- if ( in_array( $action, array( 'edit', 'submit' ) ) ) {
+ if ( in_array( $action, [ 'edit', 'submit' ] ) ) {
$addModules = true;
}
}
@@ -50,8 +50,8 @@
public static function charInsertNowiki( $matches ) {
return str_replace(
- array( '\t', '\r', ' ' ),
- array( '	', '', ' ' ),
+ [ '\t', '\r', ' ' ],
+ [ '	', '', ' ' ],
$matches[1] );
}
@@ -72,18 +72,18 @@
$inline = $estart . $eend;
return Xml::element( 'a',
- array(
+ [
'data-mw-charinsert-start' => $estart,
'data-mw-charinsert-end' => $eend,
'class' => 'mw-charinsert-item
mw-charinsert-item-todo',
'href' => "#"
- ), $inline
+ ], $inline
);
}
public static function charInsertDisplay( $text ) {
- static $invisibles = array( ' ', ' ' );
- static $visibles = array( ' ', ' ' );
+ static $invisibles = [ ' ', ' ' ];
+ static $visibles = [ ' ', ' ' ];
return Sanitizer::decodeCharReferences(
str_replace( $invisibles, $visibles, $text ) );
}
diff --git a/Gruntfile.js b/Gruntfile.js
index 90e007b..69e6d05 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -1,24 +1,25 @@
-/*!
- * Grunt file
- *
- * @package CharInsert
- */
-
/*jshint node:true */
module.exports = function ( grunt ) {
- var conf = grunt.file.readJSON( 'extension.json' );
-
+ grunt.loadNpmTasks( 'grunt-contrib-jshint' );
+ grunt.loadNpmTasks( 'grunt-jsonlint' );
grunt.loadNpmTasks( 'grunt-banana-checker' );
grunt.loadNpmTasks( 'grunt-jscs' );
- grunt.loadNpmTasks( 'grunt-jsonlint' );
grunt.initConfig( {
- banana: conf.MessagesDirs,
- jscs: {
+ jshint: {
+ options: {
+ jshintrc: true
+ },
all: [
- '**/*.js',
- '!node_modules/**'
+ '*.js',
+ 'modules/**/*.js'
]
+ },
+ jscs: {
+ src: '<%= jshint.all %>'
+ },
+ banana: {
+ all: 'i18n/'
},
jsonlint: {
all: [
@@ -28,6 +29,6 @@
}
} );
- grunt.registerTask( 'test', [ 'jscs', 'jsonlint', 'banana' ] );
+ grunt.registerTask( 'test', [ 'jshint', 'jscs', 'jsonlint', 'banana' ]
);
grunt.registerTask( 'default', 'test' );
};
diff --git a/composer.json b/composer.json
new file mode 100644
index 0000000..5d52161
--- /dev/null
+++ b/composer.json
@@ -0,0 +1,13 @@
+{
+ "require-dev": {
+ "jakub-onderka/php-parallel-lint": "0.9.2",
+ "mediawiki/mediawiki-codesniffer": "0.6.0"
+ },
+ "scripts": {
+ "fix": "phpcbf",
+ "test": [
+ "parallel-lint . --exclude vendor",
+ "phpcs -p -s"
+ ]
+ }
+}
diff --git a/package.json b/package.json
index 284ae06..3f9062c 100644
--- a/package.json
+++ b/package.json
@@ -9,6 +9,7 @@
"devDependencies": {
"grunt": "0.4.5",
"grunt-cli": "0.1.13",
+ "grunt-contrib-jshint": "0.11.3",
"grunt-banana-checker": "0.4.0",
"grunt-jscs": "2.8.0",
"grunt-jsonlint": "1.0.7"
diff --git a/phpcs.xml b/phpcs.xml
new file mode 100644
index 0000000..d81a292
--- /dev/null
+++ b/phpcs.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0"?>
+<ruleset>
+ <rule ref="vendor/mediawiki/mediawiki-codesniffer/MediaWiki"/>
+ <file>.</file>
+ <arg name="extensions" value="php,php5,inc"/>
+ <arg name="encoding" value="utf8"/>
+ <exclude-pattern>vendor</exclude-pattern>
+</ruleset>
--
To view, visit https://gerrit.wikimedia.org/r/275532
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia97e34b1734cda40ce46269333dfda0377c78c78
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CharInsert
Gerrit-Branch: master
Gerrit-Owner: Siebrand <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits