Skip to content

Commit

Permalink
feat: init utils
Browse files Browse the repository at this point in the history
  • Loading branch information
v8tenko committed Aug 28, 2024
0 parents commit f4297b4
Show file tree
Hide file tree
Showing 22 changed files with 14,357 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.idea
.vscode
.history
.env
.DS_Store
node_modules
/lib
/dist
/build
/cache
/coverage
8 changes: 8 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
root: true,
extends: require.resolve('@diplodoc/lint/eslint-config'),
parserOptions: {
tsconfigRootDir: __dirname,
project: ['./tsconfig.json'],
},
};
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.idea
.vscode
.history
.env
.DS_Store
node_modules
/lib
/dist
/build
/cache
/coverage
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npm run pre-commit
6 changes: 6 additions & 0 deletions .lintstagedrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
'**/*.{js,mjs,cjs,jsx,ts,mts,cts,tsx}': ['prettier --write', 'eslint --max-warnings=0 --fix'],
'**/*.{css,scss}': ['prettier --write', 'stylelint --fix'],
'**/*.{json,yaml,yml,md}': ['prettier --write'],
'**/*.{svg,svgx}': ['svgo'],
};
11 changes: 11 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.idea
.vscode
.history
.env
.DS_Store
node_modules
/lib
/dist
/build
/cache
/coverage
1 change: 1 addition & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('@diplodoc/lint/prettier-config');
11 changes: 11 additions & 0 deletions .stylelintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.idea
.vscode
.history
.env
.DS_Store
node_modules
/lib
/dist
/build
/cache
/coverage
3 changes: 3 additions & 0 deletions .stylelintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
extends: require.resolve('@diplodoc/lint/stylelint-config'),
};
Empty file added CONTRIBUTING.md
Empty file.
21 changes: 21 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2022 YANDEX LLC

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.
35 changes: 35 additions & 0 deletions README.MD
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Diplodoc utils

[![NPM version](https://img.shields.io/npm/v/@diplodoc/utils.svg?style=flat)](https://www.npmjs.org/package/@diplodoc/utils)

Diplodoc cross-packages utils.

## Motivation

The Diplodoc ecosystem consists of many packages that have similar problems and needs. This package will contain all the general logic that is duplicated in our code base.

## Table of contents

### AttrsParser

### Purpose

Support [markdown-it-attrs](https://github.com/arve0/markdown-it-attrs)-like attributes parser. Used in custom Diplodoc MarkdownIt plugins to add classes and anchors, enabling subsequent customization through CSS.

### Interface

```typescript
/*
optional first query
if provided parser will parse it imminently
each 'parse' call is pure
*/
const attrs = new AttrsParser('{.class #id data-name=diplodoc}');

attrs.state /* { class: ['class'], id: ['id'], 'data-name': ['diplodoc'] } */

const other = attrs.parse('{data-wide title="Support quotes too"}')

other /* { attr: ['data-wide'], title: ['Support quotes too'] }
```
14 changes: 14 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const path = require('path');

/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
module.exports = {
testEnvironment: 'node',
transform: {
'^.+\\.tsx?$': ['esbuild-jest', {tsconfig: './tsconfig.json'}],
},
moduleNameMapper: {
'^src/(.*)': '<rootDir>/src/$1',
'^__tests__/(.*)': '<rootDir>/__tests__/$1',
},
testPathIgnorePatterns: [`.*__fixtures__${path.sep}.*`, `.*__helpers__${path.sep}.*`],
};
Loading

0 comments on commit f4297b4

Please sign in to comment.