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

Feat: Introducing Markdown linting using Remark #177

Merged
merged 3 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .commitlintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ module.exports = {
'browserslist',
'commitlint',
'conventional-changelog',
'markdownlint',
'prettier',
'stylelint',
'renovate',
'stylelint',
'textlint',
'eslint-config-base',
'eslint-config-lmc',
Expand Down
3 changes: 3 additions & 0 deletions .remarkignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Changelog is autogenerated
CHANGELOG.md
example-changelog.md
5 changes: 5 additions & 0 deletions .remarkrc.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import config from './packages/remark-config/index.js';

export default {
...config,
};
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

> Built with ❤️ at [Alma Career][alma-home]

This monorepo contains shareable configurations for various coding-style/best practices/lint tools to make the configurations consistent across projects and provide easy setup mechanism.
This monorepo contains shareable configurations for various coding-style/best practices/lint tools to make the configurations consistent across projects and provide an easy setup mechanism.

## Available Configurations

Expand All @@ -12,7 +12,7 @@ This monorepo contains shareable configurations for various coding-style/best pr
| Commitlint | [@lmc-eu/commitlint-config](packages/commitlint-config) | [![@lmc-eu/commitlint-config][clc-badge]][clc-npm] |
| Conventional Changelog | [@lmc-eu/conventional-changelog-lmc-bitbucket](packages/conventional-changelog-lmc-bitbucket) | [![@lmc-eu/conventional-changelog-lmc-bitbucket][cc-bb-badge]][cc-bb-npm] |
| Conventional Changelog | [@lmc-eu/conventional-changelog-lmc-github](packages/conventional-changelog-lmc-github) | [![@lmc-eu/conventional-changelog-lmc-github][cc-gh-badge]][cc-gh-npm] |
| ESLint | [@lmc-eu/eslint-config-base](packages/eslint-config-base) | [![@lmc-eu/eslint-config-base][slc-badge]][ec-base-npm] |
| ESLint | [@lmc-eu/eslint-config-base](packages/eslint-config-base) | [![@lmc-eu/eslint-config-base][ec-base-badge]][ec-base-npm] |
| ESLint | [@lmc-eu/eslint-config-graphql](packages/eslint-config-graphql) | [![@lmc-eu/eslint-config-graphql][ec-gql-badge]][ec-gql-npm] |
| ESLint | [@lmc-eu/eslint-config-react](packages/eslint-config-react) | [![@lmc-eu/eslint-config-react][ec-react-badge]][ec-react-npm] |
| ESLint | [@lmc-eu/eslint-config-jest](packages/eslint-config-jest) | [![@lmc-eu/eslint-config-jest][ec-jest-badge]][ec-jest-npm] |
Expand All @@ -28,7 +28,7 @@ See the [LICENSE](LICENSE) file for information.

## Credit

We got a lot of inspiration from similar project at [STRV][strv-github]. Thank you very much ❤️!
We got a lot of inspiration from the similar project at [STRV][strv-github]. Thank you very much ❤️!

[alma-home]: https://www.almacareer.com
[blc-npm]: https://npmjs.org/package/%40lmc-eu/browserslist-config
Expand Down
9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@
"format:check": "prettier --check ./",
"format:fix": "prettier --write ./",
"format:fix:changelog": "prettier --write ./packages/**/CHANGELOG.md",
"lint": "npm-run-all --serial lint:es lint:text",
"lint": "npm-run-all --serial lint:es lint:text lint:md",
"lint:fix": "npm-run-all --serial lint:*:fix",
"lint:es": "eslint ./",
"lint:es:fix": "yarn lint:es --fix",
"lint:text": "textlint ./",
"lint:text:fix": "yarn lint:text --fix",
"lint:md": "remark ./ --quiet",
"version": "yarn format:fix:changelog"
},
"devDependencies": {
Expand All @@ -41,6 +42,10 @@
"lerna": "8.1.3",
"npm-run-all": "4.1.5",
"prettier": "2.8.8",
"pretty-quick": "3.3.1"
"pretty-quick": "3.3.1",
"remark-cli": "^12.0.0",
"remark-preset-lint-consistent": "^6",
"remark-preset-lint-markdown-style-guide": "^6",
"remark-preset-lint-recommended": "^7"
}
}
9 changes: 5 additions & 4 deletions packages/browserslist-config/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ npm install --save-dev @lmc-eu/browserslist-config

