Prepare project

This commit is contained in:
Jakub Jirutka 2019-09-05 21:14:48 +02:00
parent f258556f09
commit b1f3ca8cb7
18 changed files with 5028 additions and 0 deletions

15
.editorconfig Normal file
View file

@ -0,0 +1,15 @@
; http://editorconfig.org
root = true
[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
[patches/*.patch]
end_of_line =
insert_final_newline = false
trim_trailing_whitespace = false

4
.eslintignore Normal file
View file

@ -0,0 +1,4 @@
/.tmp/
/dist/
/lib/
/types/

130
.eslintrc.js Normal file
View file

@ -0,0 +1,130 @@
module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
project: './tsconfig.json',
},
env: {
es6: true,
node: true,
},
settings: {
'import/resolver': {
// Use eslint-import-resolver-typescript to obey "paths" in tsconfig.json.
typescript: {},
},
},
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'standard-with-typescript',
'plugin:import/recommended',
'plugin:import/typescript',
],
rules: {
'comma-dangle': ['error', 'always-multiline'],
// Disable in favour of TypeScript rule.
'func-call-spacing': 'off',
'linebreak-style': ['error', 'unix'],
'lines-between-class-members': 'off',
// Disable in favour of TypeScript rule.
'no-extra-semi': 'off',
'no-multi-spaces': ['warn', {
ignoreEOLComments: true,
}],
'no-multiple-empty-lines': ['warn', {
max: 2,
maxEOF: 1,
maxBOF: 1,
}],
'no-template-curly-in-string': 'off',
'operator-linebreak': ['error', 'before'],
'padded-blocks': ['warn', {
switches: 'never',
}],
'quote-props': ['error', 'consistent-as-needed'],
// Disable in favour of TypeScript rule.
'semi': 'off',
// Import
'import/newline-after-import': 'warn',
'import/order': ['warn', {
'groups': [['builtin', 'external']],
'newlines-between': 'always-and-inside-groups',
}],
// TypeScript
'@typescript-eslint/await-thenable': 'error',
'@typescript-eslint/consistent-type-definitions': ['warn', 'type'],
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-member-accessibility': ['warn', {
accessibility: 'no-public',
overrides: {
parameterProperties: 'off',
},
}],
'@typescript-eslint/func-call-spacing': ['error', 'never'],
'@typescript-eslint/indent': ['error', 2, {
SwitchCase: 1,
VariableDeclarator: 1,
outerIIFEBody: 1,
MemberExpression: 1,
// Changed parameters from 1 to off.
FunctionDeclaration: { parameters: 'off', body: 1 },
// Changed parameters from 1 to off.
FunctionExpression: { parameters: 'off', body: 1 },
// Changed arguments from 1 to off.
CallExpression: { arguments: 'off' },
ArrayExpression: 1,
ObjectExpression: 1,
ImportDeclaration: 1,
// Changed from false to true.
flatTernaryExpressions: true,
ignoreComments: false,
}],
'@typescript-eslint/member-delimiter-style': ['error', {
multiline: { delimiter: 'comma', requireLast: true },
singleline: { delimiter: 'comma', requireLast: false },
}],
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-floating-promises': 'error',
'@typescript-eslint/no-namespace': 'warn',
'@typescript-eslint/no-object-literal-type-assertion': 'off',
'@typescript-eslint/no-parameter-properties': 'off',
'@typescript-eslint/no-require-imports': 'error',
'@typescript-eslint/no-unused-vars': ['error', {
argsIgnorePattern: '^_',
}],
'@typescript-eslint/no-use-before-define': ['error', {
classes: true,
functions: false,
typedefs: false,
variables: true,
}],
'@typescript-eslint/prefer-for-of': 'warn',
'@typescript-eslint/prefer-includes': 'warn',
'@typescript-eslint/prefer-interface': 'off',
'@typescript-eslint/prefer-string-starts-ends-with': 'warn',
'@typescript-eslint/promise-function-async': ['error', {
allowAny: true,
}],
'@typescript-eslint/semi': ['error', 'never'],
},
overrides: [
{
files: ['*.test.ts'],
rules: {
// Allow to format arrays for parametrized tests as tables.
'array-bracket-spacing': 'off',
'comma-spacing': 'off',
'no-multi-spaces': 'off',
'standard/array-bracket-even-spacing': 'off',
// Allow spaces inside expect( foo ).
'space-in-parens': 'off',
// jest.mock() must be above imports.
'import/first': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
},
},
],
}

7
.gitignore vendored Normal file
View file

@ -0,0 +1,7 @@
/coverage/
/dist/
/lib/
/.*cache/
/.tmp/
node_modules/
*.log

26
.travis.yml Normal file
View file

@ -0,0 +1,26 @@
dist: bionic
language: node_js
node_js:
- '10'
- '12'
- node
cache: yarn
install:
- yarn install
script:
- yarn run build
- yarn run test
- yarn run lint
deploy:
provider: npm
email: jakub@jirutka.cz
api_key:
secure: TODO
skip_cleanup: true
on:
tags: true
node_js: '10'

17
.vscode/extensions.json vendored Normal file
View file

@ -0,0 +1,17 @@
{
// See http://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": [
"dbaeumer.vscode-eslint",
"EditorConfig.EditorConfig",
"gamunu.vscode-yarn",
"Orta.vscode-jest",
"shtian.jest-snippets-standard"
],
// List of extensions recommended by VS Code that should not be recommended for users of this workspace.
"unwantedRecommendations": [
"ms-vscode.vscode-typescript-tslint-plugin"
]
}

15
.vscode/launch.json vendored Normal file
View file

@ -0,0 +1,15 @@
{
// Use IntelliSense to learn about possible Node.js debug attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "attach",
"name": "Attach by Process ID",
"processId": "${command:PickProcess}",
"protocol": "inspector"
}
]
}

22
.vscode/settings.json vendored Normal file
View file

@ -0,0 +1,22 @@
{
"editor.insertSpaces": true,
"editor.tabSize": 2,
"eslint.packageManager": "yarn",
"eslint.validate": [
"javascript",
"typescript"
],
"files.encoding": "utf8",
"files.eol": "\n",
"files.insertFinalNewline": true,
"files.trimTrailingWhitespace": true,
"flow.enabled": false,
"search.exclude": {
"**/node_modules": true,
"**/dist": true
}
}

