From 432b999737f968a0fb547a5596ae068056095369 Mon Sep 17 00:00:00 2001 From: lens0021 Date: Sat, 2 Mar 2024 06:05:05 +0900 Subject: [PATCH] Replace Prettier with eslint --- .eslintignore | 7 +++++++ .eslintrc.json | 7 +++++++ .prettierignore | 8 -------- .prettierrc | 3 --- Gruntfile.js | 26 ++++++++++++++++++++++++++ package.json | 7 +------ 6 files changed, 41 insertions(+), 17 deletions(-) create mode 100644 .eslintignore create mode 100644 .eslintrc.json delete mode 100644 .prettierignore delete mode 100644 .prettierrc create mode 100644 Gruntfile.js diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 00000000..5c8483cd --- /dev/null +++ b/.eslintignore @@ -0,0 +1,7 @@ +# Build +/vendor/ +/coverage/ +# Language files written automatically by TranslateWiki +/i18n/**/*.json +!/i18n/**/en.json +!/i18n/**/qqq.json diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 00000000..6acf3068 --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,7 @@ +{ + "root": true, + "extends": [ + "wikimedia/server", + "wikimedia/mediawiki" + ] +} diff --git a/.prettierignore b/.prettierignore deleted file mode 100644 index d5eaf07d..00000000 --- a/.prettierignore +++ /dev/null @@ -1,8 +0,0 @@ -# composer dependencies -/vendor/ -/composer.lock - -# maintained by translatewiki -/i18n/ - -*.svg diff --git a/.prettierrc b/.prettierrc deleted file mode 100644 index 544138be..00000000 --- a/.prettierrc +++ /dev/null @@ -1,3 +0,0 @@ -{ - "singleQuote": true -} diff --git a/Gruntfile.js b/Gruntfile.js new file mode 100644 index 00000000..0006157c --- /dev/null +++ b/Gruntfile.js @@ -0,0 +1,26 @@ +'use strict'; +module.exports = function ( grunt ) { + const 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, + fix: grunt.option( 'fix' ) + }, + all: '.' + }, + stylelint: { + all: [ + '**/*.{css,less}', + '!node_modules/**', + '!vendor/**' + ] + }, + banana: conf.MessagesDirs + } ); + grunt.registerTask( 'test', [ 'eslint', 'stylelint', 'banana' ] ); + grunt.registerTask( 'default', 'test' ); +}; diff --git a/package.json b/package.json index 8cbe0a21..62eef8f2 100644 --- a/package.json +++ b/package.json @@ -3,24 +3,19 @@ "description": "Let users handle sanctions.", "private": true, "scripts": { - "test": "npm -s run lint", - "lint": "npm -s run lint:prettier && npm -s run lint:i18n", - "lint:prettier": "prettier '**/*.{js,json,css,less,md,yml}' --check", + "test": "grunt test", "lint:i18n": "banana-checker --requireLowerCase=0 i18n/", - "fix": "prettier '**/*.{js,json,css,less,md,yml}' --write", "minify-svg": "svgo --config=.svgo.config.js -q -r -f modules/visualeditor/ui/images/", "selenium-daily": "npm run selenium-test", "selenium-test": "wdio tests/selenium/wdio.conf.js" }, "devDependencies": { - "@prettier/plugin-xml": "^2.2.0", "@wdio/cli": "^7.29.1", "@wdio/dot-reporter": "^7.25.1", "@wdio/junit-reporter": "^7.26.0", "@wdio/local-runner": "^7.20.9", "@wdio/mocha-framework": "^7.24.1", "grunt-banana-checker": "^0.10.0", - "prettier": "^2.8.1", "svgo": "^2.3.1", "wdio-mediawiki": "^2.2.0" }