Add this to `.browserslistrc` file:

```
```txt
extends @lmc-eu/browserslist-config
```

Expand All @@ -32,7 +32,7 @@ Alternatively, add this to your `package.json` file:

To support Internet Explorer (or any other browser):

```
```txt
extends @lmc-eu/browserslist-config

ie # sorry!
Expand All @@ -46,13 +46,14 @@ To get the data from Google Analytics, use one of the following tools:

- [browserslist-ga-export](https://github.com/browserslist/browserslist-ga-export)
— create a custom report in GA and export it to CSV,

- [browserslist-ga](https://github.com/browserslist/browserslist-ga)
— easier if you are OK with providing your Google password to a third-party tool.

Make the resulting file available to Browserslist by saving it right next to
your `.browserslistrc` (or `package.json`, wherever you store your config):

```
```txt
# Project root

- .browserslistrc
Expand All @@ -63,7 +64,7 @@ your `.browserslistrc` (or `package.json`, wherever you store your config):

As mentioned in the stats file in your Browserslist configuration:

```
```txt
extends @lmc-eu/browserslist-config

> 0.5% in my stats
Expand Down
4 changes: 2 additions & 2 deletions packages/conventional-changelog-lmc-bitbucket/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@

NPM:

```
```sh
npm i --dev @commitlint/cli @commitlint/config-conventional @lmc-eu/conventional-changelog-lmc-bitbucket
```

Yarn:

```
```sh
yarn add --dev @commitlint/cli @commitlint/config-conventional @lmc-eu/conventional-changelog-lmc-bitbucket
```

Expand Down
4 changes: 2 additions & 2 deletions packages/conventional-changelog-lmc-github/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@

NPM:

```
```sh
npm i --dev @commitlint/cli @commitlint/config-conventional @lmc-eu/conventional-changelog-lmc-github
```

Yarn:

```
```sh
yarn add --dev @commitlint/cli @commitlint/config-conventional @lmc-eu/conventional-changelog-lmc-github
```

Expand Down
4 changes: 2 additions & 2 deletions packages/conventional-changelog-lmc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@

NPM:

```
```sh
npm i --dev @lmc-eu/conventional-changelog-lmc
```

Yarn:

```
```sh
yarn add --dev @lmc-eu/conventional-changelog-lmc
```

Expand Down
8 changes: 4 additions & 4 deletions packages/eslint-config-base/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,21 @@ These rules are meant to be shared across all ESLint rulesets.

## Configurations

### `@lmc-eu/eslint-config-base`
- **`@lmc-eu/eslint-config-base`**

Use this ruleset to configure ESLint to work with every JavaScript code.

### `@lmc-eu/eslint-config-base/optional`
- **`@lmc-eu/eslint-config-base/optional`**

Use this ruleset together with the above ruleset. Provides additional insights into potential inconsistencies in the project.

> For new projects, it is recommended to enable this ruleset. For existing projects, it is only recommended for the brave.

### `@lmc-eu/eslint-config-base/legacy`
- **`@lmc-eu/eslint-config-base/legacy`**

Lints ES5 and below.

### `@lmc-eu/eslint-config-base/whitespace`
- **`@lmc-eu/eslint-config-base/whitespace`**

This entry point only errors on whitespace rules and sets all other rules to warnings. View [the list of whitespace rules](https://github.com/airbnb/javascript/blob/master/packages/eslint-config-airbnb-base/whitespace.js).

Expand Down
8 changes: 4 additions & 4 deletions packages/eslint-config-react/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@

Wee need to install everything needed by the config using (installs package and also peer dependencies):

```
```sh
npx install-peerdeps --dev @lmc-eu/eslint-config-react
```

You can see in your package.json there are now a big list of devDependencies.
You can see in your package.json there is now a big list of devDependencies.

## Configurations

### `@lmc-eu/eslint-config-react`
- **`@lmc-eu/eslint-config-react`**

Use this ruleset to configure ESLint to work with React code.

### `@lmc-eu/eslint-config-react/optional`
- **`@lmc-eu/eslint-config-react/optional`**

