Skip to content

Commit

Permalink
Cleanup tests and prettify all source.
Browse files Browse the repository at this point in the history
Added ESLint and Prettier and made the code mostly obey.
This necessitated finally fixing the text OCR in the spec, which turns out to be a matter of making it easy on Tesseract by emitting the text in monospace (since we're really not testing OCR!) here.
  • Loading branch information
IDisposable committed Jan 10, 2023
1 parent 4f6bf1d commit 8a80c31
Show file tree
Hide file tree
Showing 49 changed files with 5,325 additions and 4,369 deletions.
18 changes: 18 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module.exports = {
env: {
browser: true,
es2021: true,
},
extends: 'eslint:recommended',
overrides: [],
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
},
rules: {
'indent': ['error', 4],
'linebreak-style': ['error', 'unix'],
'quotes': ['error', 'single'],
'semi': ['error', 'always'],
},
};
14 changes: 7 additions & 7 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
### Use case: description, code
# Use case: description, code

[jsfiddle](https://jsfiddle.net/IDisposable/emjL1ow8/)

### Expected behavior
## Expected behavior

### Actual behavior (stack traces, console logs etc)
## Actual behavior (stack traces, console logs etc)

### Library version
## Library version

### Browsers
## Browsers

- [ ] Chrome 49+
- [ ] Firefox 45+
- [ ] Chrome 49+
- [ ] Firefox 45+
103 changes: 51 additions & 52 deletions .github/workflows/codeql-analysis-v2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,68 +9,67 @@
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"
name: 'CodeQL'

on:
push:
branches: [ "master" ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ "master" ]
schedule:
- cron: '17 11 * * 1'
push:
branches: ['master']
pull_request:
# The branches below must be a subset of the branches above
branches: ['master']
schedule:
- cron: '17 11 * * 1'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'javascript' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Use only 'java' to analyze code written in Java, Kotlin or both
# Use only 'javascript' to analyze code written in JavaScript, TypeScript or both
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
strategy:
fail-fast: false
matrix:
language: ['javascript']
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Use only 'java' to analyze code written in Java, Kotlin or both
# Use only 'javascript' to analyze code written in JavaScript, TypeScript or both
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support

steps:
- name: Checkout repository
uses: actions/checkout@v3
steps:
- name: Checkout repository
uses: actions/checkout@v3

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.

# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality
# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality

# Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2

# Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2
# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
# If the Autobuild fails above, remove it and uncomment the following three lines.
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.

# If the Autobuild fails above, remove it and uncomment the following three lines.
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
# - run: |
# echo "Run, Build Application using script"
# ./location_of_script_within_repo/buildscript.sh

# - run: |
# echo "Run, Build Application using script"
# ./location_of_script_within_repo/buildscript.sh

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
with:
category: "/language:${{matrix.language}}"
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
with:
category: '/language:${{matrix.language}}'
9 changes: 9 additions & 0 deletions .markdownlink.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"list-marker-space": {
"ul_multi": 3,
"ul_single": 3
},
"ul-indent": {
"indent": 4
}
}
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
test-lib/
dist/
11 changes: 11 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"singleQuote": true,
"semi": true,
"trailingComma": "es5",
"quoteProps": "consistent",
"bracketSpacing": true,
"arrowParens": "always",
"endOfLine": "lf",
"tabWidth": 4,
"printWidth": 90
}
2 changes: 1 addition & 1 deletion .stylelintrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
"rules": {
"indentation": 4
}
}
}
13 changes: 0 additions & 13 deletions .travis.yml

This file was deleted.

25 changes: 12 additions & 13 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,34 @@
module.exports = function(grunt) {

module.exports = function (grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
jshint: {
files: ['Gruntfile.js', 'src/**/*.js', 'spec/**/*.js'],
options: {
jshintrc: true
}
jshintrc: true,
},
},
karma: {
unit: {
configFile: 'karma.conf.js',
background: false,
singleRun: true
}
singleRun: true,
},
},
uglify: {
options: {
banner: '/*! <%= pkg.name %> <%= grunt.template.today("dd-mm-yyyy") %> */\n',
sourceMap: true
sourceMap: true,
},
dist: {
files: {
'dist/<%= pkg.name %>.min.js': ['src/dom-to-image-more.js']
}
}
'dist/<%= pkg.name %>.min.js': ['src/dom-to-image-more.js'],
},
},
},
watch: {
files: ['<%= jshint.files %>'],
tasks: ['test']
}
tasks: ['test'],
},
});

grunt.loadNpmTasks('grunt-contrib-jshint');
Expand All @@ -39,4 +38,4 @@ module.exports = function(grunt) {

grunt.registerTask('test', ['karma']);
grunt.registerTask('default', ['jshint', 'test', 'uglify']);
};
};
Loading

0 comments on commit 8a80c31

Please sign in to comment.