Skip to content
This repository has been archived by the owner on Oct 20, 2022. It is now read-only.

Commit

Permalink
I figured I might as well convert to TypeScript at this point.
Browse files Browse the repository at this point in the history
  • Loading branch information
aslilac committed Aug 6, 2019
1 parent e3a5671 commit e8f24d6
Show file tree
Hide file tree
Showing 19 changed files with 938 additions and 408 deletions.
19 changes: 14 additions & 5 deletions .eslintrc.yml
@@ -1,8 +1,17 @@
env:
es6: true
parser: babel-eslint
parser: "@typescript-eslint/parser"
parserOptions:
sourceType: module
plugins:
- "@typescript-eslint"
rules:
# General rules
# TypeScript
"@typescript-eslint/no-inferrable-types": error
"@typescript-eslint/no-unused-vars": error
"@typescript-eslint/semi": error
"@typescript-eslint/type-annotation-spacing": error
# General
arrow-body-style: error
arrow-parens:
- error
Expand All @@ -28,7 +37,7 @@ rules:
- TemplateLiteral
keyword-spacing: error
linebreak-style: error
lines-between-class-members: error
# lines-between-class-members: error
max-len:
- warn
- code: 100
Expand Down Expand Up @@ -73,7 +82,7 @@ rules:
no-undefined: error
no-unexpected-multiline: error
no-unreachable: error
no-unused-vars: error
# no-unused-vars: error
no-useless-computed-key: error
no-useless-concat: error
no-useless-escape: error
Expand Down Expand Up @@ -108,7 +117,7 @@ rules:
- allowTemplateLiterals: true
require-await: error
require-yield: error
semi: error
# semi: error
semi-spacing: error
semi-style: error
space-before-function-paren:
Expand Down
19 changes: 13 additions & 6 deletions .gitignore
@@ -1,14 +1,21 @@
# macOS
.DS_Store

# Dependencies
node_modules
.pnp
.pnp.js

# Logs
logs
*.log
npm-debug.log*

# Builds
dist
.rpt2_cache
bad_tests/index.*
bad_tests/**/*.d.ts
dist
doc

# Dependencies
node_modules
.pnp