Use this ruleset together with the above ruleset. Provides additional insights into potential inconsistencies in the project.

Expand Down
4 changes: 2 additions & 2 deletions packages/eslint-config-typescript/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the example _.eslintrc.js_ file below for more details and make sure you rea

## Configurations

### `@lmc-eu/eslint-config-typescript`
- **`@lmc-eu/eslint-config-typescript`**

Suitable for linting TypeScript source files.

Expand Down Expand Up @@ -65,7 +65,7 @@ module.exports = {

A full configuration for a TypeScript on React project:

> Please note, that you need to have [eslint-config-react] installed as well
> Please note, that you need to have [eslint-config-react][eslint-config-react] installed as well

```js
// .eslintrc.js
Expand Down
2 changes: 1 addition & 1 deletion packages/prettier-config/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ module.exports = {

### Prettier Version

Versions of `prettier` before v1.17 did not feature the possibility to use a shared config via _package.json_. The way to do it is similar to when [extending](#Extending), except that you can just export the config directly:
Versions of `prettier` before v1.17 did not feature the possibility of using a shared config via _package.json_. The way to do it is similar to when [extending](#Extending), except that you can just export the config directly:

```js
// .prettierrc.js
Expand Down
23 changes: 23 additions & 0 deletions packages/remark-config/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# @almacareer/remark-config

> Alma Career’s config for [remark-cli][remark-cli-home]

## Usage

```sh
npm i --dev remark-cli @almacareer/remark-config
```

Now, create a _.remarkrc.js_ file in your project’s root with the following contents:

```js
import config from '@almacareer/remark-config';

export default {
...config,
};
```

Remark’s configuration does not support built-in extensibility/inheritance of configuration so if you’d like to change some configuration options you will have to resort to standard JavaScript’s object mutation/extension patterns.

[remark-cli-home]: https://github.com/remarkjs/remark/tree/master/packages/remark-cli
28 changes: 28 additions & 0 deletions packages/remark-config/index.js
literat marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
export default {
settings: {
emphasis: '_',
},

plugins: [
'preset-lint-recommended',
'preset-lint-consistent',
'preset-lint-markdown-style-guide',

// warn when the spacing between a list item’s bullet and its content violates a given style
// @see: https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-list-item-indent
['lint-list-item-indent', 'one'],
// warn when lines are too long
// @see: https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-maximum-line-length
['lint-maximum-line-length', Infinity],
literat marked this conversation as resolved.
Show resolved Hide resolved
// warn when emphasis markers violate the given style
// @see: https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-emphasis-marker
['lint-emphasis-marker', '_'],
literat marked this conversation as resolved.
Show resolved Hide resolved
// warn when table pipes are not aligned
// @see: https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-table-pipe-alignment
['lint-table-pipe-alignment', false],
// warn when table cells are incorrectly padded
// @see: https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-table-cell-padding
['lint-table-cell-padding', 'consistent'],
literat marked this conversation as resolved.
Show resolved Hide resolved
['lint-no-undefined-references', { allow: ['x'] }],
literat marked this conversation as resolved.
Show resolved Hide resolved
],
};
32 changes: 32 additions & 0 deletions packages/remark-config/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"name": "@almacareer/remark-config",
"description": "Alma Career's config for Markdown linting with Remark",
"version": "0.0.0",
"keywords": [
"config",
"lint",
"markdown",
"remark",
"alma",
"career"
],
"author": "Tomáš Litera <[email protected]>",
"repository": {
"type": "git",
"url": "git://github.com/lmc-eu/code-quality-tools.git"
},
"engines": {
"node": ">=18"
},
"license": "MIT",
"type": "module",
"main": "index.js",
"publishConfig": {
"access": "public"
},
"dependencies": {
"remark-preset-lint-consistent": "^6.0.0",
"remark-preset-lint-markdown-style-guide": "^6.0.0",
"remark-preset-lint-recommended": "^7.0.0"
}
literat marked this conversation as resolved.
Show resolved Hide resolved
}
2 changes: 1 addition & 1 deletion packages/stylelint-config/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ This config:

## Configuration

### `@lmc-eu/stylelint-config`
- **`@lmc-eu/stylelint-config`**

Use this ruleset to configure Stylelint to work with your code.

Expand Down
Loading