23
.vscode/tasks.json vendored Normal file
View file

@ -0,0 +1,23 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"type": "yarn",
"task": "build",
"group": {
"kind": "build",
"isDefault": true
}
},
{
"type": "yarn",
"task": "test",
"group": {
"kind": "test",
"isDefault": true
}
}
]
}

21
LICENSE Normal file
View file

@ -0,0 +1,21 @@
The MIT License
Copyright 2019 Jakub Jirutka <jakub@jirutka.cz>.
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.

73
README.adoc Normal file
View file

@ -0,0 +1,73 @@
= Jupyter Notebook to HTML
:npm-name: ipynb2html
:gh-name: jirutka/{npm-name}
:gh-branch: master
:vs-marketplace-uri: https://marketplace.visualstudio.com/items?itemName=
ifdef::env-github[]
image:https://travis-ci.com/{gh-name}.svg?branch={gh-branch}[Build Status, link="https://travis-ci.com/{gh-name}"]
image:https://img.shields.io/npm/v/{npm-name}.svg[npm Version, link="https://www.npmjs.org/package/{npm-name}"]
endif::env-github[]
TODO
== Development
== System Requirements
* https://nodejs.org[NodeJS] 10.13+
* https://yarnpkg.com[yarn] 1.6+ (can be installed using npm)
=== Used Tools
* https://www.typescriptlang.org[TypeScript] the language
* https://yarnpkg.com[yarn] for dependencies management and building
* https://eslint.org[ESLint] for linting JS/TypeScript code
* https://jestjs.io[Jest] for testing
=== How to Start
. Clone this repository:
[source, subs="+attributes"]
git clone git@github.com:{gh-name}.git
. Install Yarn (if you dont have it already):
[source]
npm install -g yarn
. Install all JS dependencies:
[source]
yarn install
. Build the project:
[source]
yarn build
. Run tests:
[source]
yarn test
. Run linter:
[source]
yarn lint
IMPORTANT: Keep in mind that JS sources are located in the directory `src`; directory `lib` contains transpiled code (created after running `yarn build`)!
=== Visual Studio Code
If you use Visual Studio Code, you should install the following extensions:
* link:{vs-marketplace-uri}EditorConfig.EditorConfig[EditorConfig for VS Code]
* link:{vs-marketplace-uri}dbaeumer.vscode-eslint[ESLint]
* link:{vs-marketplace-uri}Orta.vscode-jest[Jest] (and link:{vs-marketplace-uri}shtian.jest-snippets-standard[Jest Snippets Standard Style])
* link:{vs-marketplace-uri}gamunu.vscode-yarn[yarn]
== License
This project is licensed under http://opensource.org/licenses/MIT/[MIT License].
For the full text of the license, see the link:LICENSE[LICENSE] file.

