Skip to content

Commit

Permalink
build: refactor build scripts + eslint config
Browse files Browse the repository at this point in the history
  • Loading branch information
emagnier committed May 5, 2024
1 parent b9c162b commit dff8341
Show file tree
Hide file tree
Showing 33 changed files with 154 additions and 328 deletions.
4 changes: 2 additions & 2 deletions .commitlintrc.ts
@@ -1,6 +1,6 @@
import { UserConfig, RuleConfigSeverity } from '@commitlint/types';
import { LOCALE_IDS } from './lib/constants/locales';
import { CALENDAR_IDS } from './lib/constants/calendars';
import { LOCALE_IDS } from './rites/roman1969/src/constants/locales';
import { CALENDAR_IDS } from './rites/roman1969/src/constants/calendars';

const empty = [null];
const scopes = [...CALENDAR_IDS, ...LOCALE_IDS, 'calendar', 'l10n', 'util'];
Expand Down
1 change: 1 addition & 0 deletions .eslintrc.js
Expand Up @@ -2,6 +2,7 @@ module.exports = {
extends: ['./packages/config/.eslintrc.js'],
parserOptions: {
root: true,
tsconfigRootDir: __dirname,
project: 'tsconfig.base.json',
},
};
2 changes: 1 addition & 1 deletion .github/workflows/dev-publishing.yml
Expand Up @@ -108,4 +108,4 @@ jobs:
- name: Npm publish a new 'dev' version (romcal + all calendar bundles)
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: node -r ts-node/register rites/roman1969/scripts/publish.ts
run: node -r ts-node/register rites/roman1969/build/publish.ts
2 changes: 1 addition & 1 deletion .npmignore
Expand Up @@ -12,7 +12,7 @@ coverage/
# Main codebase
.github/
lib/
scripts/
build/
tests/
.editorconfig
.eslintignore
Expand Down
306 changes: 77 additions & 229 deletions package-lock.json

Large diffs are not rendered by default.

