From b545f776413acc26b1a9cc816fa62e5acf5001e7 Mon Sep 17 00:00:00 2001 From: Arctic Ice Studio Date: Fri, 2 Apr 2021 14:00:20 +0200 Subject: [PATCH] Monorepo with Remark packages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit >> Previous Project State Before the repository only contained the actual style guide documentation while specific projects that implement the guidelines for linters and code style analyzer live in separate repositories. This was the best approach for modularity and a small and clear code base, but it increases the maintenance overhead by 1(n) since changes to the development workflow or toolbox, general project documentations as well as dependency management requires changes in every repository with dedicated tickets/issues and PRs. In particular, Node packages require frequent dependency management due to their fast development cycles to keep up-to-date with the latest package changes like (security) bug fixes. This style guide is currently implemented by the remark-preset-lint-arcticicestudio [1] Node package that lived in its own repository. The development workflow was clean using most of GitHub's awesome features like project boards, codeowner assignments, issue & PR automation and so on, but changes often require multiple actions when packages depend on each other or they use the same development tooling and documentation standards. >>> Monorepo Comparison Monorepos [2] are a fantastic way to manage such a project structure, but there are also some points that must be taken into account: - No more scoped code - the developer experience with Git is slightly worse because commits can contains changes to multiple scopes of the code. Since there is only a "transparent separation” of code, that was previously located in a dedicated repository but is not aggregated into a parent (e.g. `packages`) with other modules, commits can now contain changes to multiple code scopes spread over the entire code base. - No more assignment of commits to single modules - like described in the bullet point above, commit can contain changes to multiple modules, it is harder to detect which commit targeted a specific module. - Steeper learning curve for new contributors - in a dedicated repository that only hosts a specific module it is easier for new developers to contribute to the project, but in a monorepo they might need to change code in multiple places within other modules or the root code/documentation of the entire project. - Uniform version number - in order to keep conform to SemVer [3], the entire project must use a uniform version number. This means that a module that has not been changed since the last version must also be incremented in order to keep compatible with the other modules. Using different version numbers prefixed/suffixed with an individual version number is a not an option, increases the maintenance overhead and and drastically reduces the project overview and quality! This would result in multiple Git tags on the `main` branch as well as "empty” changelogs and release notes with placeholder logs that only refer to changes of other modules. >> Project Future Even though a monorepo requires some special thoughts, it also comes with a lot of benefits and makes sense for specific project modules that are slightly coupled and where using dedicated repositories only increases the maintenance overhead when changes must be reflected in multiple modules anyway. In order to reduce the maintenance overhead, the remark-preset-lint-arcticicestudio [1] Node package has been migrated into this repository by adapting to Yarn workspaces [4]. This simplifies the development tooling setup and allows to use a unified documentation base as well as a smoother development and testing workflow. This change also implies that the root of the repository is now the main package for the entire project setup including shared development dependencies, tools and documentations while the packages only contain specific configurations and (dev)dependencies. >>> Scoped Packages Before the remark-preset-lint-arcticicestudio [1] package was not a scoped package [5] but suffixed with `-arcticicestudio`. To simplify the naming and improving the usage of user/organization specific packages, it is now scoped to `@arcticicestudio` resulting in the new name `@arcticicestudio/remark-preset-lint`. The currently released public version will be deprecated using the `npm deprecate` command [6] where the provided message will point out to migrate to the new scoped packages. >>> Versioning The style guide itself and all packages now use a shared/fixed/locked version. This helps all packages to keep in sync and ensure the compatibility with the latest style guide version. [1]: https://github.com/arcticicestudio/remark-preset-lint-arcticicestudio [2]: https://trunkbaseddevelopment.com/monorepos [3]: https://semver.org [4]: https://yarnpkg.com/en/docs/workspaces [5]: https://docs.npmjs.com/about-scopes [6]: https://docs.npmjs.com/cli/deprecate Co-authored-by: Sven Greb GH-10 --- package.json | 13 +- .../remark-preset-lint/README.md | 126 ++++++++++++++++++ .../remark-preset-lint/index.js | 36 +++++ .../remark-preset-lint/package.json | 105 +++++++++++++++ .../remark-preset-lint/rules/blockquotes.js | 34 +++++ .../remark-preset-lint/rules/code.js | 50 +++++++ .../remark-preset-lint/rules/emphasis.js | 53 ++++++++ .../remark-preset-lint/rules/headings.js | 102 ++++++++++++++ .../rules/horizontal-rules.js | 26 ++++ .../remark-preset-lint/rules/links.js | 111 +++++++++++++++ .../remark-preset-lint/rules/lists.js | 92 +++++++++++++ .../rules/naming-conventions.js | 62 +++++++++ .../remark-preset-lint/rules/paragraphs.js | 26 ++++ .../remark-preset-lint/rules/raw-html.js | 25 ++++ .../remark-preset-lint/rules/strings.js | 26 ++++ .../remark-preset-lint/rules/support.js | 27 ++++ .../remark-preset-lint/rules/tables.js | 51 +++++++ .../remark-preset-lint/rules/whitespace.js | 74 ++++++++++ 18 files changed, 1031 insertions(+), 8 deletions(-) create mode 100644 packages/@arcticicestudio/remark-preset-lint/README.md create mode 100644 packages/@arcticicestudio/remark-preset-lint/index.js create mode 100644 packages/@arcticicestudio/remark-preset-lint/package.json create mode 100644 packages/@arcticicestudio/remark-preset-lint/rules/blockquotes.js create mode 100644 packages/@arcticicestudio/remark-preset-lint/rules/code.js create mode 100644 packages/@arcticicestudio/remark-preset-lint/rules/emphasis.js create mode 100644 packages/@arcticicestudio/remark-preset-lint/rules/headings.js create mode 100644 packages/@arcticicestudio/remark-preset-lint/rules/horizontal-rules.js create mode 100644 packages/@arcticicestudio/remark-preset-lint/rules/links.js create mode 100644 packages/@arcticicestudio/remark-preset-lint/rules/lists.js create mode 100644 packages/@arcticicestudio/remark-preset-lint/rules/naming-conventions.js create mode 100644 packages/@arcticicestudio/remark-preset-lint/rules/paragraphs.js create mode 100644 packages/@arcticicestudio/remark-preset-lint/rules/raw-html.js create mode 100644 packages/@arcticicestudio/remark-preset-lint/rules/strings.js create mode 100644 packages/@arcticicestudio/remark-preset-lint/rules/support.js create mode 100644 packages/@arcticicestudio/remark-preset-lint/rules/tables.js create mode 100644 packages/@arcticicestudio/remark-preset-lint/rules/whitespace.js diff --git a/package.json b/package.json index 223270d..f9b401d 100644 --- a/package.json +++ b/package.json @@ -1,13 +1,8 @@ { "name": "styleguide-markdown", - "title": "Styleguide Markdown", "version": "0.2.0", - "description": "The Arctic Ice Studio Markdown Code Style.", - "author": { - "name": "Arctic Ice Studio", - "email": "development@arcticicestudio.com", - "url": "http://arcticicestudio.com" - }, + "description": "Arctic Ice Studio Markdown code style", + "author": "Arctic Ice Studio (https://www.arcticicestudio.com)", "homepage": "https://arcticicestudio.github.io/styleguide-markdown", "repository": { "type": "git", @@ -25,7 +20,9 @@ "config", "preset" ], - "private": true, + "workspaces": [ + "packages/@arcticicestudio/*" + ], "scripts": { "clean": "del build", "docs:build": "gitbook install src && gitbook build src build/docs", diff --git a/packages/@arcticicestudio/remark-preset-lint/README.md b/packages/@arcticicestudio/remark-preset-lint/README.md new file mode 100644 index 0000000..bcd4e0b --- /dev/null +++ b/packages/@arcticicestudio/remark-preset-lint/README.md @@ -0,0 +1,126 @@ +

