Skip to content

Create LICENSE #22

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 34 additions & 34 deletions .appends/.github/labels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,50 +3,50 @@
# https://github.com/exercism/org-wide-files/blob/main/global-files/.github/labels.yml. #
# ----------------------------------------------------------------------------------------- #

- name: "bug :bug:"
- name: 'bug :bug:'
description: "Something isn't working"
color: "b60205"
color: 'b60205'

- name: "chore :wrench:"
description: "Meta related task such as build, test, linting, maintainers.json etc."
color: "000000"
- name: 'chore :wrench:'
description: 'Meta related task such as build, test, linting, maintainers.json etc.'
color: '000000'

- name: "documentation :book:"
description: "Improvements or additions to documentation"
color: "1d76db"
- name: 'documentation :book:'
description: 'Improvements or additions to documentation'
color: '1d76db'

- name: "duplicate :repeat:"
description: "This issue or pull request already exists"
color: "FFFFFF"
- name: 'duplicate :repeat:'
description: 'This issue or pull request already exists'
color: 'FFFFFF'

- name: "enhancement :unicorn:"
description: "New feature or request"
color: "a2eeef"
- name: 'enhancement :unicorn:'
description: 'New feature or request'
color: 'a2eeef'

- name: "experimental :microscope:"
description: "Speculative functionality or implementation"
color: "b60205"
- name: 'experimental :microscope:'
description: 'Speculative functionality or implementation'
color: 'b60205'

- name: "good first issue"
description: "Good for newcomers"
color: "680a9b"
- name: 'good first issue'
description: 'Good for newcomers'
color: '680a9b'

- name: "help wanted"
description: "Extra attention is needed"
color: "680a9b"
- name: 'help wanted'
description: 'Extra attention is needed'
color: '680a9b'

- name: "invalid"
- name: 'invalid'
description: "This doesn't seem right"
color: "ffffff"
color: 'ffffff'

- name: "question :thinking:"
description: "Further information is requested"
color: "000000"
- name: 'question :thinking:'
description: 'Further information is requested'
color: '000000'

- name: "security :rotating_light:"
description: "Security related issue or change"
color: "b60205"
- name: 'security :rotating_light:'
description: 'Security related issue or change'
color: 'b60205'

- name: "wontfix :no_good_woman:"
description: "This will not be worked on"
color: "ffffff"
- name: 'wontfix :no_good_woman:'
description: 'This will not be worked on'
color: 'ffffff'
2 changes: 0 additions & 2 deletions .github/workflows/format-code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ jobs:

- name: 'Format code'
run: ./bin/format.sh
env:
EXERCISM_PRETTIER_VERSION: '2.2.1'

- name: 'Commit formatted code'
run: |
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/verify-code-formatting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,3 @@ jobs:

- name: 'Verify formatting of all files'
run: ./bin/check-formatting.sh
env:
EXERCISM_PRETTIER_VERSION: '2.2.1'
9 changes: 7 additions & 2 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
/.github/labels.yml
/.github/workflows/sync-labels.yml
/dist
/test/fixtures

# These are org-wide files (https://github.com/exercism/org-wide-files/)
/.github/labels.yml
/.github/workflows/sync-labels.yml

/CODE_OF_CONDUCT.md
/LICENSE
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 0.10.0

- Bump the dependencies
- Add `prettier`

## 0.9.0

- Add `#files()` for `DirectoryInput` and `DirectoryWithConfigInput`
Expand Down
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 Exercism

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
24 changes: 21 additions & 3 deletions bin/check-formatting.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,27 @@
#!/usr/bin/env bash

if [ -z "$EXERCISM_PRETTIER_VERSION" ]; then
echo "This script requires the EXERCISM_PRETTIER_VERSION variable to work."
echo "Please see https://github.com/exercism/v3/blob/master/docs/maintainers/style-guide.md for guidance."
exit 1
echo "Pulling prettier version from package.json"
EXERCISM_PRETTIER_VERSION=$(yarn list --pattern prettier | grep -Po '.*\sprettier@\K.*')
fi

if [ -z "$EXERCISM_PRETTIER_VERSION" ]; then
echo "---------------------------------------------------"
echo "This script requires the EXERCISM_PRETTIER_VERSION variable to work."
echo "Please see https://exercism.org/docs/building/markdown/style-guide for guidance."
echo "---------------------------------------------------"
echo "This is what yarn list reports:"
echo "$(yarn list prettier)"
echo ""
echo "This is the version that can be extracted:"
echo "$(yarn list --pattern prettier | grep -Po '.*\sprettier@\K.*')"
echo ""
echo "These files are found in the repo root:"
echo "$(ls -p | grep -v /)"
echo "---------------------------------------------------"
exit 1
else
echo "Running format with prettier@$EXERCISM_PRETTIER_VERSION"
fi

