Skip to content
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
40 changes: 40 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Lint

on:
pull_request:
types: [opened, synchronize]
paths:
- '**/*.[tj]s'
- '**/*.?[tj]s'
- 'eslint.config.mjs'
- 'tsconfig.json'
- 'package.json'
- 'package-lock.json'
- '.nvmrc'
- '.github/workflows/lint.yml'

jobs:
lint:
runs-on: blacksmith-2vcpu-ubuntu-2404
steps:
- name: Checkout
# 6.0.3
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10

# v6.1.0
- name: Setup Node
uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f
with:
node-version-file: .nvmrc
cache: npm
cache-dependency-path: package-lock.json

- name: Install npm packages
run: npm ci

- name: Lint
run: npm run lint

- name: Tell people how to run the failing check
if: failure()
run: echo "::error::The lint check failed! To run it locally, run \`npm ci && npm run lint\` from the GitHub-Actions repo root."
48 changes: 48 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import {createRequire} from 'node:module';
import path from 'node:path';
import {fileURLToPath} from 'node:url';

import jestConfig from 'eslint-config-expensify/jest';
import nodeConfig from 'eslint-config-expensify/node';
import scriptsConfig from 'eslint-config-expensify/scripts';
import tsConfig from 'eslint-config-expensify/typescript';
import rulesdir from 'eslint-plugin-rulesdir';
import {defineConfig, globalIgnores} from 'eslint/config';

const projectRoot = path.dirname(fileURLToPath(import.meta.url));
const require = createRequire(import.meta.url);
const expensifyConfigDirectory = path.dirname(require.resolve('eslint-config-expensify'));

// eslint-config-expensify/typescript enables custom Expensify rules (rulesdir/*) such as
// rulesdir/prefer-at, but the typescript config slice does not register eslint-plugin-rulesdir
// itself (that wiring lives in eslint-config-expensify/expensify, which we do not use here).
// Register the plugin and point it at eslint-config-expensify's bundled rule implementations
// so ESLint can resolve those rules. eslint-plugin-rulesdir is a transitive dependency of
// eslint-config-expensify; it does not need a direct package.json entry.
rulesdir.RULES_DIR = path.resolve(expensifyConfigDirectory, 'eslint-plugin-expensify');

export default defineConfig([
globalIgnores(['node_modules']),
{
plugins: {
rulesdir,
},
},
...nodeConfig,
...tsConfig,
...scriptsConfig,
...jestConfig,
{
files: ['**/*.ts'],
languageOptions: {
parserOptions: {
project: path.resolve(projectRoot, 'tsconfig.json'),
projectService: false,
},
},
rules: {
// node:test is used instead of Jest in this repo.
'jest/no-jest-import': 'off',
},
},
]);
Loading
Loading