+ +

The Arctic Ice Studio Markdown code style guide rules as an extensible remark-lint rule preset.

+ +

+ +

+ +

+ + +This project implements the rules of the [“Arctic Ice Studio Markdown Style Guide”][gh-arcticicestudio/styleguide-markdown] as an extensible [remark-lint][gh-remarkjs/remark-lint] rule preset. +The package supports all [official core rules][gh-remarkjs/remark-lint-blob-docs-rules] and [various plugins][gh-remarkjs/remark-blob-docs-plugins] like the [“frontmatter” Markdown extension][gh-remarkjs/remark-frontmatter] for [YAML][] and [TOML][gh-toml-lang/toml] and [“GitHub Flavoured“ Markdown][gh-remarkjs/remark-gfm]. + +## Getting Started + +Note that this project uses [npm version 7.7.0 or higher][gh-blog-npm_v7] as the main package manager, but the documentations also include instructions to work with [Yarn][yarn-classic] (classic / `v1`). + +### Installation + +Add the package as development dependency to your project: + +```sh +# With npm... +npm install --save-dev @arcticicestudio/remark-preset-lint + +# or Yarn. +yarn add --dev @arcticicestudio/remark-preset-lint +``` + +Note that [peer dependencies][node-blog-peer_deps], like the [remark-lint][gh-remarkjs/remark-lint] package itself, are **only installed automatically when using a npm version equal or higher than `7.0.0`**, otherwise they must be installed separately like described in the [peer dependencies](#peer-dependencies) section below. +See the [Node distribution index][node-dist-index] for more information about which npm version is bundled with which Node version. + +#### Peer Dependencies + +This package depends on [various remark-lint rule packages][gh-remarkjs/remark-lint-tree-pkgs] that are defined as [peer dependencies][node-blog-peer_deps]. + +##### npm versions `>=7.0.0` + +As of **npm version `7.0.0`, peer dependencies are** [**installed automatically**][gh-npm/rfcs-blob-install_peer_deps] and does not require any additional steps. + +##### npm versions `>=5.0.0 <7.0.0` + +For **npm version equal to or higher than `5.0.0` (pre-bundled with [Node.js 8][node-dist-v8-latest]) but less than `7.0.0`**, all peer dependencies can be auto-installed using the pre-bundled [`npx`][npm-npx] package: + +```sh +npx install-peerdeps --dev @arcticicestudio/remark-preset-lint +``` +##### npm versions `<5.0.0` + +If you’re using a **npm version less than `5.0.0`**, the `npx` package is not pre-bundled, but users can either simply install the [`npx`][npm-npx] package globally to run the above command or use the [install-peerdeps][npm-install-peerdeps] helper package locally/globally to let it handle the installation of all peer dependencies: + +```sh +# Install and use the "install-peerdeps" helper package locally... +npm install install-peerdeps +./node_modules/.bin/install-peerdeps --dev @arcticicestudio/remark-preset-lint + +# ...or globally. +npm install --global install-peerdeps +install-peerdeps --dev @arcticicestudio/remark-preset-lint +``` + +To install all peer dependencies manually without `npx` or any helper package, the npm `info` command can be used to get a list of all packages and their versions: + +```sh +# List the names and versions of all peer dependencies... +npm info "@arcticicestudio/remark-preset-lint" peerDependencies + +# ...and install each listed package manually. +npm install PACKAGE@VERSION +``` + +##### Using Yarn instead of npm + +If you’re not using npm but Yarn, peer dependencies can be installed by either adding them manually or using the [install-peerdeps][npm-install-peerdeps] helper package: + +```sh +# Either add all packages manually by listing all required names and their versions and install them manually... +yarn info @arcticicestudio/remark-preset-lint peerDependencies +yarn add --dev remark-lint #... + +# ...or use the "install-peerdeps" helper package. +yarn add --dev install-peerdeps +yarn run install-peerdeps --dev @arcticicestudio/remark-preset-lint +``` + +## Usage + +The package can be used as rule preset by adding it to the plugins within your `.remarkrc.js` or `.remarkrc` [configuration file][remark-lint-doc-conf]: + +```js +module.exports = { + plugins: ["@arcticicestudio/remark-preset-lint"], +}; +``` + +## Contributing + +Please read the [contribution guidelines][ghio-arcticicestudio/styleguide-markdown-dev-contributing] of the [“Arctic Ice Studio Markdown Style Guide”][gh-arcticicestudio/styleguide-markdown] for more details. + +

+ +

Copyright © 2018-present Arctic Ice Studio and Sven Greb

+ +