npx "prettier@$EXERCISM_PRETTIER_VERSION" --check "**/*.{js,jsx,ts,tsx,css,sass,scss,html,json,md,yml}"
24 changes: 21 additions & 3 deletions bin/format.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,27 @@
#!/usr/bin/env bash

if [ -z "$EXERCISM_PRETTIER_VERSION" ]; then
echo "This script requires the EXERCISM_PRETTIER_VERSION variable to work."
echo "Please see https://github.com/exercism/v3/blob/master/docs/maintainers/style-guide.md for guidance."
exit 1
echo "Pulling prettier version from package.json"
EXERCISM_PRETTIER_VERSION=$(yarn list --pattern prettier | grep -Po '.*\sprettier@\K.*')
fi

if [ -z "$EXERCISM_PRETTIER_VERSION" ]; then
echo "---------------------------------------------------"
echo "This script requires the EXERCISM_PRETTIER_VERSION variable to work."
echo "Please see https://exercism.org/docs/building/markdown/style-guide for guidance."
echo "---------------------------------------------------"
echo "This is what yarn list reports:"
echo "$(yarn list prettier)"
echo ""
echo "This is the version that can be extracted:"
echo "$(yarn list --pattern prettier | grep -Po '.*\sprettier@\K.*')"
echo ""
echo "These files are found in the repo root:"
echo "$(ls -p | grep -v /)"
echo "---------------------------------------------------"
exit 1
else
echo "Running format with prettier@$EXERCISM_PRETTIER_VERSION"
fi

npx "prettier@$EXERCISM_PRETTIER_VERSION" --write "**/*.{js,jsx,ts,tsx,css,sass,scss,html,json,md,yml}"
39 changes: 20 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@exercism/static-analysis",
"version": "0.9.0",
"version": "0.10.0",
"description": "Exercism static analysis library for javascript and typescript",
"repository": "https://github.com/SleeplessByte/exercism-static-analysis",
"author": "Derk-Jan Karrenbeld <derk-jan+github@karrenbeld.info>",
Expand All @@ -18,28 +18,29 @@
"test": "jest"
},
"peerDependencies": {
"@typescript-eslint/typescript-estree": "^4.22.0",
"@typescript-eslint/visitor-keys": "^4.22.0"
"@typescript-eslint/typescript-estree": "^4.30.0",
"@typescript-eslint/visitor-keys": "^4.30.0"
},
"devDependencies": {
"@babel/cli": "^7.13.14",
"@babel/core": "^7.13.15",
"@babel/preset-env": "^7.13.15",
"@babel/preset-typescript": "^7.13.0",
"@babel/cli": "^7.15.4",
"@babel/core": "^7.15.5",
"@babel/preset-env": "^7.15.4",
"@babel/preset-typescript": "^7.15.0",
"@tsconfig/recommended": "^1.0.1",
"@types/jest": "^26.0.22",
"@types/node": "^14.14.41",
"@typescript-eslint/eslint-plugin": "^4.22.0",
"@typescript-eslint/parser": "^4.22.0",
"@typescript-eslint/typescript-estree": "^4.22.0",
"babel-jest": "^26.6.3",
"eslint": "^7.24.0",
"eslint-config-prettier": "^8.2.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jest": "^24.3.5",
"jest": "^26.6.3",
"@types/jest": "^27.0.1",
"@types/node": "^14.17.14",
"@typescript-eslint/eslint-plugin": "^4.30.0",
"@typescript-eslint/parser": "^4.30.0",
"@typescript-eslint/typescript-estree": "^4.30.0",
"babel-jest": "^27.1.0",
"eslint": "^7.32.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-import": "^2.24.2",
"eslint-plugin-jest": "^24.4.0",
"jest": "^27.1.0",
"prettier": "^2.3.2",
"rimraf": "^3.0.2",
"typescript": "^4.2.4"
"typescript": "^4.4.2"
},
"dependencies": {},
"files": [
Expand Down
3 changes: 2 additions & 1 deletion src/AstParser.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { parse as parseToTree } from '@typescript-eslint/typescript-estree'
import type { DebugLevel } from '@typescript-eslint/types'
import type { TSESTree } from '@typescript-eslint/typescript-estree'
import type { TSError } from '@typescript-eslint/typescript-estree/dist/node-utils'

import { NoSourceError } from './errors/NoSourceError'
import { ParserError } from './errors/ParserError'
Expand Down Expand Up @@ -131,7 +132,7 @@ export class AstParser {
new ParsedSource(parseToTree(source, this.options), source)
)
} catch (error) {
throw new ParserError(error)
throw new ParserError(error as TSError)
}
}
}
12 changes: 7 additions & 5 deletions src/AstTraverser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,13 @@ export class AstTraverser {
// this was extracted using `[node.type]`, that means that the parameter
// type is correct. This widens the expected type to be a regular node,
// but it's actually node & { type: node.type }
;(onSelector as (
this: AstTraverser,
node: Node,
parent: Node | undefined
) => void).call(this, node, parent)
;(
onSelector as (
this: AstTraverser,
node: Node,
parent: Node | undefined
) => void
).call(this, node, parent)
}

