From f1e2678b97462cf0c730e1e9b6c194e20ca635e4 Mon Sep 17 00:00:00 2001 From: Edward Chernenko Date: Sat, 7 Dec 2024 05:23:16 +0300 Subject: [PATCH] (tests) Add eslint --- .eslintrc.json | 16 ++++++++++++++++ .github/workflows/main.yml | 3 ++- .gitignore | 3 +++ .stylelintrc.json | 6 ++++++ Gruntfile.js | 30 ++++++++++++++++++++++++++++++ package.json | 14 ++++++++++++++ 6 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 .eslintrc.json create mode 100644 .stylelintrc.json create mode 100644 Gruntfile.js create mode 100644 package.json diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 0000000..8b1784a --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,16 @@ +{ + "root": true, + "extends": [ + "wikimedia/client", + "wikimedia/jquery", + "wikimedia/mediawiki" + ], + "globals": { + "require": "readonly" + }, + "rules": { + "no-jquery/no-event-shorthand": "off", + "no-jquery/no-global-selector": "off", + "no-console": "off" + } +} diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b7eeaab..9f953c3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -20,8 +20,9 @@ jobs: with: path: ~/.composer/cache key: buildcache-linter - - run: sudo apt-get install -y composer && composer install + - run: sudo apt-get install -y composer npm && composer install - run: composer test + - run: npm test # Phan (PHP static analyzer) phan: diff --git a/.gitignore b/.gitignore index 22d0d82..ce34efb 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,4 @@ vendor +node_modules +.eslintcache + diff --git a/.stylelintrc.json b/.stylelintrc.json new file mode 100644 index 0000000..b681cd2 --- /dev/null +++ b/.stylelintrc.json @@ -0,0 +1,6 @@ +{ + "extends": "stylelint-config-wikimedia", + "rules": { + "selector-max-id": null + } +} diff --git a/Gruntfile.js b/Gruntfile.js new file mode 100644 index 0000000..4d342d5 --- /dev/null +++ b/Gruntfile.js @@ -0,0 +1,30 @@ +/* eslint-env node */ +module.exports = function ( grunt ) { + var conf = grunt.file.readJSON( 'extension.json' ); + + grunt.loadNpmTasks( 'grunt-banana-checker' ); + grunt.loadNpmTasks( 'grunt-eslint' ); + grunt.loadNpmTasks( 'grunt-stylelint' ); + + grunt.initConfig( { + eslint: { + options: { + cache: true + }, + all: [ + '**/*.{js,json}', + '!{vendor,node_modules}/**' + ] + }, + banana: conf.MessagesDirs, + stylelint: { + all: [ + '**/*.css', + '!{vendor,node_modules}/**' + ] + } + } ); + + grunt.registerTask( 'test', [ 'eslint', 'banana', 'stylelint' ] ); + grunt.registerTask( 'default', 'test' ); +}; diff --git a/package.json b/package.json new file mode 100644 index 0000000..f32ccd4 --- /dev/null +++ b/package.json @@ -0,0 +1,14 @@ +{ + "private": true, + "scripts": { + "test": "grunt test" + }, + "devDependencies": { + "eslint-config-wikimedia": "0.22.1", + "grunt": "1.5.3", + "grunt-banana-checker": "0.9.00", + "grunt-eslint": "24.0.0", + "grunt-stylelint": "0.18.0", + "stylelint-config-wikimedia": "0.13.0" + } +}