36 changes: 3 additions & 33 deletions package.json
Expand Up @@ -49,11 +49,11 @@
"typings": "rites/roman1969/dist/index.d.ts",
"scripts": {
"build": "npm run build -w=@romcal/easter && npm run build -w=@romcal/rite-roman1969",
"clean": "npm run clean -w=@romcal/easter && npm run clean -w=@romcal/rite-roman1969",
"clean": "rimraf coverage dist tmp && npm run clean -w=@romcal/easter && npm run clean -w=@romcal/rite-roman1969",
"data:checks": "npm run data:checks -w=@romcal/rite-roman1969",
"doc": "npm run doc -w=@romcal/rite-roman1969",
"lint": "npm run lint -w=@romcal/rite-roman1969",
"lint:fix": "npm run lint -w=@romcal/rite-roman1969 -- --fix",
"lint": "npm run lint -w=@romcal/easter && npm run lint -w=@romcal/rite-roman1969",
"lint:fix": "npm run lint -w=@romcal/easter && npm run lint:fix -w=@romcal/rite-roman1969",
"prepare": "husky",
"prettier": "prettier -c .",
"prettier:fix": "prettier -w .",
Expand All @@ -76,41 +76,11 @@
]
},
"devDependencies": {
"@commitlint/cli": "^19.2.1",
"@commitlint/config-conventional": "^19.1.0",
"@commitlint/types": "^19.0.3",
"@jsdevtools/npm-publish": "^3.1.1",
"@types/cli-progress": "^3.11.5",
"@types/humanize-duration": "^3.27.4",
"@types/jest": "^29.5.12",
"@types/node": "~20.12.7",
"@typescript-eslint/eslint-plugin": "^7.1.0",
"@typescript-eslint/parser": "^7.1.0",
"chalk": "^4.1.2",
"cli-progress": "^3.12.0",
"commitlint-plugin-selective-scope": "^1.0.1",
"dts-bundle-generator": "^9.3.1",
"esbuild": "~0.20.1",
"esbuild-jest": "~0.5.0",
"eslint": "^8.57.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-config-airbnb-typescript": "^18.0.0",
"eslint-config-prettier": "~9.1.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jest": "^28.2.0",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-unused-imports": "^3.1.0",
"glob": "^10.3.10",
"humanize-duration": "^3.31.0",
"husky": "^9.0.11",
"jest": "^29.7.0",
"jest-extended": "^4.0.2",
"prettier": "~3.2.5",
"rimraf": "^5.0.5",
"romcal": "file:",
"ts-node": "^10.9.2",
"tslib": "^2.6.2",
"type-fest": "^4.10.3",
"typescript": "~5.2.2"
},
"engines": {
Expand Down
19 changes: 12 additions & 7 deletions packages/config/.eslintrc.js
@@ -1,14 +1,14 @@
module.exports = {
root: true,
env: {
browser: false,
es6: true,
node: true,
},
parserOptions: {
project: 'tsconfig.base.json',
project: '../../tsconfig.base.json',
sourceType: 'module',
},
ignorePatterns: ['node_modules', 'dist', 'coverage', 'tmp', '__snapshots__', '*.js', '*.json'],
extends: [
'airbnb-base',
// although this is typescript, it has to be here to have it's imported rules configured for
Expand Down Expand Up @@ -42,7 +42,7 @@ module.exports = {
'import/no-extraneous-dependencies': [
'error',
{
devDependencies: ['tests/**', 'scripts/**'],
devDependencies: ['__tests__/**', 'build/**'],
},
],
'import/prefer-default-export': 'off',
Expand Down Expand Up @@ -71,7 +71,7 @@ module.exports = {
// override specific to test files
overrides: [
{
files: ['scripts/**/*.ts', 'src/**/*.ts', '__tests__/**/*.ts'],
files: ['build/**/*.ts', 'src/**/*.ts', '__tests__/**/*.ts'],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint'],
rules: {
Expand Down Expand Up @@ -107,9 +107,9 @@ module.exports = {
// i know the nesting is weird, but this keeps all the tests inheriting ts base configs
overrides: [
{
files: ['scripts/**/*.ts', 'src/types/**/*.ts', 'src/utils/**/*.ts', 'src/constants/**/*.ts'],
files: ['build/**/*.ts', 'src/types/**/*.ts', 'src/utils/**/*.ts', 'src/constants/**/*.ts'],
rules: {
// scripts don't export, and utils are always needed!
// build scripts don't export, and utils are always needed!
// turn this off to see if there's anything unused worth removing
'import/no-unused-modules': 'off',
'no-console': 'off',
Expand All @@ -132,12 +132,17 @@ module.exports = {
},
},
{
files: ['tests/**/*.ts', '**/*.spec.ts'],
files: ['__tests__/**/*.ts', '**/*.spec.ts'],
extends: ['plugin:jest/recommended'],
plugins: ['jest'],
rules: {
'@typescript-eslint/no-non-null-assertion': 'off',

// tests don't export
'import/no-unused-modules': 'off',

// do not complain about importing dist localized calendars
'import/no-relative-packages': 'off',
},
},
],
Expand Down
7 changes: 1 addition & 6 deletions packages/config/jest.config.js
Expand Up @@ -12,11 +12,6 @@ module.exports = {
modulePathIgnorePatterns: [],
testRegex: '((\\.|/)(test|spec))\\.(ts|js)x?$',
coverageDirectory: 'coverage',
collectCoverageFrom: [
'src/**/*.{ts,tsx,js,jsx}',
'build/**/*.{ts,tsx,js,jsx}',
'!**/types/**/*.ts',
'!**/index.ts',
],
collectCoverageFrom: ['src/**/*.{ts,tsx,js,jsx}', 'build/**/*.{ts,tsx,js,jsx}', '!**/types/**/*.ts', '!**/index.ts'],
setupFilesAfterEnv: ['jest-extended/all'],
};
19 changes: 17 additions & 2 deletions packages/config/package.json
Expand Up @@ -3,9 +3,24 @@
"version": "0.0.0",
"description": "Configuration files for the Romcal project",
"scripts": {
"lint": "eslint .",
"lint:fix": "npm run lint -- --fix",
"prettier": "prettier -c .",
"test": "echo \"Error: no test specified\" && exit 1"
},
"dependencies": {},
"devDependencies": {},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^7.8.0",
"@typescript-eslint/parser": "^7.8.0",
"eslint": "^8.57.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-config-airbnb-typescript": "^18.0.0",
"eslint-config-prettier": "~9.1.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jest": "^28.5.0",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-unused-imports": "^3.2.0",
"jest": "^29.7.0",
"jest-extended": "^4.0.2"
},
"license": "MIT"
}
3 changes: 2 additions & 1 deletion packages/easter/.eslintrc.js
@@ -1,7 +1,8 @@
module.exports = {
extends: ['@romcal/config/.eslintrc.js'],
extends: ['../config/.eslintrc.js'],
parserOptions: {
root: true,
tsconfigRootDir: __dirname,
project: 'tsconfig.json',
},
};
7 changes: 6 additions & 1 deletion packages/easter/package.json
Expand Up @@ -6,9 +6,14 @@
"scripts": {
"build": "tsc --project tsconfig.release.json",
"clean": "rimraf coverage dist",
"lint": "eslint .",
"lint:fix": "npm run lint -- --fix",
"prettier": "prettier -c .",
"test": "TZ=UTC jest"
},
"dependencies": {},
"devDependencies": {},
"devDependencies": {
"@romcal/config": "file:../../packages/config"
},
"license": "MIT"
}
2 changes: 2 additions & 0 deletions packages/easter/src/index.ts
@@ -1,3 +1,5 @@
/* eslint-disable import/no-unused-modules */

export type EasterDate = {
year: number;
month: number;
Expand Down
8 changes: 8 additions & 0 deletions rites/roman1962/.eslintrc.js
@@ -0,0 +1,8 @@
module.exports = {
extends: ['../../packages/config/.eslintrc.js'],
parserOptions: {
root: true,
tsconfigRootDir: __dirname,
project: 'tsconfig.json',
},
};
2 changes: 1 addition & 1 deletion rites/roman1962/tsconfig.json
@@ -1,4 +1,4 @@
{
"extends": "../../tsconfig.base.json",
"include": ["build", "src"]
"include": ["__tests__", "build", "src"]
}
1 change: 1 addition & 0 deletions rites/roman1969/.eslintrc.js
Expand Up @@ -2,6 +2,7 @@ module.exports = {
extends: ['../../packages/config/.eslintrc.js'],
parserOptions: {
root: true,
tsconfigRootDir: __dirname,
project: 'tsconfig.json',
},
};
2 changes: 0 additions & 2 deletions rites/roman1969/__tests__/calendar-builder.test.ts
@@ -1,11 +1,9 @@
/* eslint-disable @typescript-eslint/no-non-null-assertion */
import { England_En } from '../dist/bundles/england';
import { GeneralRoman_En } from '../dist/bundles/general-roman';
import { Germany_En } from '../dist/bundles/germany';
import { Hungary_En } from '../dist/bundles/hungary';
import { Ireland_En } from '../dist/bundles/ireland';
import { Slovakia_Sk } from '../dist/bundles/slovakia';

import { CalendarScope, Id, LiturgicalCalendar, LiturgicalDayDef, Romcal, Period, Season, LiturgicalDay } from '../src';
import { dateDifference } from '../src/utils/dates';

Expand Down
2 changes: 0 additions & 2 deletions rites/roman1969/__tests__/calendar-date-overrides.test.ts
@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/no-non-null-assertion */
import { CzechRepublic_Cs } from '../dist/bundles/czech-republic';
import { England_En } from '../dist/bundles/england';
import { France_Fr } from '../dist/bundles/france';
Expand All @@ -10,7 +9,6 @@ import { Mexico_Es } from '../dist/bundles/mexico';
import { Slovakia_Sk } from '../dist/bundles/slovakia';
import { Spain_Es } from '../dist/bundles/spain';
import { Wales_En } from '../dist/bundles/wales';

import { LiturgicalDay, Romcal } from '../src';

const { Ranks, Periods, Precedences, getUtcDateFromString } = Romcal;
Expand Down
2 changes: 0 additions & 2 deletions rites/roman1969/__tests__/dates.test.ts
@@ -1,7 +1,5 @@
/* eslint-disable @typescript-eslint/no-non-null-assertion */
import { France_Fr } from '../dist/bundles/france';
import { UnitedStates_En } from '../dist/bundles/united-states';

import { Romcal } from '../src';

/**
Expand Down
@@ -1,5 +1,4 @@
import { GeneralRoman_La } from '../../dist/bundles/general-roman';

import { Fixture } from '../type/fixture.type';

export const laOrdinalNumberGenderFixture: Fixture = [
Expand Down
Expand Up @@ -11,7 +11,6 @@ import {
GeneralRoman_PtBr,
GeneralRoman_Sk,
} from '../../dist/bundles/general-roman';

import { Fixture } from '../type/fixture.type';

export const seasonalWeekNumberLocalisationFixture: Fixture = [
Expand Down
1 change: 0 additions & 1 deletion rites/roman1969/__tests__/locales.test.ts
@@ -1,6 +1,5 @@
import { Brazil_PtBr } from '../dist/bundles/brazil';
import { France_Fr } from '../dist/bundles/france';

import { Romcal } from '../src';

import { laOrdinalNumberGenderFixture } from './fixtures/la-ordinal-number-gender.fixture';
Expand Down
2 changes: 0 additions & 2 deletions rites/roman1969/__tests__/use-cases.test.ts
@@ -1,6 +1,4 @@
/* eslint-disable @typescript-eslint/no-non-null-assertion */
import { Slovakia_Sk } from '../dist/bundles/slovakia';

import { Romcal } from '../src';

const { Ranks, getUtcDateFromString, isSameDate, subtractsDays } = Romcal;
Expand Down
@@ -1,5 +1,4 @@
/* eslint-disable import/no-extraneous-dependencies */
/* eslint-disable import/no-unused-modules */
import path, { dirname, resolve } from 'node:path';
import fs from 'fs';

Expand Down
@@ -1,5 +1,5 @@
/* eslint-disable import/no-extraneous-dependencies */
/* eslint-disable import/no-unused-modules */

import fs from 'fs';
import path from 'path';

Expand Down
File renamed without changes.
Expand Up @@ -20,9 +20,8 @@
* to distinguish them from the keys that are directly defined in the source files.
*/

/* eslint-disable import/no-extraneous-dependencies */
/* eslint-disable import/no-unused-modules */
/* eslint-disable no-console */
/* eslint-disable import/no-extraneous-dependencies */
import chalk from 'chalk';
import { merge } from 'ts-deepmerge';

Expand Down
@@ -1,3 +1,5 @@
/* eslint-disable import/no-extraneous-dependencies */

import fs from 'fs';
import path from 'path';

Expand Down
@@ -1,3 +1,5 @@
/* eslint-disable import/no-extraneous-dependencies */

import humanizeDuration, { Unit, UnitTranslationOptions } from 'humanize-duration';

/**
Expand Down

0 comments on commit dff8341

Please sign in to comment.