Skip to content
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

chore: add automatic formatting #110

Closed
wants to merge 2 commits into from
Closed
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
15 changes: 15 additions & 0 deletions .github/workflows/code-checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Code Style

on:
push:
branches: [master]
pull_request:
branches: [master]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Check code formatting
run: npx prettier . --check
7 changes: 3 additions & 4 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@ name: Node.js CI

on:
push:
branches: [ master ]
branches: [master]
pull_request:
branches: [ master ]
branches: [master]

jobs:
build:

runs-on: ubuntu-latest

strategy:
Expand All @@ -26,4 +25,4 @@ jobs:
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm run build --if-present
- run: npm run build --if-present
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules/**
build/**
src/data/**
11 changes: 11 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"printWidth": 120,
"tabWidth": 2,
"semi": false,
"singleQuote": true,
"quoteProps": "as-needed",
"trailingComma": "all",
"bracketSpacing": true,
"arrowParens": "avoid",
"endOfLine": "auto"
}
7 changes: 7 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
// Extension identifier format: ${publisher}.${name}. Example: vscode.csharp

// List of extensions which should be recommended for users of this workspace.
"recommendations": ["esbenp.prettier-vscode"]
}
11 changes: 11 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"json.schemaDownload.enable": true,
"eslint.enable": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
"editor.detectIndentation": false,
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.tabSize": 2
}
2 changes: 1 addition & 1 deletion AUTHORS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Contributors

By adding your name to this document, you agree to release all your contributions to Flix under the [Apache 2.0 License](LICENSE.md).

- [Magnus Madsen](https://github.com/magnus-madsen)
11 changes: 5 additions & 6 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
Apache License
==============
# Apache License

_Version 2.0, January 2004_
_&lt;<http://www.apache.org/licenses/>&gt;_
Expand Down Expand Up @@ -89,15 +88,15 @@ You may reproduce and distribute copies of the Work or Derivative Works thereof
in any medium, with or without modifications, and in Source or Object form,
provided that You meet the following conditions:

* **(a)** You must give any other recipients of the Work or Derivative Works a copy of
- **(a)** You must give any other recipients of the Work or Derivative Works a copy of
this License; and
* **(b)** You must cause any modified files to carry prominent notices stating that You
- **(b)** You must cause any modified files to carry prominent notices stating that You
changed the files; and
* **(c)** You must retain, in the Source form of any Derivative Works that You distribute,
- **(c)** You must retain, in the Source form of any Derivative Works that You distribute,
all copyright, patent, trademark, and attribution notices from the Source form
of the Work, excluding those notices that do not pertain to any part of the
Derivative Works; and
* **(d)** If the Work includes a “NOTICE” text file as part of its distribution, then any
- **(d)** If the Work includes a “NOTICE” text file as part of its distribution, then any
Derivative Works that You distribute must include a readable copy of the
attribution notices contained within such NOTICE file, excluding those notices
that do not pertain to any part of the Derivative Works, in at least one of the
Expand Down
34 changes: 17 additions & 17 deletions build-scripts/main.mjs
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
import fs from "fs";
import fs from 'fs'

import { sampleFiles, baseUrl } from "./sampleFiles.mjs";
import { sampleFiles, baseUrl } from './sampleFiles.mjs'

async function fetchSamples(baseUrl, files) {
return await Promise.all(
files.map(async sample => {
const response = await fetch(baseUrl + sample.file);
const code = await response.text();
return await Promise.all(
files.map(async sample => {
const response = await fetch(baseUrl + sample.file)
const code = await response.text()

return {
name: sample.name,
code,
};
})
);
return {
name: sample.name,
code,
}
}),
)
}

const samples = await fetchSamples(baseUrl, sampleFiles);
const objString = JSON.stringify(samples);
const samples = await fetchSamples(baseUrl, sampleFiles)
const objString = JSON.stringify(samples)
const fileString = `
// This file is generated by build-scripts/main.mjs
/* eslint-disable */
export default ${objString};
`;
`

