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

Initial Fork Release #16

Merged
merged 11 commits into from
Aug 27, 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
14 changes: 0 additions & 14 deletions .editorconfig

This file was deleted.

1 change: 0 additions & 1 deletion .eslintignore

This file was deleted.

22 changes: 22 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Pull Request Linting
on:
pull_request:
branches: [main]

permissions:
contents: read

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 'lts/*'
- name: Install dependencies
run: npm clean-install
- name: Run linters
run: npm run lint
35 changes: 35 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Automated NPM Release
on:
push:
branches: [main]

permissions:
contents: read

jobs:
release:
name: Release
runs-on: ubuntu-latest
permissions:
contents: write # to be able to publish a GitHub release
issues: write # to be able to comment on released issues
pull-requests: write # to be able to comment on released pull requests
id-token: write # to enable use of OIDC for npm provenance
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 'lts/*'
- name: Install dependencies
run: npm clean-install
- name: Verify the integrity of provenance attestations and registry signatures for installed dependencies
run: npm audit signatures
- name: Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npx semantic-release
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
/.eslintcache
/node_modules
node_modules
1 change: 1 addition & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
commitlint --edit ${1}
1 change: 0 additions & 1 deletion .husky/pre-commit

This file was deleted.

1 change: 1 addition & 0 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npm run lint
11 changes: 0 additions & 11 deletions .npmignore

This file was deleted.

2 changes: 0 additions & 2 deletions .prettierignore

This file was deleted.

3 changes: 0 additions & 3 deletions CHANGELOG.md

This file was deleted.

20 changes: 20 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Contributing

## Commit Messages