188
jest.config.js Normal file
View file

@ -0,0 +1,188 @@
// For a detailed explanation regarding each configuration property, visit:
// https://jestjs.io/docs/en/configuration.html
module.exports = {
// All imported modules in your tests should be mocked automatically
// automock: false,
// Stop running tests after `n` failures
// bail: 0,
// Respect "browser" field in package.json when resolving modules
// browser: false,
// The directory where Jest should store its cached dependency information
// cacheDirectory: '/tmp/jest_rt',
// Automatically clear mock calls and instances between every test
clearMocks: true,
// Indicates whether the coverage information should be collected while executing the test
// collectCoverage: false,
// An array of glob patterns indicating a set of files for which coverage information should be collected
collectCoverageFrom: [
'<rootDir>/src/**/*.ts',
],
// The directory where Jest should output its coverage files
coverageDirectory: 'coverage',
// An array of regexp pattern strings used to skip coverage collection
// coveragePathIgnorePatterns: [
// '/node_modules/'
// ],
// A list of reporter names that Jest uses when writing coverage reports
// coverageReporters: [
// 'json',
// 'text',
// 'lcov',
// 'clover'
// ],
// An object that configures minimum threshold enforcement for coverage results
// coverageThreshold: null,
// A path to a custom dependency extractor
// dependencyExtractor: null,
// Make calling deprecated APIs throw helpful error messages
// errorOnDeprecated: false,
// Force coverage collection from ignored files using an array of glob patterns
// forceCoverageMatch: [],
// A path to a module which exports an async function that is triggered once before all test suites
// globalSetup: null,
// A path to a module which exports an async function that is triggered once after all test suites
// globalTeardown: null,
// A set of global variables that need to be available in all test environments
// globals: {},
// An array of directory names to be searched recursively up from the requiring module's location
// moduleDirectories: [
// 'node_modules'
// ],
// An array of file extensions your modules use
// moduleFileExtensions: [
// 'js',
// 'json',
// 'jsx',
// 'ts',
// 'tsx',
// 'node'
// ],
// A map from regular expressions to module names that allow to stub out resources with a single module
moduleNameMapper: {
'@/(.*)': '<rootDir>/src/$1',
},
// An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
// modulePathIgnorePatterns: [],
// Activates notifications for test results
// notify: false,
// An enum that specifies notification mode. Requires { notify: true }
// notifyMode: "failure-change",
// A preset that is used as a base for Jest's configuration
preset: 'ts-jest',
// Run tests from one or more projects
// projects: null,
// Use this configuration option to add custom reporters to Jest
// reporters: undefined,
// Automatically reset mock state between every test
// resetMocks: false,
// Reset the module registry before running each individual test
// resetModules: false,
// A path to a custom resolver
// resolver: null,
// Automatically restore mock state between every test
// restoreMocks: false,
// The root directory that Jest should scan for tests and modules within
// rootDir: null,
// A list of paths to directories that Jest should use to search for files in
// roots: [
// '<rootDir>'
// ],
// Allows you to use a custom runner instead of Jest's default test runner
// runner: 'jest-runner',
// The paths to modules that run some code to configure or set up the testing environment before each test
// setupFiles: [],
// A list of paths to modules that run some code to configure or set up the testing framework before each test
// setupFilesAfterEnv: [],
// A list of paths to snapshot serializer modules Jest should use for snapshot testing
// snapshotSerializers: [],
// The test environment that will be used for testing
testEnvironment: 'node',
// Options that will be passed to the testEnvironment
// testEnvironmentOptions: {},
// Adds a location field to test results
// testLocationInResults: false,
// The glob patterns Jest uses to detect test files
testMatch: [
'<rootDir>/test/**/*.test.[jt]s',
],
// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
// testPathIgnorePatterns: [
// '/node_modules/'
// ],
// The regexp pattern or array of patterns that Jest uses to detect test files
// testRegex: [],
// This option allows the use of a custom results processor
// testResultsProcessor: null,
// This option allows use of a custom test runner
// testRunner: 'jasmine2',
// This option sets the URL for the jsdom environment. It is reflected in properties such as location.href
// testURL: 'http://localhost',
// Setting this value to "fake" allows the use of fake timers for functions such as "setTimeout"
// timers: 'real',
// A map from regular expressions to paths to transformers
// transform: null,
// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
// transformIgnorePatterns: [
// '/node_modules/'
// ],
// An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
// unmockedModulePathPatterns: undefined,
// Indicates whether each individual test should be reported during the run
// verbose: null,
// An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode
// watchPathIgnorePatterns: [],
// Whether to use watchman for file crawling
// watchman: true,
}