if (this.stopped) {
Expand Down
5 changes: 2 additions & 3 deletions src/guards/is_binary_expression.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ import { AST_NODE_TYPES, TSESTree } from '@typescript-eslint/typescript-estree'
type Node = TSESTree.Node
export type BinaryExpression = TSESTree.BinaryExpression
export type BinaryOperator = BinaryExpression['operator']
export type BinaryExpressionWithOperator<
T extends BinaryOperator
> = BinaryExpression & { operator: T }
export type BinaryExpressionWithOperator<T extends BinaryOperator> =
BinaryExpression & { operator: T }

export function guardBinaryExpression(node: Node): node is BinaryExpression
export function guardBinaryExpression<T extends BinaryOperator>(
Expand Down
5 changes: 2 additions & 3 deletions src/guards/is_variable_declaration_of_kind.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ import { TSESTree, AST_NODE_TYPES } from '@typescript-eslint/typescript-estree'
type Node = TSESTree.Node
export type VariableKind = TSESTree.VariableDeclaration['kind']

export type VariableDeclarationOfKind<
T extends VariableKind
> = TSESTree.VariableDeclaration & { kind: T }
export type VariableDeclarationOfKind<T extends VariableKind> =
TSESTree.VariableDeclaration & { kind: T }

export function guardVariableDeclarationOfKind(
node: Node,
Expand Down
10 changes: 4 additions & 6 deletions src/input/DirectoryInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,10 @@ export class DirectoryInput implements Input {
const files = await this.files(n, preferredExtension)

return await Promise.all(
files.map(
async (file): Promise<string> => {
const [source] = await file.read()
return source
}
)
files.map(async (file): Promise<string> => {
const [source] = await file.read()
return source
})
)
}

Expand Down
3 changes: 2 additions & 1 deletion src/input/Input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ export type TrackOptions = {
export const GLOBAL_TRACK_OPTIONS: TrackOptions = {
fileExtensions: /\.(jsx?|tsx?|mjs)$/,
testFilePattern: /\.spec|test\./,
configurationFilePattern: /(?:babel\.config\.js|jest\.config\.js|\.eslintrc\.js)$/,
configurationFilePattern:
/(?:babel\.config\.js|jest\.config\.js|\.eslintrc\.js)$/,
}

export function getTrackOptions(): TrackOptions {
Expand Down
10 changes: 4 additions & 6 deletions test/__mocks__/fs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,10 @@ fs.promises = {} as typeof fs.promises
// This is a custom function that our tests can use during setup to specify
// what the files on the "mock" filesystem should look like when any of the
// `fs` APIs are used.
let mockFiles: { [dir: string]: { [file: string]: string } } = Object.create(
null
)
let writtenFiles: { [dir: string]: { [file: string]: string } } = Object.create(
null
)
let mockFiles: { [dir: string]: { [file: string]: string } } =
Object.create(null)
let writtenFiles: { [dir: string]: { [file: string]: string } } =
Object.create(null)

class NotMocked extends Error {
public readonly code: string
Expand Down
10 changes: 4 additions & 6 deletions test/extracts/extract_functions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -686,9 +686,8 @@ const collection = {

Klazz.prototype.fn = () => { }`)

const [fn1, fn2, fn3, fn4, fn5, fn6, fn7, ...others] = extractFunctions(
program
)
const [fn1, fn2, fn3, fn4, fn5, fn6, fn7, ...others] =
extractFunctions(program)
expect(others).toHaveLength(0)
expect(fn7).not.toBeUndefined()

Expand All @@ -715,9 +714,8 @@ const collection = {

Klazz.prototype.fn = () => { return () => {} }`)

const [fn1, fn2, fn3, fn4, fn5, fn6, fn7, ...others] = extractFunctions(
program
)
const [fn1, fn2, fn3, fn4, fn5, fn6, fn7, ...others] =
extractFunctions(program)
expect(others).toHaveLength(0)
expect(fn7).not.toBeUndefined()

Expand Down
Loading