Please use [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/) with the [conventional changelog types](https:/conventional-changelog/commitlint/tree/master/@commitlint/config-conventional#type-enum). These allow us to follow [Semantic Versioning](https://semver.org/) in our [automated release pipeline](https://semantic-release.gitbook.io/semantic-release).

You may be asked to rebase your branch if the commit messages need to be fixed (and cannot be addressed with a simple squash merge).

## Pull Request Guidelines

1. A pull request should, ideally, focus on a single improvement or fix. If you have many changes or improvements, consider breaking your work apart and submitting as multiple PRs.
2. If your branch has many commits, please consider rebasing _before_ submitting the pull request. Once a pull request has been made and a reviewer assigned, please _do not_ rebase or rewrite your branch history unless asked.
- Your changes may be squashed on merge to keep the changelog clean.
3. Please give maintainers / reviewers up to 2 weeks to reply. After that, feel free to bump!

## Third-Party Types

Because the upstream [Airbnb eslint config project](https:/airbnb/javascript/blob/master/packages/eslint-config-airbnb-base) provides no type declarations, we've needed to add our own for Typescript to pass validation. These can be found under `types/third-party/eslint-config-airbnb-base/`.

Because the upstream project is rarely updated and this is a temporary solution, these were manually generated by having `tsc` generate declarations from the [rules files](https:/airbnb/javascript/blob/master/packages/eslint-config-airbnb-base/rules/) with one modification to add a trailing [`as const`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-5.html#const-assertions-and-default-type-arguments-in-jsdoc) on the exported object literals. If we need to update these in the future, it's likely we should actually contribute to the upstream or make a submission to the [DefinitelyTyped](https:/DefinitelyTyped/DefinitelyTyped).
27 changes: 14 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# eslint-config-airbnb-typescript
# Typescript Compatible Airbnb Rules for ESLint

[![Version](https://img.shields.io/npm/v/eslint-config-airbnb-typescript.svg?style=flat-square)](https://www.npmjs.com/package/eslint-config-airbnb-typescript?activeTab=versions) [![Downloads](https://img.shields.io/npm/dt/eslint-config-airbnb-typescript.svg?style=flat-square)](https://www.npmjs.com/package/eslint-config-airbnb-typescript) [![Last commit](https://img.shields.io/github/last-commit/iamturns/eslint-config-airbnb-typescript.svg?style=flat-square)](https:/iamturns/eslint-config-airbnb-typescript/graphs/commit-activity) [![Build](https://img.shields.io/circleci/project/github/iamturns/eslint-config-airbnb-typescript/master.svg?style=flat-square)](https://circleci.com/gh/iamturns/eslint-config-airbnb-typescript) [![License](https://img.shields.io/github/license/iamturns/eslint-config-airbnb-typescript.svg?style=flat-square)](https:/iamturns/eslint-config-airbnb-typescript/blob/master/LICENSE) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](https:/iamturns/eslint-config-airbnb-typescript/blob/master/CONTRIBUTING.md) [![Code of conduct](https://img.shields.io/badge/code%20of-conduct-ff69b4.svg?style=flat-square)](https:/iamturns/eslint-config-airbnb-typescript/blob/master/CODE_OF_CONDUCT.md)
[![Version](https://img.shields.io/npm/v/@kesills/eslint-config-airbnb-typescript.svg?style=flat-square)](https://www.npmjs.com/package/@kesills/eslint-config-airbnb-typescript?activeTab=versions) [![Downloads](https://img.shields.io/npm/dm/@kesills/eslint-config-airbnb-typescript.svg?style=flat-square)](https://www.npmjs.com/package/@kesills/eslint-config-airbnb-typescript)

Enhances [Airbnb's ESLint config](https://www.npmjs.com/package/eslint-config-airbnb) with TypeScript support.
Forked from the generous work of [Matt Turnbull](https:/iamturns/eslint-config-airbnb-typescript)!

> [!WARNING]
> We currently **do not** support ESLint v9 or above. Please see issue #331 to track progress.
> We currently **do not** support ESLint v9 or above. Please see issue #15 to track progress.

## Setup

Expand All @@ -14,7 +15,7 @@ Enhances [Airbnb's ESLint config](https://www.npmjs.com/package/eslint-config-ai
Start by installing both ESLint and Typescript in your project. Afterwards, you can install this config through your favorite package manager normally:

```sh
npm install -D eslint-config-airbnb-typescript
npm install -D @kesills/eslint-config-airbnb-typescript
```

If you're using React, you'll also need to install the appropriate Airbnb rules separately:
Expand Down Expand Up @@ -44,7 +45,7 @@ Next, tell ESLint to extend from this configuration. And since we need to access

#### Recommended - Flat Config

Since we don't yet have first-class support for the new flat configuration format (see #307 for progress), [ESLint's compatability utility](https://www.npmjs.com/package/@eslint/eslintrc) is needed:
Since we don't yet have first-class support for the new flat configuration format (see #14 for progress), [ESLint's compatability utility](https://www.npmjs.com/package/@eslint/eslintrc) is needed:

```sh
npm install -D @eslint/eslintrc
Expand All @@ -62,11 +63,11 @@ const compat = new FlatCompat({
export default [
// Without React
...compat.extends('airbnb-base'),
...compat.extends('airbnb-typescript/base'),
...compat.extends('@kesills/airbnb-typescript/base'),

// With React
...compat.extends('airbnb'),
...compat.extends('airbnb-typescript'),
...compat.extends('@kesills/airbnb-typescript'),

// Either way
{
Expand All @@ -89,11 +90,11 @@ module.exports = {
extends: [
// Without React
'airbnb-base',
'airbnb-typescript/base'
'@kesills/airbnb-typescript/base'

// With React
'airbnb',
'airbnb-typescript'
'@kesills/airbnb-typescript'
],
parserOptions: {
projectService: true,
Expand Down Expand Up @@ -133,7 +134,7 @@ import typescriptPlugin from 'typescript-eslint';
export default [
...compat.extends('airbnb-base'),
...compat.extends('airbnb/hooks'),
...compat.extends('airbnb-typescript/base'),
...compat.extends('@kesills/airbnb-typescript/base'),
...typescriptPlugin.configs.recommendedTypeChecked,
...typescriptPlugin.configs.stylisticTypeChecked,
{
Expand Down Expand Up @@ -196,10 +197,10 @@ If you would like to enable this rule, then:

## Credits

Authored and maintained by Matt Turnbull ([iamturns.com](https://iamturns.com) / [@iamturns](https://twitter.com/iamturns))
Originally authored by Matt Turnbull. Forked and maintained by Kenneth Sills.

A big thank you to all [contributors](https:/iamturns/eslint-config-airbnb-typescript/graphs/contributors)!
A big thank you to all [contributors](https:/Kenneth-Sills/eslint-config-airbnb-typescript/graphs/contributors)!

## License

Open source [licensed as MIT](https:/iamturns/eslint-config-airbnb-typescript/blob/master/LICENSE).
Open source [licensed as MIT](./LICENSE).
2 changes: 1 addition & 1 deletion base.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = {
extends: ['./lib/shared.js'].map(require.resolve),
extends: ['./lib/shared.js'].map((path) => require.resolve(path)),
};
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// This file adds some React specific settings. Not using React? Use base.js instead.
module.exports = {
extends: ['./lib/shared'].map(require.resolve),
extends: ['./lib/shared'].map((path) => require.resolve(path)),
settings: {
// Append 'ts' extensions to Airbnb 'import/resolver' setting
// Prepend 'mjs' to match shared config
Expand Down
30 changes: 20 additions & 10 deletions lib/shared.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
/* eslint-disable import/no-extraneous-dependencies */
const { rules: baseBestPracticesRules } = require('eslint-config-airbnb-base/rules/best-practices');
const { rules: baseErrorsRules } = require('eslint-config-airbnb-base/rules/errors');
const { rules: baseES6Rules } = require('eslint-config-airbnb-base/rules/es6');
const { rules: baseImportsRules } = require('eslint-config-airbnb-base/rules/imports');
const { rules: baseStyleRules } = require('eslint-config-airbnb-base/rules/style');
const { rules: baseVariablesRules } = require('eslint-config-airbnb-base/rules/variables');
/* eslint-enable import/no-extraneous-dependencies */

module.exports = {
plugins: ['@typescript-eslint', '@stylistic'],
Expand All @@ -15,16 +13,19 @@ module.exports = {
'import/parsers': {
'@typescript-eslint/parser': ['.ts', '.tsx', '.d.ts'],
},

// Append 'ts' extensions to Airbnb 'import/resolver' setting
// Original: ['.mjs', '.js', '.json']
'import/resolver': {
node: {
extensions: ['.mjs', '.js', '.json', '.ts', '.d.ts'],
},
},

// Append 'ts' extensions to Airbnb 'import/extensions' setting
// Original: ['.js', '.mjs', '.jsx']
'import/extensions': ['.js', '.mjs', '.jsx', '.ts', '.tsx', '.d.ts'],

// Resolve type definition packages
'import/external-module-folders': ['node_modules', 'node_modules/@types'],
},
Expand Down Expand Up @@ -181,14 +182,23 @@ module.exports = {
...baseImportsRules['import/no-extraneous-dependencies'][1],
devDependencies: baseImportsRules[
'import/no-extraneous-dependencies'
][1].devDependencies.reduce((result, devDep) => {
const toAppend = [devDep];
const devDepWithTs = devDep.replace(/\bjs(x?)\b/g, 'ts$1');
if (devDepWithTs !== devDep) {
toAppend.push(devDepWithTs);
}
return [...result, ...toAppend];
}, []),
][1].devDependencies.reduce(
/**
* @param {string[]} result
* @param {string} devDep
*/
(result, devDep) => {
const toAppend = [devDep];
const devDepWithTs = devDep.replace(/\bjs(x?)\b/g, 'ts$1');

if (devDepWithTs !== devDep) {
toAppend.push(devDepWithTs);
}

return [...result, ...toAppend];
},
[],
),
},
],
},
Expand Down
7 changes: 0 additions & 7 deletions lint-staged.config.js

This file was deleted.

Loading
Loading