// The file is placed in the src directory to include it in the bundle
fs.mkdirSync("./src/data", { recursive: true });
fs.writeFileSync("./src/data/Samples.js", fileString);
fs.mkdirSync('./src/data', { recursive: true })
fs.writeFileSync('./src/data/Samples.js', fileString)
230 changes: 115 additions & 115 deletions build-scripts/sampleFiles.mjs
Original file line number Diff line number Diff line change
@@ -1,116 +1,116 @@
const version = "0.38.0";
export const baseUrl = `https://raw.githubusercontent.com/flix/flix/v${version}/examples/`;
const version = '0.38.0'
export const baseUrl = `https://raw.githubusercontent.com/flix/flix/v${version}/examples/`
export const sampleFiles = [
{
name: "Algebraic Data Types and Pattern Matching",
file: "algebraic-data-types-and-pattern-matching.flix",
},
{
name: "Lists and List Processing",
file: "lists-and-list-processing.flix",
},
{
name: "Higher-Order Functions",
file: "higher-order-functions.flix",
},
{
name: "Enums and Parametric Polymorphism",
file: "enums-and-parametric-polymorphism.flix",
},
{
name: "Record Construction and Use",
file: "record-construction-and-use.flix",
},
{
name: "Polymorphic Record Update",
file: "polymorphic-record-update.flix",
},
{
name: "Polymorphic Record Extension and Restriction",
file: "polymorphic-record-extension-and-restriction.flix",
},
{
name: "Function Composition, Pipelines, and Currying",
file: "function-composition-pipelines-and-currying.flix",
},
{
name: "Pure and Impure Functions",
file: "pure-and-impure-functions.flix",
},
{
name: "Effect Polymorphic Functions",
file: "effect-polymorphic-functions.flix",
},
{
name: "Type Aliases",
file: "type-aliases.flix",
},
{
name: "Mutual Recursion with Full Tail-Call Elimination",
file: "mutual-recursion-with-full-tail-call-elimination.flix",
},
{
name: "Sending and Receiving on Channels",
file: "sending-and-receiving-on-channels.flix",
},
{
name: "Using Channels and Select",
file: "using-channels-and-select.flix",
},
{
name: "Select with Defaults and Timers",
file: "select-with-defaults-and-timers.flix",
},
{
name: "First-Class Constraints and Fixpoints",
file: "first-class-constraints-and-fixpoints.flix",
},
{
name: "Polymorphic First-Class Constraints",
file: "polymorphic-first-class-constraints.flix",
},
{
name: "Pipelines of Fixpoint Computations",
file: "pipelines-of-fixpoint-computations.flix",
},
{
name: "Using Datalog to Solve a Compiler Puzzle",
file: "compiler-puzzle.flix",
},
{
name: "An Interpreter for a Trivial Expression Language",
file: "an-interpreter-for-a-trivial-expression-language.flix",
},
{
name: "A Simple Card Game Simulation",
file: "simple-card-game.flix",
},
{
name: "Deriving Type Classes",
file: "deriving-type-classes.flix",
},
{
name: "Internal Mutability with Regions",
file: "internal-mutability-with-regions.flix",
},
{
name: "File Information",
file: "file-information.flix",
},
{
name: "Working with Files and Directories",
file: "working-with-files-and-directories.flix",
},
{
name: "Using Laziness for Infinite Streams",
file: "using-laziness-for-infinite-streams.flix",
},
{
name: "Using Laziness for Logging",
file: "using-laziness-for-logging.flix",
},
{
name: "Using Laziness to Compute Fibonacci",
file: "using-laziness-to-compute-fibonacci.flix",
}
];
{
name: 'Algebraic Data Types and Pattern Matching',
file: 'algebraic-data-types-and-pattern-matching.flix',
},
{
name: 'Lists and List Processing',
file: 'lists-and-list-processing.flix',
},
{
name: 'Higher-Order Functions',
file: 'higher-order-functions.flix',
},
{
name: 'Enums and Parametric Polymorphism',
file: 'enums-and-parametric-polymorphism.flix',
},
{
name: 'Record Construction and Use',
file: 'record-construction-and-use.flix',
},
{
name: 'Polymorphic Record Update',
file: 'polymorphic-record-update.flix',
},
{
name: 'Polymorphic Record Extension and Restriction',
file: 'polymorphic-record-extension-and-restriction.flix',
},
{
name: 'Function Composition, Pipelines, and Currying',
file: 'function-composition-pipelines-and-currying.flix',
},
{
name: 'Pure and Impure Functions',
file: 'pure-and-impure-functions.flix',
},
{
name: 'Effect Polymorphic Functions',
file: 'effect-polymorphic-functions.flix',
},
{
name: 'Type Aliases',
file: 'type-aliases.flix',
},
{
name: 'Mutual Recursion with Full Tail-Call Elimination',
file: 'mutual-recursion-with-full-tail-call-elimination.flix',
},
{
name: 'Sending and Receiving on Channels',
file: 'sending-and-receiving-on-channels.flix',
},
{
name: 'Using Channels and Select',
file: 'using-channels-and-select.flix',
},
{
name: 'Select with Defaults and Timers',
file: 'select-with-defaults-and-timers.flix',
},
{
name: 'First-Class Constraints and Fixpoints',
file: 'first-class-constraints-and-fixpoints.flix',
},
{
name: 'Polymorphic First-Class Constraints',
file: 'polymorphic-first-class-constraints.flix',
},
{
name: 'Pipelines of Fixpoint Computations',
file: 'pipelines-of-fixpoint-computations.flix',
},
{
name: 'Using Datalog to Solve a Compiler Puzzle',
file: 'compiler-puzzle.flix',
},
{
name: 'An Interpreter for a Trivial Expression Language',
file: 'an-interpreter-for-a-trivial-expression-language.flix',
},
{
name: 'A Simple Card Game Simulation',
file: 'simple-card-game.flix',
},
{
name: 'Deriving Type Classes',
file: 'deriving-type-classes.flix',
},
{
name: 'Internal Mutability with Regions',
file: 'internal-mutability-with-regions.flix',
},
{
name: 'File Information',
file: 'file-information.flix',
},
{
name: 'Working with Files and Directories',
file: 'working-with-files-and-directories.flix',
},
{
name: 'Using Laziness for Infinite Streams',
file: 'using-laziness-for-infinite-streams.flix',
},
{
name: 'Using Laziness for Logging',
file: 'using-laziness-for-logging.flix',
},
{
name: 'Using Laziness to Compute Fibonacci',
file: 'using-laziness-to-compute-fibonacci.flix',
},
]
Loading
Loading