+ +[gh-arcticicestudio/styleguide-markdown]: https://github.com/arcticicestudio/styleguide-markdown +[gh-remarkjs/remark-lint]: https://github.com/remarkjs/remark-lint +[gh-remarkjs/remark-frontmatter]: https://github.com/remarkjs/remark-frontmatter +[gh-remarkjs/remark-gfm]: https://github.com/remarkjs/remark-gfm +[gh-remarkjs/remark-blob-docs-plugins]: https://github.com/remarkjs/remark/blob/main/doc/plugins.md +[gh-remarkjs/remark-lint-tree-pkgs]: https://github.com/remarkjs/remark-lint/tree/main/packages +[yarn-classic]: https://classic.yarnpkg.com +[gh-blog-npm_v7]: https://github.blog/2020-10-13-presenting-v7-0-0-of-the-npm-cli +[npm]: https://www.npmjs.com +[node-blog-peer_deps]: https://nodejs.org/en/blog/npm/peer-dependencies +[gh-npm/rfcs-blob-install_peer_deps]: https://github.com/npm/rfcs/blob/latest/implemented/0025-install-peer-deps.md +[npm-install-peerdeps]: https://www.npmjs.com/package/install-peerdeps +[node-dist-v8-latest]: https://nodejs.org/dist/latest-v8.x +[npm-npx]: https://www.npmjs.com/package/npx +[node-dist-index]: https://nodejs.org/dist/index.json +[gh-remarkjs/remark-lint-blob-docs-rules]: https://github.com/remarkjs/remark-lint/blob/main/doc/rules.md#list-of-rules +[gh-toml-lang/toml]: https://github.com/toml-lang/toml +[yaml]: http://yaml.org +[remark-lint-doc-conf]: https://github.com/remarkjs/remark-lint#configuring-remark-lint +[ghio-arcticicestudio/styleguide-markdown-dev-contributing]: https://arcticicestudio.github.io/remark-preset-lint-arcticicestudio/development/contributing.html diff --git a/packages/@arcticicestudio/remark-preset-lint/index.js b/packages/@arcticicestudio/remark-preset-lint/index.js new file mode 100644 index 0000000..1b2d02e --- /dev/null +++ b/packages/@arcticicestudio/remark-preset-lint/index.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2018-present Arctic Ice Studio + * Copyright (c) 2018-present Sven Greb + * This source code is licensed under the MIT license found in the LICENSE file. + */ + +/** + * Arctic Ice Studio Markdown Style Guide rules as an extensible remark-lint rule preset. + * @version 0.3.0 + * @license MIT + * @author Arctic Ice Studio + * @author Sven Greb + * @see https://github.com/remarkjs/remark-lint + * @see https://remark.js.org + * @see https://github.com/remarkjs/remark-lint/blob/master/doc/rules.md#list-of-rules + * @see https://github.com/remarkjs/remark-lint#configuring-remark-lint + */ +module.exports = { + plugins: [ + "remark-lint", + "./rules/blockquotes", + "./rules/code", + "./rules/emphasis", + "./rules/headings", + "./rules/horizontal-rules", + "./rules/links", + "./rules/lists", + "./rules/naming-conventions", + "./rules/paragraphs", + "./rules/raw-html", + "./rules/strings", + "./rules/support", + "./rules/tables", + "./rules/whitespace", + ].map(require.resolve), +}; diff --git a/packages/@arcticicestudio/remark-preset-lint/package.json b/packages/@arcticicestudio/remark-preset-lint/package.json new file mode 100644 index 0000000..d0b4d7f --- /dev/null +++ b/packages/@arcticicestudio/remark-preset-lint/package.json @@ -0,0 +1,105 @@ +{ + "name": "@arcticicestudio/remark-preset-lint", + "version": "0.3.0", + "description": "Arctic Ice Studio Markdown code style guide rules as an extensible remark-lint rule preset", + "author": "Arctic Ice Studio (https://www.arcticicestudio.com)", + "homepage": "https://github.com/arcticicestudio/styleguide-markdown", + "repository": { + "type": "git", + "url": "git+https://github.com/arcticicestudio/styleguide-markdown.git", + "directory": "packages/@arcticicestudio/remark-preset-lint" + }, + "bugs": { + "url": "https://github.com/arcticicestudio/styleguide-markdown/issues" + }, + "license": "MIT", + "keywords": [ + "remark", + "lint", + "preset", + "markdown", + "styleguide", + "codestyle" + ], + "main": "index.js", + "files": [ + "rules", + "index.js" + ], + "publishConfig": { + "access": "public" + }, + "dependencies": { + "remark-frontmatter": "^1.3.0", + "remark-lint": "^6.0.1", + "remark-lint-blockquote-indentation": "^1.0.1", + "remark-lint-checkbox-character-style": "^1.0.1", + "remark-lint-checkbox-content-indent": "^1.0.1", + "remark-lint-code-block-style": "^1.0.1", + "remark-lint-definition-case": "^1.0.1", + "remark-lint-definition-spacing": "^1.0.1", + "remark-lint-emphasis-marker": "^1.0.1", + "remark-lint-fenced-code-flag": "^1.0.1", + "remark-lint-fenced-code-marker": "^1.0.1", + "remark-lint-file-extension": "^1.0.1", + "remark-lint-final-definition": "^1.0.1", + "remark-lint-final-newline": "^1.0.1", + "remark-lint-first-heading-level": "^1.1.1", + "remark-lint-hard-break-spaces": "^1.0.2", + "remark-lint-heading-increment": "^1.0.1", + "remark-lint-heading-style": "^1.0.1", + "remark-lint-linebreak-style": "^1.0.1", + "remark-lint-link-title-style": "^1.0.1", + "remark-lint-list-item-bullet-indent": "^1.0.1", + "remark-lint-list-item-content-indent": "^1.0.1", + "remark-lint-list-item-indent": "^1.0.1", + "remark-lint-list-item-spacing": "^1.1.1", + "remark-lint-maximum-heading-length": "^1.0.1", + "remark-lint-maximum-line-length": "^1.0.2", + "remark-lint-no-auto-link-without-protocol": "^1.0.1", + "remark-lint-no-blockquote-without-marker": "^2.0.1", + "remark-lint-no-consecutive-blank-lines": "^1.0.1", + "remark-lint-no-duplicate-definitions": "^1.0.1", + "remark-lint-no-duplicate-headings": "^1.0.1", + "remark-lint-no-duplicate-headings-in-section": "^1.0.1", + "remark-lint-no-emphasis-as-heading": "^1.0.1", + "remark-lint-no-empty-url": "^1.0.2", + "remark-lint-no-file-name-articles": "^1.0.1", + "remark-lint-no-file-name-consecutive-dashes": "^1.0.1", + "remark-lint-no-file-name-irregular-characters": "^1.0.1", + "remark-lint-no-file-name-mixed-case": "^1.0.1", + "remark-lint-no-file-name-outer-dashes": "^1.0.2", + "remark-lint-no-heading-content-indent": "^1.0.1", + "remark-lint-no-heading-indent": "^1.0.1", + "remark-lint-no-heading-like-paragraph": "^1.0.1", + "remark-lint-no-heading-punctuation": "^1.0.1", + "remark-lint-no-html": "^1.0.1", + "remark-lint-no-inline-padding": "^1.0.1", + "remark-lint-no-literal-urls": "^1.0.1", + "remark-lint-no-missing-blank-lines": "^1.0.1", + "remark-lint-no-multiple-toplevel-headings": "^1.0.1", + "remark-lint-no-paragraph-content-indent": "^1.0.3", + "remark-lint-no-reference-like-url": "^1.0.1", + "remark-lint-no-shell-dollars": "^1.0.1", + "remark-lint-no-shortcut-reference-image": "^1.0.1", + "remark-lint-no-shortcut-reference-link": "^1.0.2", + "remark-lint-no-table-indentation": "^1.0.1", + "remark-lint-no-tabs": "^1.0.1", + "remark-lint-no-undefined-references": "^1.0.1", + "remark-lint-no-unused-definitions": "^1.0.1", + "remark-lint-ordered-list-marker-style": "^1.0.1", + "remark-lint-ordered-list-marker-value": "^1.0.1", + "remark-lint-rule-style": "^1.0.1", + "remark-lint-strong-marker": "^1.0.1", + "remark-lint-table-cell-padding": "^1.0.1", + "remark-lint-table-pipe-alignment": "^1.0.1", + "remark-lint-table-pipes": "^1.0.1", + "remark-lint-unordered-list-marker-style": "^1.0.1" + }, + "devDependencies": { + "remark-cli": "^5.0.0" + }, + "peerDependencies": { + "remark-cli": "^5.0.0" + } +} diff --git a/packages/@arcticicestudio/remark-preset-lint/rules/blockquotes.js b/packages/@arcticicestudio/remark-preset-lint/rules/blockquotes.js new file mode 100644 index 0000000..ca4bb38 --- /dev/null +++ b/packages/@arcticicestudio/remark-preset-lint/rules/blockquotes.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2018-present Arctic Ice Studio + * Copyright (c) 2018-present Sven Greb + * This source code is licensed under the MIT license found in the LICENSE file. + */ + +/** + * Enforce correct indentation for blockquotes. + * + * @see https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-blockquote-indentation + * @see https://arcticicestudio.github.io/styleguide-markdown/rules/blockquotes.html#indentation + */ +const blockquoteIndentation = require("remark-lint-blockquote-indentation"); +/** + * Disallow blank lines without markers ('>') in blockquotes. + * + * @see https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-blockquote-without-marker + * @see https://arcticicestudio.github.io/styleguide-markdown/rules/blockquotes.html#multi-line + */ +const noBlockquoteWithoutMarker = require("remark-lint-no-blockquote-without-marker"); + +/** + * Official remark-lint core rules for blockquote document nodes. + * @author Arctic Ice Studio + * @author Sven Greb + * @since 0.1.0 + * @see https://github.com/remarkjs/remark-lint/blob/master/doc/rules.md#list-of-rules + */ +module.exports = { + plugins: [ + [blockquoteIndentation, ["error", 2]], + [noBlockquoteWithoutMarker, ["warn"]] + ] +}; diff --git a/packages/@arcticicestudio/remark-preset-lint/rules/code.js b/packages/@arcticicestudio/remark-preset-lint/rules/code.js new file mode 100644 index 0000000..fea3816 --- /dev/null +++ b/packages/@arcticicestudio/remark-preset-lint/rules/code.js @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2018-present Arctic Ice Studio + * Copyright (c) 2018-present Sven Greb + * This source code is licensed under the MIT license found in the LICENSE file. + */ + +/** + * Enforce fenced code blocks. + * + * @see https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-code-block-style + * @see https://arcticicestudio.github.io/styleguide-markdown/rules/code.html#blocks + */ +const codeBlockStyle = require("remark-lint-code-block-style"); +/** + * Enforce language syntax flags for fenced code blocks. + * + * @see https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-fenced-code-flag + * @see https://arcticicestudio.github.io/styleguide-markdown/rules/code.html#syntax-highlighting + */ +const fencedCodeFlag = require("remark-lint-fenced-code-flag"); +/** + * Enforce language syntax flags for fenced code blocks. + * + * @see https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-fenced-code-marker + * @see https://arcticicestudio.github.io/styleguide-markdown/rules/code.html#marker-character-style + */ +const fencedCodeMarker = require("remark-lint-fenced-code-marker"); +/** + * Warn when using a dollar sign ("$") in shell code. + * + * @see https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-shell-dollars + * @see https://arcticicestudio.github.io/styleguide-markdown/rules/code.html#no-shell-code-dollar-sign + */ +const noShellDollars = require("remark-lint-no-shell-dollars"); + +/** + * Official remark-lint core rules for code document nodes. + * @author Arctic Ice Studio + * @author Sven Greb + * @since 0.1.0 + * @see https://github.com/remarkjs/remark-lint/blob/master/doc/rules.md#list-of-rules + */ +module.exports = { + plugins: [ + [codeBlockStyle, ["error", "fenced"]], + [fencedCodeFlag, ["error", { allowEmpty: false }]], + [fencedCodeMarker, ["error", "`"]], + [noShellDollars, ["warn"]] + ] +}; diff --git a/packages/@arcticicestudio/remark-preset-lint/rules/emphasis.js b/packages/@arcticicestudio/remark-preset-lint/rules/emphasis.js new file mode 100644 index 0000000..1e40977 --- /dev/null +++ b/packages/@arcticicestudio/remark-preset-lint/rules/emphasis.js @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2018-present Arctic Ice Studio + * Copyright (c) 2018-present Sven Greb + * This source code is licensed under the MIT license found in the LICENSE file. + */ + +/** + * Enforce a consistent character style for emphasis marker. + * + * @see https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-code-block-style + * @see https://arcticicestudio.github.io/styleguide-markdown/rules/emphasis.html#italic + * @see https://arcticicestudio.github.io/styleguide-markdown/rules/emphasis.html#bold + * @see https://arcticicestudio.github.io/styleguide-markdown/rules/emphasis.html#strikethrough + */ +const emphasisMarker = require("remark-lint-emphasis-marker"); +/** + * Warn when using emphasis elements (bold or italics) as replacement for headings. + * + * @see https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-emphasis-as-heading + * @see https://arcticicestudio.github.io/styleguide-markdown/rules/emphasis.html#no-header-replacement + */ +const noEmphasisAsHeading = require("remark-lint-no-emphasis-as-heading"); +/** + * Disallow inner padding within emphasis marker, code marker and link IDs. + * + * @see https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-inline-padding + * @see https://arcticicestudio.github.io/styleguide-markdown/rules/emphasis.html#no-inner-spacing + * @see https://arcticicestudio.github.io/styleguide-markdown/rules/links.html#no-id-inner-spacing + */ +const noInlinePadding = require("remark-lint-no-inline-padding"); +/** + * Enforce the character style for strong (bold) emphasis markers. + * + * @see https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-strong-marker + * @see https://arcticicestudio.github.io/styleguide-markdown/rules/emphasis.html#bold + */ +const strongMarker = require("remark-lint-strong-marker"); + +/** + * Official remark-lint core rules for emphasis document nodes. + * @author Arctic Ice Studio + * @author Sven Greb + * @since 0.1.0 + * @see https://github.com/remarkjs/remark-lint/blob/master/doc/rules.md#list-of-rules + */ +module.exports = { + plugins: [ + [emphasisMarker, ["warn", "consistent"]], + [noEmphasisAsHeading, ["warn"]], + [noInlinePadding, ["error"]], + [strongMarker, ["error", "*"]] + ] +}; diff --git a/packages/@arcticicestudio/remark-preset-lint/rules/headings.js b/packages/@arcticicestudio/remark-preset-lint/rules/headings.js new file mode 100644 index 0000000..0748603 --- /dev/null +++ b/packages/@arcticicestudio/remark-preset-lint/rules/headings.js @@ -0,0 +1,102 @@ +/* + * Copyright (c) 2018-present Arctic Ice Studio + * Copyright (c) 2018-present Sven Greb + * This source code is licensed under the MIT license found in the LICENSE file. + */ + +/** + * Enforce a specific level for the first heading. + * + * @see https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-first-heading-level + */ +const firstHeadingLevel = require("remark-lint-first-heading-level"); +/** + * Enforce headings to only increment by one at a time. + * + * @see https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-heading-increment + */ +const headingIncrement = require("remark-lint-heading-increment"); +/** + * Enforce ATX style headings. + * + * @see https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-heading-style + * @see https://arcticicestudio.github.io/styleguide-markdown/rules/headings.html#atx-style + */ +const headingStyle = require("remark-lint-heading-style"); +/** + * Warn if a maximum length for headings is exceeded. + * + * @see https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-maximum-heading-length + * @see https://arcticicestudio.github.io/styleguide-markdown/rules/headings.html#length + */ +const maximumHeadingLength = require("remark-lint-maximum-heading-length"); +/** + * Warn when using two or more headers with the same content in the same markdown file. + * + * @see https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-duplicate-headings + * @see https://arcticicestudio.github.io/styleguide-markdown/rules/headings.html#no-duplicate + */ +const noDuplicateHeadings = require("remark-lint-no-duplicate-headings"); +/** + * Warn when using two or more headers with the same content in the same section. + * + * @see https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-duplicate-headings-in-section + * @see https://arcticicestudio.github.io/styleguide-markdown/rules/headings.html#no-duplicate + */ +const noDuplicateHeadingsInSection = require("remark-lint-no-duplicate-headings-in-section"); +/** + * Disallow invalid indention of headings content. + * + * @see https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-heading-content-indent + * @see https://arcticicestudio.github.io/styleguide-markdown/rules/headings.html#content-spacing + */ +const noHeadingContentIndent = require("remark-lint-no-heading-content-indent"); +/** + * Disallow indention and any content (including whitespaces) before headings. + * + * @see https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-heading-indent + * @see https://arcticicestudio.github.io/styleguide-markdown/rules/headings.html#no-content-before + */ +const noHeadingIndent = require("remark-lint-no-heading-indent"); +/** + * Disallow using level 7+ "headings". + * + * @see https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-heading-like-paragraph + */ +const noHeadingLikeParagraph = require("remark-lint-no-heading-like-paragraph"); +/** + * Warn when ending a heading content with a punctuation character. + * + * @see https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-heading-punctuation + * @see https://arcticicestudio.github.io/styleguide-markdown/rules/headings.html#punctuation-after-content + */ +const noHeadingPunctuation = require("remark-lint-no-heading-punctuation"); +/** + * Disallow multiple toplevel headings. + * + * @see https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-multiple-toplevel-headings + */ +const noMultipleToplevelHeadings = require("remark-lint-no-multiple-toplevel-headings"); + +/** + * Official remark-lint core rules for heading document nodes. + * @author Arctic Ice Studio + * @author Sven Greb + * @since 0.1.0 + * @see https://github.com/remarkjs/remark-lint/blob/master/doc/rules.md#list-of-rules + */ +module.exports = { + plugins: [ + [firstHeadingLevel, false], + [headingIncrement, false], + [headingStyle, ["error", "atx"]], + [maximumHeadingLength, ["warn", 80]], + [noDuplicateHeadings, ["warn"]], + [noDuplicateHeadingsInSection, ["warn"]], + [noHeadingContentIndent, ["error"]], + [noHeadingIndent, ["error"]], + [noHeadingLikeParagraph, ["error"]], + [noHeadingPunctuation, ["warn"]], + [noMultipleToplevelHeadings, false] + ] +}; diff --git a/packages/@arcticicestudio/remark-preset-lint/rules/horizontal-rules.js b/packages/@arcticicestudio/remark-preset-lint/rules/horizontal-rules.js new file mode 100644 index 0000000..7f66962 --- /dev/null +++ b/packages/@arcticicestudio/remark-preset-lint/rules/horizontal-rules.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2018-present Arctic Ice Studio + * Copyright (c) 2018-present Sven Greb + * This source code is licensed under the MIT license found in the LICENSE file. + */ + +/** + * Enforce the character style for horizontal rule markers. + * + * @see https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-rule-style + * @see https://arcticicestudio.github.io/styleguide-markdown/rules/horizontal-rules.html#marker-character-style + */ +const ruleStyle = require("remark-lint-rule-style"); + +/** + * Official remark-lint core rules for horizontal rule document nodes. + * @author Arctic Ice Studio + * @author Sven Greb + * @since 0.1.0 + * @see https://github.com/remarkjs/remark-lint/blob/master/doc/rules.md#list-of-rules + */ +module.exports = { + plugins: [ + [ruleStyle, ["error", "---"]] + ] +}; diff --git a/packages/@arcticicestudio/remark-preset-lint/rules/links.js b/packages/@arcticicestudio/remark-preset-lint/rules/links.js new file mode 100644 index 0000000..ce440d6 --- /dev/null +++ b/packages/@arcticicestudio/remark-preset-lint/rules/links.js @@ -0,0 +1,111 @@ +/* + * Copyright (c) 2018-present Arctic Ice Studio + * Copyright (c) 2018-present Sven Greb + * This source code is licensed under the MIT license found in the LICENSE file. + */ + +/** + * Enforce lower case letters for reference link IDs. + * + * @see https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-definition-case + * @see https://arcticicestudio.github.io/styleguide-markdown/rules/links.html#letter-case + */ +const definitionCase = require("remark-lint-definition-case"); +/** + * Enforce a single space after the colon of reference links. + * + * @see https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-definition-spacing + * @see https://arcticicestudio.github.io/styleguide-markdown/rules/links.html#spacing-after-colon + */ +const definitionSpacing = require("remark-lint-definition-spacing"); +/** + * Enforce reference links to be placed at the bottom of the document. + * + * @see https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-final-definition + * @see https://arcticicestudio.github.io/styleguide-markdown/rules/links.html#definition-placement + */ +const finalDefinition = require("remark-lint-final-definition"); +/** + * Disallow autolinks without a valid protocols. + * + * @see https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-auto-link-without-protocol + * @see https://arcticicestudio.github.io/styleguide-markdown/rules/links.html#autolink-protocol + */ +const noAutoLinkWithoutProtocol = require("remark-lint-no-auto-link-without-protocol"); +/** + * Disallow duplicate reference link IDs. + * + * @see https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-duplicate-definitions + * @see https://arcticicestudio.github.io/styleguide-markdown/rules/links.html#unique-ids + */ +const noDuplicateDefinitions = require("remark-lint-no-duplicate-definitions"); +/** + * Disallow empty link and image URLs. + * + * @see https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-empty-url + * @see https://arcticicestudio.github.io/styleguide-markdown/rules/links.html#no-empty-url + */ +const noEmptyUrl = require("remark-lint-no-empty-url"); +/** + * Disallow literal URLs and enforce to always use angle-brackets ("<>") for autolinks. + * + * @see https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-literal-urls + */ +const noLiteralUrls = require("remark-lint-no-literal-urls"); +/** + * Disallow URLs that are also defined identifiers. + * + * @see https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-reference-like-url + * @see https://arcticicestudio.github.io/styleguide-markdown/rules/links.html#no-reference-like-url + */ +const noReferenceLikeUrl = require("remark-lint-no-reference-like-url"); +/** + * Warn when using shortcut reference images. + * + * @see https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-shortcut-reference-image + */ +const noShortcutReferenceImage = require("remark-lint-no-shortcut-reference-image"); +/** + * Warn when using shortcut reference links. + * + * @see https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-shortcut-reference-link + */ +const noShortcutReferenceLink = require("remark-lint-no-shortcut-reference-link"); +/** + * Disallow the usage of references that are not defined. + * + * @see https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-undefined-references + * @see https://arcticicestudio.github.io/styleguide-markdown/rules/links.html#no-undefined + */ +const noUndefinedReferences = require("remark-lint-no-undefined-references"); +/** + * Warn when unused definitions are found. + * + * @see https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-unused-definitions + * @see https://arcticicestudio.github.io/styleguide-markdown/rules/links.html#no-unused + */ +const noUnusedDefinitions = require("remark-lint-no-unused-definitions"); + +/** + * Official remark-lint core rules for link document nodes. + * @author Arctic Ice Studio + * @author Sven Greb + * @since 0.1.0 + * @see https://github.com/remarkjs/remark-lint/blob/master/doc/rules.md#list-of-rules + */ +module.exports = { + plugins: [ + [definitionCase, ["error"]], + [definitionSpacing, ["error"]], + [finalDefinition, ["error"]], + [noAutoLinkWithoutProtocol, ["warn"]], + [noDuplicateDefinitions, ["error"]], + [noEmptyUrl, ["error"]], + [noLiteralUrls, false], + [noReferenceLikeUrl, ["error"]], + [noShortcutReferenceImage, false], + [noShortcutReferenceLink, false], + [noUndefinedReferences, ["error"]], + [noUnusedDefinitions, ["warn"]] + ] +}; diff --git a/packages/@arcticicestudio/remark-preset-lint/rules/lists.js b/packages/@arcticicestudio/remark-preset-lint/rules/lists.js new file mode 100644 index 0000000..6a93dc4 --- /dev/null +++ b/packages/@arcticicestudio/remark-preset-lint/rules/lists.js @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2018-present Arctic Ice Studio + * Copyright (c) 2018-present Sven Greb + * This source code is licensed under the MIT license found in the LICENSE file. + */ + +/** + * Enforce a valid character style for ticked list item checkboxes. + * + * @see https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-checkbox-character-style + * @see https://arcticicestudio.github.io/styleguide-markdown/rules/lists.html#checkbox-character-style + */ +const checkboxCharacterStyle = require("remark-lint-checkbox-character-style"); +/** + * Allow only one whitespace after list item checkboxes. + * + * @see https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-checkbox-content-indent + */ +const checkboxContentIndent = require("remark-lint-checkbox-content-indent"); +/** + * Disallow that list item bullets are indented. + * + * @see https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-list-item-bullet-indent + * @see https://arcticicestudio.github.io/styleguide-markdown/rules/lists.html#no-content-before + */ +const listItemBulletIndent = require("remark-lint-list-item-bullet-indent"); +/** + * Enforce two (2) whitespaces for continuous content indentation of nested items. + * + * @see https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-list-item-content-indent + * @see https://arcticicestudio.github.io/styleguide-markdown/rules/lists.html#continuous-indentation + */ +const listItemContentIndent = require("remark-lint-list-item-content-indent"); +/** + * Enforce two (2) whitespaces for continuous indentation of nested items. + * + * @see https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-list-item-indent + * @see https://arcticicestudio.github.io/styleguide-markdown/rules/lists.html#continuous-indentation + */ +const listItemIndent = require("remark-lint-list-item-indent"); +/** + * Disallow blank lines between list items. + * + * @see https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-list-item-spacing + * @see https://arcticicestudio.github.io/styleguide-markdown/rules/lists.html#empty-lines + */ +const listItemSpacing = require("remark-lint-list-item-spacing"); +/** + * Enforce the dot (".") marker character style for ordered list items. + * + * @see https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-ordered-list-marker-style + * @see https://arcticicestudio.github.io/styleguide-markdown/rules/lists.html#ordered-marker + */ +const orderedListMarkerStyle = require("remark-lint-ordered-list-marker-style"); +/** + * Enforce continuous numerating for markers of ordered list items. + * + * @see https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-ordered-list-marker-value + * @see https://arcticicestudio.github.io/styleguide-markdown/rules/lists.html#ordered-marker + */ +const orderedListMarkerValue = require("remark-lint-ordered-list-marker-value"); +/** + * Enforce dash (`-`) marker character style for unordered list items. + * + * @see https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-unordered-list-marker-style + * @see https://arcticicestudio.github.io/styleguide-markdown/rules/lists.html#unordered-marker + */ +const unorderedListMarkerStyle = require("remark-lint-unordered-list-marker-style"); + +/** + * Official remark-lint core rules for list document nodes. + * @author Arctic Ice Studio + * @author Sven Greb + * @since 0.1.0 + * @see https://github.com/remarkjs/remark-lint/blob/master/doc/rules.md#list-of-rules + */ +module.exports = { + plugins: [ + [checkboxCharacterStyle, ["error", { + checked: "x", + unchecked: " " + }]], + [checkboxContentIndent, ["error"]], + [listItemBulletIndent, ["error"]], + [listItemContentIndent, ["error"]], + [listItemIndent, ["error", "space"]], + [listItemSpacing, false], + [orderedListMarkerStyle, ["error", "."]], + [orderedListMarkerValue, ["error", "ordered"]], + [unorderedListMarkerStyle, ["error", "-"]] + ] +}; diff --git a/packages/@arcticicestudio/remark-preset-lint/rules/naming-conventions.js b/packages/@arcticicestudio/remark-preset-lint/rules/naming-conventions.js new file mode 100644 index 0000000..8c5674f --- /dev/null +++ b/packages/@arcticicestudio/remark-preset-lint/rules/naming-conventions.js @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2018-present Arctic Ice Studio + * Copyright (c) 2018-present Sven Greb + * This source code is licensed under the MIT license found in the LICENSE file. + */ + +/** + * Enforce a consistent file extension. + * + * @see https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-file-extension + * @see https://arcticicestudio.github.io/styleguide-markdown/rules/naming-conventions.html#file-extension + */ +const fileExtension = require("remark-lint-file-extension"); +/** + * Warn when file name start with an article. + * + * @see https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-file-name-articles + */ +const noFileNameArticles = require("remark-lint-no-file-name-articles"); +/** + * Warn when file names contain consecutive dashes. + * + * @see https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-file-name-consecutive-dashes + */ +const noFileNameConsecutiveDashes = require("remark-lint-no-file-name-consecutive-dashes"); +/** + * Warn when file names contain irregular characters other than alpha-numericals, dashes, and dots. + * + * @see https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-file-name-irregular-characters + */ +const noFileNameIrregularCharacters = require("remark-lint-no-file-name-irregular-characters"); +/** + * Disallow file names with mixed letter case: both upper- and lower case characters. + * + * @see https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-file-name-mixed-case + * @see https://arcticicestudio.github.io/styleguide-markdown/rules/naming-conventions.html#file-naming + */ +const noFileNameMixedCase = require("remark-lint-no-file-name-mixed-case"); +/** + * Warn when file names contain initial or final dashes. + * + * @see https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-file-name-outer-dashes + */ +const noFileNameOuterDashes = require("remark-lint-no-file-name-outer-dashes"); + +/** + * Official remark-lint core rules for naming conventions. + * @author Arctic Ice Studio + * @author Sven Greb + * @since 0.1.0 + * @see https://github.com/remarkjs/remark-lint/blob/master/doc/rules.md#list-of-rules + */ +module.exports = { + plugins: [ + [fileExtension, ["error", "md"]], + [noFileNameArticles, false], + [noFileNameConsecutiveDashes, ["warn"]], + [noFileNameIrregularCharacters, false], + [noFileNameMixedCase, ["error"]], + [noFileNameOuterDashes, ["warn"]] + ] +}; diff --git a/packages/@arcticicestudio/remark-preset-lint/rules/paragraphs.js b/packages/@arcticicestudio/remark-preset-lint/rules/paragraphs.js new file mode 100644 index 0000000..00d0692 --- /dev/null +++ b/packages/@arcticicestudio/remark-preset-lint/rules/paragraphs.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2018-present Arctic Ice Studio + * Copyright (c) 2018-present Sven Greb + * This source code is licensed under the MIT license found in the LICENSE file. + */ + +/** + * Disallow the content of paragraphs to be indented. + * + * @see https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-paragraph-content-indent + * @see https://arcticicestudio.github.io/styleguide-markdown/rules/paragraphs.html#no-indentation + */ +const noParagraphContentIndent = require("remark-lint-no-paragraph-content-indent"); + +/** + * Official remark-lint core rules for paragraph document nodes. + * @author Arctic Ice Studio + * @author Sven Greb + * @since 0.1.0 + * @see https://github.com/remarkjs/remark-lint/blob/master/doc/rules.md#list-of-rules + */ +module.exports = { + plugins: [ + [noParagraphContentIndent, ["error"]] + ] +}; diff --git a/packages/@arcticicestudio/remark-preset-lint/rules/raw-html.js b/packages/@arcticicestudio/remark-preset-lint/rules/raw-html.js new file mode 100644 index 0000000..afb5323 --- /dev/null +++ b/packages/@arcticicestudio/remark-preset-lint/rules/raw-html.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2018-present Arctic Ice Studio + * Copyright (c) 2018-present Sven Greb + * This source code is licensed under the MIT license found in the LICENSE file. + */ + +/** + * Disallow using raw HTML nodes. + * + * @see https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-html + */ +const noHtml = require("remark-lint-no-html"); + +/** + * Official remark-lint core rules for raw HTML document nodes. + * @author Arctic Ice Studio + * @author Sven Greb + * @since 0.1.0 + * @see https://github.com/remarkjs/remark-lint/blob/master/doc/rules.md#list-of-rules + */ +module.exports = { + plugins: [ + [noHtml, false] + ] +}; diff --git a/packages/@arcticicestudio/remark-preset-lint/rules/strings.js b/packages/@arcticicestudio/remark-preset-lint/rules/strings.js new file mode 100644 index 0000000..9ab40a3 --- /dev/null +++ b/packages/@arcticicestudio/remark-preset-lint/rules/strings.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2018-present Arctic Ice Studio + * Copyright (c) 2018-present Sven Greb + * This source code is licensed under the MIT license found in the LICENSE file. + */ + +/** + * Enforce double quotes for link titles. + * + * @see https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-link-title-style + * @see https://arcticicestudio.github.io/styleguide-markdown/rules/strings.html#quotes + */ +const linkTitleStyle = require("remark-lint-link-title-style"); + +/** + * Official remark-lint core rules for string document nodes. + * @author Arctic Ice Studio + * @author Sven Greb + * @since 0.1.0 + * @see https://github.com/remarkjs/remark-lint/blob/master/doc/rules.md#list-of-rules + */ +module.exports = { + plugins: [ + [linkTitleStyle, ["error", "\""]] + ] +}; diff --git a/packages/@arcticicestudio/remark-preset-lint/rules/support.js b/packages/@arcticicestudio/remark-preset-lint/rules/support.js new file mode 100644 index 0000000..2ba7f16 --- /dev/null +++ b/packages/@arcticicestudio/remark-preset-lint/rules/support.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2018-present Arctic Ice Studio + * Copyright (c) 2018-present Sven Greb + * This source code is licensed under the MIT license found in the LICENSE file. + */ + + +/** + * Add support for YAML and TOML frontmatter. + * + * @since 0.3.0 + * @see http://yaml.org + * @see https://github.com/toml-lang/toml + */ +const frontmatter = require("remark-frontmatter"); + +/** + * Support for rules of specification addons and additions. + * @author Arctic Ice Studio + * @author Sven Greb + * @since 0.1.0 + */ +module.exports = { + plugins: [ + [frontmatter, ["yaml", "toml"]] + ] +}; diff --git a/packages/@arcticicestudio/remark-preset-lint/rules/tables.js b/packages/@arcticicestudio/remark-preset-lint/rules/tables.js new file mode 100644 index 0000000..7b01180 --- /dev/null +++ b/packages/@arcticicestudio/remark-preset-lint/rules/tables.js @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2018-present Arctic Ice Studio + * Copyright (c) 2018-present Sven Greb + * This source code is licensed under the MIT license found in the LICENSE file. + */ + +/** + * Disallow tables to be indented. + * + * @see https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-table-indentation + * @see https://arcticicestudio.github.io/styleguide-markdown/rules/tables.html#no-indentation + */ +const noTableIndentation = require("remark-lint-no-table-indentation"); +/** + * Enforces table cells to be padded correctly. + * + * @see https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-table-cell-padding + * @see https://arcticicestudio.github.io/styleguide-markdown/rules/tables.html#header-delimiter-row-spacing + */ +const tableCellPadding = require("remark-lint-table-cell-padding"); +/** + * Enforces table cell header delimiter marker to be correctly aligned. + * + * @see https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-table-pipe-alignment + * @see https://arcticicestudio.github.io/styleguide-markdown/rules/tables.html#header-delimiter-row-spacing + * @see https://arcticicestudio.github.io/styleguide-markdown/rules/tables.html#minimum-column-width + */ +const tablePipeAlignment = require("remark-lint-table-pipe-alignment"); +/** + * Enforces table cell header delimiter marker to be correctly aligned. + * + * @see https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-table-pipes + * @see https://arcticicestudio.github.io/styleguide-markdown/rules/tables.html#alignment + */ +const tablePipes = require("remark-lint-table-pipes"); + +/** + * Official remark-lint core rules for table document nodes. + * @author Arctic Ice Studio + * @author Sven Greb + * @since 0.1.0 + * @see https://github.com/remarkjs/remark-lint/blob/master/doc/rules.md#list-of-rules + */ +module.exports = { + plugins: [ + [noTableIndentation, ["error"]], + [tableCellPadding, ["error", "padded"]], + [tablePipeAlignment, ["error"]], + [tablePipes, ["error"]] + ] +}; diff --git a/packages/@arcticicestudio/remark-preset-lint/rules/whitespace.js b/packages/@arcticicestudio/remark-preset-lint/rules/whitespace.js new file mode 100644 index 0000000..918817f --- /dev/null +++ b/packages/@arcticicestudio/remark-preset-lint/rules/whitespace.js @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2018-present Arctic Ice Studio + * Copyright (c) 2018-present Sven Greb + * This source code is licensed under the MIT license found in the LICENSE file. + */ + +/** + * Enforce a newline at the end of a file. Empty files are allowed. + * + * @see https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-final-newline + * @see https://arcticicestudio.github.io/styleguide-markdown/rules/whitespace.html#newline + */ +const finalNewline = require("remark-lint-final-newline"); +/** + * Enforce a consistent number of trailing whitespaces for line breaks. + * + * @see https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-hard-break-spaces + * @see https://arcticicestudio.github.io/styleguide-markdown/rules/whitespace.html#trailing + */ +const hardBreakSpaces = require("remark-lint-hard-break-spaces"); +/** + * Enforce unix-style linebreaks. + * + * @see https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-linebreak-style + * @see https://arcticicestudio.github.io/styleguide-markdown/rules/whitespace.html#newline + */ +const linebreakStyle = require("remark-lint-linebreak-style"); +/** + * Enforce a maximum line length. + * + * @see https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-maximum-line-length + * @see https://arcticicestudio.github.io/styleguide-markdown/rules/whitespace.html#maximum-line-length + */ +const maximumLineLength = require("remark-lint-maximum-line-length"); +/** + * Disallow more than one (1) blank line after and before each block. + * + * @see https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-consecutive-blank-lines + * @see https://arcticicestudio.github.io/styleguide-markdown/rules/whitespace.html#after-blocks + */ +const noConsecutiveBlankLines = require("remark-lint-no-consecutive-blank-lines"); +/** + * Warn when missing blank line before a block node. + * + * @see https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-missing-blank-lines + * @see https://arcticicestudio.github.io/styleguide-markdown/rules/whitespace.html#before-blocks + */ +const noMissingBlankLines = require("remark-lint-no-missing-blank-lines"); +/** + * Disallow tabs and enforce to use whitespaces. + * + * @see https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-tabs + * @see https://arcticicestudio.github.io/styleguide-markdown/rules/whitespace.html#indentation-character + */ +const noTabs = require("remark-lint-no-tabs"); + +/** + * Official remark-lint core rules for whitespaces. + * @author Arctic Ice Studio + * @author Sven Greb + * @since 0.1.0 + * @see https://github.com/remarkjs/remark-lint/blob/master/doc/rules.md#list-of-rules + */ +module.exports = { + plugins: [ + [finalNewline, ["error"]], + [hardBreakSpaces, ["error"]], + [linebreakStyle, ["error", "unix"]], + [maximumLineLength, false], + [noConsecutiveBlankLines, ["warn"]], + [noMissingBlankLines, ["warn", { exceptTightLists: true }]], + [noTabs, ["error"]] + ] +};