diff --git a/.eslintrc.json b/.eslintrc.json index 612410d8..b0bac723 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,5 +1,5 @@ { - "extends": "./projects/ng-dev/src/eslint-config.json", + "extends": "./projects/eslint-config-ng", "overrides": [ { "files": ["*.ts"], diff --git a/CHANGELOG.md b/CHANGELOG.md index 108f6eb6..88cba2c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,9 +6,9 @@ All notable changes to this project will be documented in this file. See [standa ### ⚠ BREAKING CHANGES -- **ng-dev:** ESLint is no longer installed automatically with `ng-dev`. The old TSLint and ESLint configs are deprecated, but you can continue to use them for now if you install the old dependencies via your own `package.json`. The were: `"@typescript-eslint/eslint-plugin": "^4.8.0"`, "@typescript-eslint/parser": "^4.6.0"`, and `"eslint": "^7.14.0"`. Consult the README for instructions to set up the new ESLint config at your convenience; the old configs will be removed from this library in a future version. +- **ng-dev:** Linting config is now provided by [`@s-libs/eslint-config-ng`](https://github.com/simontonsoftware/s-libs/tree/master/projects/eslint-config-ng). The old TSLint and ESLint configs are still available in `ng-dev`, but are deprecated. ESLint is no longer installed automatically with `ng-dev`, so to continue using its deprecated config you'll need to install the old dependencies via your own `package.json`. They were: `"@typescript-eslint/eslint-plugin": "^4.8.0"`, `"@typescript-eslint/parser": "^4.6.0"`, and `"eslint": "^7.14.0"`. Consult the [README for eslint-config-ng](https://github.com/simontonsoftware/s-libs/tree/master/projects/eslint-config-ng) to to switch to the new configs. The old ones will be removed from this library in a future version. - all 3rd party dependencies require bumped version numbers -- **ng-core:** `AngularContextNext` and `ComponentContextNext` are renamed to replace their old, deprecated versions. If you are still using the old ones, switch to the "Next" versions and get your tests passing before upgrading to `@s-libs` version 12. Once you are on the "Next" versions, this upgrade only requires removing "Next" from the ends of the names. +- **ng-core:** `AngularContextNext` and `ComponentContextNext` are renamed to replace their old, deprecated versions. If you are still using the old ones, switch to the "Next" versions and get your tests passing before upgrading to `@s-libs` version 12. Once you are on the "Next" versions, this upgrade only requires removing "Next" from the ends of their names. ### Features diff --git a/README.md b/README.md index ab29de94..6454e837 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,7 @@ This is a collection of libraries from Simonton Software, written in TypeScript - [`ng-core`](https://github.com/simontonsoftware/s-libs/tree/master/projects/ng-core): Miscellaneous utilities for Angular - [`ng-app-state`](https://github.com/simontonsoftware/s-libs/tree/master/projects/ng-app-state): Painlessly integrate `app-state` into template-driven Angular forms - [`ng-dev`](https://github.com/simontonsoftware/s-libs/tree/master/projects/ng-dev): Miscellaneous utilities to use while developing Angular apps +- [`eslint-config-ng`](https://github.com/simontonsoftware/s-libs/tree/master/projects/eslint-config-dev): ## Upgrading from the loose packages diff --git a/TODO.md b/TODO.md index 970bddb4..4e9cac0f 100644 --- a/TODO.md +++ b/TODO.md @@ -10,3 +10,4 @@ - coveralls - help may be here, to combine multiple coverage runs into one report: https://github.com/angular/angular-cli/issues/11268 - Watch for when typedoc can support that "lib" mode that would eliminate the need for @hidden +- Remove upgrade notes from the old standalone packages diff --git a/projects/eslint-config-ng/README.md b/projects/eslint-config-ng/README.md new file mode 100644 index 00000000..75cc52e3 --- /dev/null +++ b/projects/eslint-config-ng/README.md @@ -0,0 +1,32 @@ +This library provides some default config you can use for ESLint in an Angular project. It gives you all the recommended, community-standard rules from ESLint, +@typescript-eslint, and @angular-eslint/recommended, plus these additions and changes: + +- code complexity rules to keep your functions and files focused and readable +- relaxed rules around `ban-types` that Simonton Software has found unuseful + +# Installation + +1. First install [Angular ESLint](https://github.com/angular-eslint/angular-eslint) following their instructions for your situation. Make sure it is working with their minimal config. +1. `yarn add -D @s-libs/eslint-config-ng` +1. Change `.eslintrc.json` in your root directory to this, and make adjustments to suit your needs: + + ```json + { + "extends": "@s-libs/eslint-config-ng", + "overrides": [ + { + "files": ["*.ts"], + "rules": { + "@angular-eslint/directive-selector": [ + "error", + { "type": "attribute", "prefix": "app", "style": "camelCase" } + ], + "@angular-eslint/component-selector": [ + "error", + { "type": "element", "prefix": "app", "style": "kebab-case" } + ] + } + } + ] + } + ``` diff --git a/projects/ng-dev/src/eslint-config.json b/projects/eslint-config-ng/index.json similarity index 100% rename from projects/ng-dev/src/eslint-config.json rename to projects/eslint-config-ng/index.json diff --git a/projects/eslint-config-ng/package.json b/projects/eslint-config-ng/package.json new file mode 100644 index 00000000..9b6f8df5 --- /dev/null +++ b/projects/eslint-config-ng/package.json @@ -0,0 +1,19 @@ +{ + "name": "@s-libs/eslint-config-ng", + "version": "12.0.0-next.0", + "author": "Simonton Software", + "license": "MIT", + "homepage": "https://github.com/simontonsoftware/s-libs/tree/master/projects/eslint-config-ng", + "repository": { + "type": "git", + "url": "https://github.com/simontonsoftware/s-libs.git", + "directory": "projects/eslint-config-ng" + }, + "peerDependencies": { + "@angular-eslint/eslint-plugin": "^12.0.0", + "@angular-eslint/eslint-plugin-template": "^12.0.0", + "@typescript-eslint/eslint-plugin": "^4.23.0", + "@typescript-eslint/parser": "4.23.0", + "eslint": "^7.26.0" + } +} diff --git a/projects/ng-dev/README.md b/projects/ng-dev/README.md index f4ec672e..893eda85 100644 --- a/projects/ng-dev/README.md +++ b/projects/ng-dev/README.md @@ -5,19 +5,6 @@ To quickly see what is available, see the [api documentation](https://simontonso ## Installation ``` -yarn add -D @s-libs/ng-dev @s-libs/ng-core @s-libs/rxjs-core @s-libs/js-core @s-libs/micro-dash @angular/cdk +yarn add @s-libs/ng-core @s-libs/rxjs-core @s-libs/js-core @s-libs/micro-dash @angular/cdk +yarn add -D @s-libs/ng-dev ``` - -## ESLint Config - -This library comes with some default config you can use for ESLint. It to use it, first install [Angular ESLint](https://github.com/angular-eslint/angular-eslint) following their instructions for your situation. Make sure it is working with their minimal config, then change `.eslintrc.json` in your root directory to this: - -```json -{ "extends": "@s-libs/ng-dev/eslint-config.json" } -``` - -This will give you all the recommended, community-standard rules from ESLint, "eslint:recommended", -@typescript-eslint, and @angular-eslint/recommended, plus these additions and changes: - -- code complexity rules to keep your functions and files focused and readable -- relaxed rules around `ban-types` that Simonton Software has found unuseful diff --git a/scripts/build-libs.ts b/scripts/build-libs.ts index 70e13f72..fd342792 100644 --- a/scripts/build-libs.ts +++ b/scripts/build-libs.ts @@ -1,5 +1,5 @@ -import { libraries, runCommand } from './shared'; +import { buildableLibraries, runCommand } from './shared'; -for (const project of libraries) { +for (const project of buildableLibraries) { runCommand(`yarn build --configuration production ${project}`); } diff --git a/scripts/copy-eslint-config.ts b/scripts/copy-eslint-config.ts new file mode 100644 index 00000000..18810ac1 --- /dev/null +++ b/scripts/copy-eslint-config.ts @@ -0,0 +1,27 @@ +import { copyFileSync, mkdirSync, readdirSync, rmdirSync } from 'fs'; +import { join } from 'path'; + +export function copyEslintConfig() { + const targetFolder = 'dist/eslint-config-ng'; + rmdirSync(targetFolder, { recursive: true }); + mkdirSync(targetFolder); + + const srcFolder = 'projects/eslint-config-ng'; + for (const file of readdirSync(srcFolder)) { + copyFileSync(join(srcFolder, file), join(targetFolder, file)); + } + + // deprecated config + copyFileSync( + 'projects/ng-dev/deprecated-config/.eslintrc.js', + 'dist/ng-dev/.eslintrc.js', + ); + copyFileSync( + 'projects/ng-dev/deprecated-config/tslint.angularcli.json', + 'dist/ng-dev/tslint.angularcli.json', + ); + copyFileSync( + 'projects/ng-dev/deprecated-config/tslint.json', + 'dist/ng-dev/tslint.json', + ); +} diff --git a/scripts/copy-extra-dist-files.ts b/scripts/copy-extra-dist-files.ts deleted file mode 100644 index 865c4c18..00000000 --- a/scripts/copy-extra-dist-files.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { copyEslintConfig } from './shared'; - -copyEslintConfig(); diff --git a/scripts/docs-libs.ts b/scripts/docs-libs.ts index 899053c5..a0f1cc47 100644 --- a/scripts/docs-libs.ts +++ b/scripts/docs-libs.ts @@ -1,8 +1,8 @@ -import { libraries, runCommand } from './shared'; +import { buildableLibraries, runCommand } from './shared'; let projects = process.argv.slice(2); if (projects.length === 0) { - projects = libraries; + projects = buildableLibraries; } for (const project of projects) { diff --git a/scripts/publish-libs.ts b/scripts/publish-libs.ts index 747ac693..82319c48 100644 --- a/scripts/publish-libs.ts +++ b/scripts/publish-libs.ts @@ -1,4 +1,5 @@ -import { copyEslintConfig, getInput, libraries, runCommand } from './shared'; +import { copyEslintConfig } from './copy-eslint-config'; +import { getInput, libraries, runCommand } from './shared'; async function run(): Promise { copyEslintConfig(); diff --git a/scripts/shared.ts b/scripts/shared.ts index 0c00670d..81fbfc66 100644 --- a/scripts/shared.ts +++ b/scripts/shared.ts @@ -1,9 +1,8 @@ import { execSync } from 'child_process'; -import { copyFileSync } from 'fs'; import { createInterface } from 'readline'; // in dependency order -export const libraries = [ +export const buildableLibraries = [ 'micro-dash', 'js-core', 'rxjs-core', @@ -13,6 +12,8 @@ export const libraries = [ 'ng-dev', ]; +export const libraries = [...buildableLibraries, 'eslint-config-ng']; + export function runCommand(command: string): void { execSync(command, { stdio: 'inherit' }); } @@ -26,22 +27,3 @@ export function getInput(text: string): Promise { }); }); } - -export function copyEslintConfig() { - copyFileSync( - 'projects/ng-dev/src/eslint-config.json', - 'dist/ng-dev/eslint-config.json', - ); - copyFileSync( - 'projects/ng-dev/deprecated-config/.eslintrc.js', - 'dist/ng-dev/.eslintrc.js', - ); - copyFileSync( - 'projects/ng-dev/deprecated-config/tslint.angularcli.json', - 'dist/ng-dev/tslint.angularcli.json', - ); - copyFileSync( - 'projects/ng-dev/deprecated-config/tslint.json', - 'dist/ng-dev/tslint.json', - ); -}