53
package.json Normal file
View file

@ -0,0 +1,53 @@
{
"name": "ipynb2html",
"version": "0.0.0",
"description": "Convert Jupyter Notebook to static HTML",
"author": "Jakub Jirutka <jakub@jirutka.cz>",
"license": "MIT",
"homepage": "https://github.com/jirutka/ipynb2html",
"bugs": "https://github.com/jirutka/ipynb2html/issues",
"repository": {
"type": "git",
"url": "https://github.com/jirutka/ipynb2html.git"
},
"keywords": [
"converter",
"html",
"ipython",
"jupyter",
"notebook"
],
"main": "lib/index.js",
"files": [
"lib",
"src"
],
"scripts": {
"build": "tsc",
"lint": "eslint 'src/**/*.[jt]s'",
"test": "jest --detectOpenHandles --coverage --verbose",
"watch-ts": "tsc -w"
},
"engines": {
"node": ">=10.13.0"
},
"dependencies": {},
"devDependencies": {
"@types/jest": "^24.0.18",
"@types/node": "^10.13.0",
"@typescript-eslint/eslint-plugin": "^1.13.0",
"@typescript-eslint/parser": "^1.13.0",
"eslint": "^6.2.2",
"eslint-config-standard-with-typescript": "^8.0.0",
"eslint-import-resolver-typescript": "^1.1.1",
"eslint-plugin-import": "^2.18.0",
"eslint-plugin-node": "^9.1.0",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-standard": "^4.0.0",
"jest": "^24.9.0",
"npm-run-all": "^4.1.5",
"ts-jest": "^24.1.0",
"ts-node": "^8.3.0",
"typescript": "~3.5.2"
}
}

1
src/index.ts Normal file
View file

@ -0,0 +1 @@
// TODO

4
test/main.test.ts Normal file
View file

@ -0,0 +1,4 @@
it('1 + 1 should be 2', () => {
expect( 1 + 1 ).toBe(2)
})

5
test/tsconfig.json Normal file
View file

@ -0,0 +1,5 @@
// This file is needed only for VSCode, see https://github.com/palmerhq/tsdx/issues/84.
{
"extends": "../tsconfig.json",
"include": ["."],
}

76
tsconfig.json Normal file
View file

@ -0,0 +1,76 @@
{
"compilerOptions": {
/* Basic Options */
// "incremental": true, /* Enable incremental compilation */
"target": "es2018", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
// "lib": [], /* Specify library files to be included in the compilation. */
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
// "declaration": true, /* Generates corresponding '.d.ts' file. */
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
"sourceMap": true, /* Generates corresponding '.map' file. */
// "outFile": "./", /* Concatenate and emit output to single file. */
"outDir": "./lib", /* Redirect output structure to the directory. */
// "rootDir": ".", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "composite": true, /* Enable project compilation */
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
// "removeComments": true, /* Do not emit comments to output. */
// "noEmit": true, /* Do not emit outputs. */
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
/* Strict Type-Checking Options */
"strict": true, /* Enable all strict type-checking options. */
"noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
"strictNullChecks": true, /* Enable strict null checks. */
"strictFunctionTypes": true, /* Enable strict checking of function types. */
"strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
"strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
"noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
"alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
/* Additional Checks */
// "noUnusedLocals": true, /* Report errors on unused locals. */
// "noUnusedParameters": true, /* Report errors on unused parameters. */
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
/* Module Resolution Options */
"moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
"baseUrl": "./src", /* Base directory to resolve non-absolute module names. */
"paths": { /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
"*": ["../types/*"],
"@/*": ["./*"], /* resolve all modules prefixed with '@/' from 'src' directory */
},
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
"typeRoots": [ /* List of folders to include type definitions from. */
"./types",
"./node_modules/@types"
],
// "types": [], /* Type declaration files to be included in compilation. */
"allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
"resolveJsonModule": true, /* Include modules imported with .json extension. */
/* Source Map Options */
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
/* Experimental Options */
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
},
"include": [
"src",
],
"exclude": [
"node_modules",
]
}

4348
yarn.lock Normal file

File diff suppressed because it is too large Load diff