Skip to content

Commit

Permalink
[E4E-0]: Node 22 upgrade; Added examples; Dogfood the config onto its…
Browse files Browse the repository at this point in the history
…elf; Updated library versions
  • Loading branch information
joncursi committed Sep 26, 2024
1 parent 7727ab4 commit 2b50775
Show file tree
Hide file tree
Showing 10 changed files with 222 additions and 129 deletions.
6 changes: 1 addition & 5 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@
"editor.formatOnPaste": true,
"git.ignoreLimitWarning": true,
"editor.tabSize": 2,
"editor.codeActionsOnSave": [
"source.organizeImports",
"source.fixAll",
"source.addMissingImports"
],
"editor.codeActionsOnSave": ["source.organizeImports", "source.fixAll", "source.addMissingImports"],
"eslint.codeActionsOnSave.mode": "problems",
"typescript.tsdk": "node_modules/typescript/lib",
"[javascript]": {
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) ACT, Inc. and its affiliates.
Copyright (c) Encoura, LLC and its affiliates.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
73 changes: 30 additions & 43 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
# ESLint Config

<!-- markdownlint-disable line-length -->

[![Version](https://img.shields.io/npm/v/@encoura/eslint-config)](https://www.npmjs.com/package/@encoura/eslint-config) [![Build Status](https://app.travis-ci.com/nrrccua/eslint-config.svg?branch=master)](https://app.travis-ci.com/nrrccua/eslint-config) [![License](https://img.shields.io/badge/license-MIT-green)](https://github.com/nrrccua/eslint-config/blob/master/LICENSE) [![Downloads](https://img.shields.io/npm/dw/@encoura/eslint-config?color=orange)](https://www.npmjs.com/package/@encoura/eslint-config)

<!-- markdownlint-enable line-length -->

ACT's preferred configs for TypeScript, Prettier, ESLint, CommitLint, and
Encoura's preferred configs for TypeScript, Prettier, ESLint, CommitLint, and
MarkdownLint.

## Getting Started
Expand All @@ -22,10 +16,10 @@ Configure husky by adding the following to your `package.json` file:

```json
...
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
"scripts": {
...
"prepare": "husky",
...
},
...
```
Expand All @@ -43,45 +37,38 @@ module.exports = require('@encoura/eslint-config/commitlint.config');
This will allow CommitLint to discover the configuration this repository
provides from within your `node_modules` folder.

Next, add the following to your `package.json` file so that CommitLint will
check for infractions in your commit messages every time you create a new
commit:
By default the Encoura commitlint expects a commit message in the following format:

```json
...
"husky": {
"hooks": {
...
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS",
...
}
},
...
```
`[XXX-###]: Subject` where XXX-### is a jira ticket id, e.g., `E4E-1`

The commit message may also be in the form of git's standard merge commit format.

## Configure ESLint

To configure [ESLint](https://eslint.org/), add the following to your
`package.json` file. This will allow ESLint to discover the configuration this
repository provides from within your `node_modules` folder, and will check
your `*.js`, `*.ts`, and `*.tsx` files for infractions every time you create a
new commit:
`.eslintrc.js` and `package.json` files. This will allow ESLint to discover the
configuration this repository provides from within your `node_modules` folder,
and will check your `*.js`, `*.ts`, and `*.tsx` files for infractions every
time you create a new commit:

```json
...
"eslintConfig": {
...
"extends": [
...
"@encoura/eslint-config",
...
],
```js
module.exports = {
extends: [
// For front-end (React / Next.js) projects:
'@encoura/eslint-config'
// For back-end (Nest.js) projects:
'@encoura/eslint-config/nest'
]
...
},
// Add any custom rules/plugins/configuration here
}
```

```json
...
"lint-staged": {
...
"*.{js,ts,tsx}": "eslint",
"*.{js,jsx,ts,tsx}": "eslint",
...
},
...
Expand All @@ -107,11 +94,11 @@ a new commit:

## Configure Prettier

To configure [prettier](https://prettier.io/), create a `prettier.config.js`
To configure [prettier](https://prettier.io/), create a `.prettierrc.js`
file in the root of your project that contains the following:

```js
module.exports = require('@encoura/eslint-config/prettier.config');
module.exports = require('@encoura/eslint-config/.prettierrc');
```

This will allow Prettier to discover the configuration this repository
Expand All @@ -124,7 +111,7 @@ your files for infractions every time you create a new commit:
...
"lint-staged": {
...
"*.{js,json,md,ts,tsx}": [
"*.{js,jsx,json,md,ts,tsx}": [
"prettier --write",
"git add"
]
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"markdownlint-cli": "^0.42.0",
"prettier": "^3.3.3"
},
"description": "ACT's preferred configs for TypeScript, Prettier, ESLint, CommitLint, and MarkdownLint.",
"description": "Encoura's preferred configs for TypeScript, Prettier, ESLint, CommitLint, and MarkdownLint.",
"devDependencies": {
"@semantic-release/changelog": "6.0.3",
"@semantic-release/exec": "6.0.3",
Expand Down
10 changes: 9 additions & 1 deletion src/commitlint.config.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
/**
* Copyright (c) ACT, Inc. and its affiliates.
* Copyright (c) Encoura, LLC and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

module.exports = {
extends: ['@commitlint/config-conventional'],
parserPreset: {
parserOpts: {
headerCorrespondence: ['ticket', 'subject'],
headerPattern: /^(\[[A-Z0-9]*-[0-9]*\]):\s(.*)$/,
},
},
rules: {
'subject-case': [2, 'always', 'sentence-case'],
'subject-min-length': [2, 'always', 10],
'type-empty': [0, 'never'],
},
};
Loading

0 comments on commit 2b50775

Please sign in to comment.