# Types
lib/*.d.ts
13 changes: 8 additions & 5 deletions README.md
Expand Up @@ -13,7 +13,7 @@ A garden can be used interchangeably with `console`, and works basically
anywhere that JavaScript can run. If you want to add support for an environment that
I don't know about feel free to open an issue!

| <img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/edge/edge_48x48.png" alt="IE / Edge" width="24px" height="24px" /></br>Edge | <img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/firefox/firefox_48x48.png" alt="Firefox" width="24px" height="24px" /></br>Firefox | <img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/chrome/chrome_48x48.png" alt="Chrome" width="24px" height="24px" /></br>Chrome | <img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/safari/safari_48x48.png" alt="Safari" width="24px" height="24px" /></br>Safari | <img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/opera/opera_48x48.png" alt="Opera" width="24px" height="24px" /></br>Opera | <img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/electron/electron_48x48.png" alt="Electron" width="24px" height="24px" /></br>Electron |
| <img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/edge/edge_48x48.png" alt="Edge" width="24px" height="24px" /></br>Edge | <img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/firefox/firefox_48x48.png" alt="Firefox" width="24px" height="24px" /></br>Firefox | <img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/chrome/chrome_48x48.png" alt="Chrome" width="24px" height="24px" /></br>Chrome | <img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/safari/safari_48x48.png" alt="Safari" width="24px" height="24px" /></br>Safari | <img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/opera/opera_48x48.png" alt="Opera" width="24px" height="24px" /></br>Opera | <img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/electron/electron_48x48.png" alt="Electron" width="24px" height="24px" /></br>Electron |
| --------- | --------- | --------- | --------- | --------- | --------- |
- Node.js
- Deno
Expand All @@ -28,6 +28,8 @@ yarn add gardens
You should use Yarn and [pnp](https://yarnpkg.com/en/docs/pnp).

## Usage
- [Documentation](https://gardens.now.sh)

Depending on where you're using Gardens, you might need to do any of the following...
```JavaScript
// CommonJS (Node.js, Electron, React Native)
Expand All @@ -54,10 +56,11 @@ on their usage and why you should use them, read their [documentation](/doc/mana
Configurations can be set per instance, and updated at any time. Each garden
has the following options.

Note: The `scopeStyle` option is used to configure the style of the scope name when printed.
In Node.js it supports the `backgroundColor`, `color`, `fontStyle`, `fontWeight`, and `textDecoration`
CSS properties. Support in browsers should technically be any CSS property, but
the exact support depends on the implementation of the browser itself.
Note: The `scopeStyle` option is used to configure the style of the scope name when
printed. In Node.js and Deno it supports the `backgroundColor`, `color`, `fontStyle`,
`fontWeight`, and `textDecoration` CSS properties. Support in browsers should
technically be any CSS property, but the exact support depends on the implementation
of the browser itself.

```JavaScript
garden.configure({
Expand Down
2 changes: 1 addition & 1 deletion bad_tests/deno.ts
@@ -1,5 +1,5 @@
// import gardens from 'https://deno.land/x/gardens/deno.ts';
import gardens from '../deno.ts';
import tests from './tests.js';
import tests from './tests.ts';

tests( gardens );
24 changes: 19 additions & 5 deletions bad_tests/tests.js → bad_tests/tests.ts
@@ -1,4 +1,4 @@
function wait( ms ) {
function wait( ms: number ) {
return new Promise( fulfill => setTimeout( () => fulfill(), ms ) );
}

Expand All @@ -13,7 +13,7 @@ const obj = {

async function runTest( garden, next ) {
const {
log, info, success, debug, warning, warn, fail,
log, info, success, debug, warning, warn, fail, // pending,
count, countReset, time, timeEnd
} = garden.bound();

Expand All @@ -40,11 +40,24 @@ async function runTest( garden, next ) {
log( 'RegExp:', /hello/ig );
log( 'Object:', obj, 'Boolean:', true );
success( 'Hello champion!' );
debug( 'Hello debug sailor?' );
warning( 'Hello warning!' );
warn( 'Hello warn!' );
fail( 'Oh no!', '\n' );

// await pending( 'Fetching resource', fulfill => {
// setTimeout( fulfill, 1000 );
// });

// try {
// await pending( 'Fetching resource', ( fulfill, reject ) => {
// setTimeout( reject, 300 );
// });
// }
// catch {
// fail( 'Resource failed to load.' );
// }

debug( 'Hello debug sailor?' );
garden.trace( 'This should trace, but only when verbose' );

garden.error( 'This is an error!' );
Expand Down Expand Up @@ -113,7 +126,7 @@ function testGardens( output, ...list ) {
});
}

export default function tests( gardens, options ) {
export default function tests( gardens, options? ) {
const fresh = gardens.createScope( null, options );

const manager = fresh.createManager( 'manager', {
Expand Down Expand Up @@ -143,7 +156,8 @@ export default function tests( gardens, options ) {

const nestedGarden = customGarden.createScope( 'nested', {
scopeStyle: {
color: '#393ac1'
color: '#393ac1',
textDecoration: 'line-through underline'
}
});

Expand Down
6 changes: 3 additions & 3 deletions bad_tests/umd.js → bad_tests/umd.ts
Expand Up @@ -4,10 +4,10 @@ import tests from './tests';
tests( gardens );

if ( typeof document !== 'undefined' ) {
const output = document.getElementById( 'output' );
const container = document.getElementById( 'output' );
const stream = {
write( string ) {
output.innerHTML += string;
write( output: string ) {
container.innerHTML += output;
}
};

Expand Down
127 changes: 0 additions & 127 deletions doc/managers.md

This file was deleted.

2 changes: 1 addition & 1 deletion lib/deno.ts
@@ -1,4 +1,4 @@
import gardens from './garden.js';
import gardens from './garden.ts';

const hex = /^#[0-9a-f]{6}$/i;

Expand Down

0 comments on commit e8f24d6

Please sign in to comment.