Skip to content

Commit

Permalink
(tests) Add eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
edwardspec committed Dec 7, 2024
1 parent 1831f9a commit f1e2678
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 1 deletion.
16 changes: 16 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
3 changes: 2 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
vendor
node_modules
.eslintcache

6 changes: 6 additions & 0 deletions .stylelintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "stylelint-config-wikimedia",
"rules": {
"selector-max-id": null
}
}
30 changes: 30 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -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' );
};
14 changes: 14 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -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"
}
}

0 comments on commit f1e2678

Please sign in to comment.