Skip to content

Commit

Permalink
feat(ref: #188): add strict eslint rules
Browse files Browse the repository at this point in the history
  • Loading branch information
andriikamaldinov1 committed Oct 28, 2024
1 parent b5f37f1 commit 25b6ab4
Show file tree
Hide file tree
Showing 31 changed files with 321 additions and 223 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@ jobs:
run: |
bun i
bun run build:lib
- name: Setup npm token
run: |
echo "//registry.npmjs.org/:_authToken=${{ secrets.npm_token }}" > dist/ngx-mask-lib/.npmrc
- name: Publish library
run: bun run publish:lib
run: bun publish:lib
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}

Expand Down
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ bootstrapApplication(AppComponent, {
### Passing your own mask config options

```typescript
import { IConfig } from 'ngx-mask'
import { Config } from 'ngx-mask'

const maskConfig: Partial<IConfig> = {
const maskConfig: Partial<Config> = {
validation: false,
};

Expand All @@ -90,7 +90,7 @@ bootstrapApplication(AppComponent, {
### Using a function to configure:

```typescript
const maskConfigFunction: () => Partial<IConfig> = () => {
const maskConfigFunction: () => Partial<Config> = () => {
return {
validation: false,
};
Expand Down Expand Up @@ -144,9 +144,9 @@ Import **ngx-mask** module in Angular app.
### With default mask config options

```typescript
import { NgxMaskModule, IConfig } from 'ngx-mask'
import { NgxMaskModule, Config } from 'ngx-mask'

export const options: Partial<null|IConfig> | (() => Partial<IConfig>) = null;
export const options: Partial<null|Config> | (() => Partial<Config>) = null;

@NgModule({
imports: [
Expand All @@ -158,9 +158,9 @@ export const options: Partial<null|IConfig> | (() => Partial<IConfig>) = null;
### Passing in your own mask config options

```typescript
import { NgxMaskModule, IConfig } from 'ngx-mask'
import { NgxMaskModule, Config } from 'ngx-mask'

const maskConfig: Partial<IConfig> = {
const maskConfig: Partial<Config> = {
validation: false,
};

Expand All @@ -174,7 +174,7 @@ const maskConfig: Partial<IConfig> = {
Or using a function to get the config:

```typescript
const maskConfigFunction: () => Partial<IConfig> = () => {
const maskConfigFunction: () => Partial<Config> = () => {
return {
validation: false,
};
Expand Down
Binary file modified bun.lockb
Binary file not shown.
26 changes: 17 additions & 9 deletions cypress.config.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
import { defineConfig } from 'cypress';
import { defineConfig } from "cypress";

export default defineConfig({
projectId: 'qhyo66',
component: {
devServer: {
framework: 'angular',
bundler: 'webpack',
},
specPattern: 'projects/ngx-mask-lib/src/test/**/*.cy-spec.ts',
projectId: "qhyo66",

component: {
devServer: {
framework: "angular",
bundler: "webpack",
},
specPattern: "projects/ngx-mask-lib/src/test/**/*.cy-spec.ts",
},

defaultCommandTimeout: 10000,

e2e: {
setupNodeEvents(on, config) {

Check failure on line 17 in cypress.config.ts

View workflow job for this annotation

GitHub Actions / quality-check

'on' is defined but never used. Allowed unused args must match /^_/u

Check failure on line 17 in cypress.config.ts

View workflow job for this annotation

GitHub Actions / quality-check

'config' is defined but never used. Allowed unused args must match /^_/u
// implement node event listeners here
},
defaultCommandTimeout: 10000,
},
});
95 changes: 84 additions & 11 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ module.exports = tseslint.config(
// and treated as if they are HTML files (and therefore have the .html config below applied to them)
processor: angular.processInlineTemplates,
// Override specific rules for TypeScript files (these will take priority over the extended configs above)
languageOptions: {
parserOptions: {
project: ['./tsconfig.eslint.json'],
},
},
rules: {
'@angular-eslint/component-selector': [
'error',
Expand All @@ -68,25 +73,93 @@ module.exports = tseslint.config(
type: 'attribute',
},
],
'@typescript-eslint/prefer-for-of': 'off',
'@typescript-eslint/no-unused-vars': [
'@typescript-eslint/consistent-type-definitions': ['error', 'type'],
'@typescript-eslint/ban-ts-comment': ['error', { minimumDescriptionLength: 10 }],
'@typescript-eslint/no-array-constructor': 'error',
'@typescript-eslint/no-duplicate-enum-values': 'error',
'@typescript-eslint/no-empty-object-type': 'error',
'@typescript-eslint/no-extra-non-null-assertion': 'error',
'@typescript-eslint/no-misused-new': 'error',
'@typescript-eslint/no-namespace': 'error',
'@typescript-eslint/no-non-null-asserted-nullish-coalescing': 'error',
'@typescript-eslint/no-non-null-asserted-optional-chain': 'error',
'@typescript-eslint/no-non-null-assertion': 'error',
'@typescript-eslint/no-this-alias': 'error',
'@typescript-eslint/no-unnecessary-type-constraint': 'error',
'@typescript-eslint/no-unsafe-declaration-merging': 'error',
'@typescript-eslint/no-useless-constructor': 'error',
'@typescript-eslint/no-wrapper-object-types': 'error',
'@typescript-eslint/prefer-as-const': 'error',
'@typescript-eslint/prefer-namespace-keyword': 'error',
'@typescript-eslint/triple-slash-reference': 'error',
'no-array-constructor': 'off',
'no-useless-constructor': 'off',
'no-return-await': 'error',
'no-useless-catch': 'error',
'no-unused-labels': 'error',
'no-unneeded-ternary': 'error',
'no-undef-init': 'error',
'no-regex-spaces': 'error',
'no-proto': 'error',
'no-new-wrappers': 'error',
'no-unused-private-class-members': 'error',
'no-invalid-regexp': 'error',
curly: ['error', 'all'],
'@typescript-eslint/restrict-template-expressions': 'error',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/adjacent-overload-signatures': 'error',
'no-console': ['warn'],
'@typescript-eslint/explicit-member-accessibility': 'error',
'@typescript-eslint/no-inferrable-types': ['error', { ignoreParameters: true }],
'no-unused-vars': 'off',
'no-duplicate-imports': 'off',
'@typescript-eslint/no-invalid-void-type': 'off',
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
'@typescript-eslint/no-require-imports': 'error',
'@typescript-eslint/indent': 0,
'@typescript-eslint/member-delimiter-style': 0,
'@typescript-eslint/no-var-requires': 0,
'@typescript-eslint/no-use-before-define': 0,
'prefer-const': 1,
'prefer-spread': 1,
'@typescript-eslint/naming-convention': [
'error',
{
argsIgnorePattern: '^_',
selector: 'interface',
format: ['PascalCase'],
custom: {
regex: '^I[A-Z]',
match: true,
},
},
],
'@typescript-eslint/no-empty-function': [
'error',
{
allow: ['arrowFunctions', 'functions', 'methods'],
},
],
'@typescript-eslint/no-explicit-any': [
'import/no-unresolved': 'off',
'import/no-extraneous-dependencies': 'off',
'import/prefer-default-export': 'off',
'no-underscore-dangle': 'off',
'class-methods-use-this': 'off',
'lines-between-class-members': 'off',
'no-return-assign': 'off',
'no-unused-expressions': ['error', { allowShortCircuit: true, allowTernary: true }],

//THINK ABOUT THIS
'no-param-reassign': 'off',
'no-undefined': 'off',
// 'no-param-reassign': 'error', 43
// 'no-undefined': 'error', 9

'@typescript-eslint/no-unused-expressions': 'error',
'@typescript-eslint/array-type': 'error',
'@typescript-eslint/consistent-type-assertions': [
'error',
{
ignoreRestArgs: true,
assertionStyle: 'as',
},
],
'no-plusplus': ['off'],
'@typescript-eslint/unbound-method': 'off',
'import/no-cycle': 'off',
'import/extensions': 'off',
},
},
{
Expand Down
84 changes: 42 additions & 42 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"pack:lib": "cd dist/ngx-mask-lib && npm pack",
"precommit-msg": "echo 'Please wait while we do our pre-commit checks...' && exit 0",
"prettier": "prettier './src/**/*.ts' './projects/**/*.ts' --write",
"publish:lib": "cd dist/ngx-mask-lib && npm publish",
"publish:lib": "cd dist/ngx-mask-lib && bun publish",
"release:major": "bun run version:major && bun run build:lib && bun run pack:lib && bun run publish:lib",
"release:minor": "bun run version:minor && bun run build:lib && bun run pack:lib && bun run publish:lib",
"release:patch": "bun run version:patch && bun run build:lib && bun run pack:lib && bun run publish:lib",
Expand All @@ -60,67 +60,67 @@
"url": "https://github.com/JsDaddy/ngx-mask.git"
},
"dependencies": {
"@angular/animations": "18.1.1",
"@angular/common": "18.1.1",
"@angular/compiler": "18.1.1",
"@angular/core": "18.1.1",
"@angular/forms": "18.1.1",
"@angular/platform-browser": "18.1.1",
"@angular/platform-browser-dynamic": "18.1.1",
"@angular/router": "18.1.1",
"@types/jest": "^29.5.12",
"@types/mocha": "^10.0.7",
"@angular/animations": "18.2.9",
"@angular/common": "18.2.9",
"@angular/compiler": "18.2.9",
"@angular/core": "18.2.9",
"@angular/forms": "18.2.9",
"@angular/platform-browser": "18.2.9",
"@angular/platform-browser-dynamic": "18.2.9",
"@angular/router": "18.2.9",
"@types/jest": "^29.5.14",
"@types/mocha": "^10.0.9",
"ajv": "^8.17.1",
"cypress": "^13.13.1",
"cypress": "^13.15.1",
"highlight.js": "11.10.0",
"ngx-highlightjs": "12.0.0",
"rxjs": "7.8.1",
"semantic-release": "24.0.0",
"semantic-release": "24.2.0",
"semantic-release-export-data": "^1.1.0",
"snyk": "^1.1292.1"
"snyk": "^1.1294.0"
},
"devDependencies": {
"@angular-devkit/build-angular": "18.1.1",
"@angular-eslint/builder": "18.1.0",
"@angular-eslint/eslint-plugin": "18.1.0",
"@angular-eslint/eslint-plugin-template": "18.1.0",
"@angular-eslint/schematics": "18.1.0",
"@angular-eslint/template-parser": "18.1.0",
"@angular/cli": "18.1.1",
"@angular/compiler-cli": "18.1.1",
"@angular/language-service": "18.1.1",
"@commitlint/cli": "19.3.0",
"@commitlint/config-conventional": "19.2.2",
"@angular-devkit/build-angular": "18.2.10",
"@angular-eslint/builder": "18.4.0",
"@angular-eslint/eslint-plugin": "18.4.0",
"@angular-eslint/eslint-plugin-template": "18.4.0",
"@angular-eslint/schematics": "18.4.0",
"@angular-eslint/template-parser": "18.4.0",
"@angular/cli": "18.2.10",
"@angular/compiler-cli": "18.2.9",
"@angular/language-service": "18.2.9",
"@commitlint/cli": "19.5.0",
"@commitlint/config-conventional": "19.5.0",
"@jscutlery/cypress-angular": "^0.9.22",
"@types/highlight.js": "9.12.4",
"@types/jasmine": "5.1.4",
"@types/node": "20.14.12",
"@typescript-eslint/eslint-plugin": "7.17.0",
"@typescript-eslint/parser": "7.17.0",
"@web/test-runner": "^0.18.2",
"angular-cli-ghpages": "2.0.1",
"@types/node": "22.8.1",
"@typescript-eslint/eslint-plugin": "8.11.0",
"@typescript-eslint/parser": "8.11.0",
"@web/test-runner": "^0.19.0",
"angular-cli-ghpages": "2.0.3",
"angular-http-server": "1.12.0",
"eslint": "9.7.0",
"eslint": "9.13.0",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-json": "4.0.0",
"eslint-plugin-json": "4.0.1",
"eslint-plugin-prettier": "5.2.1",
"jasmine-core": "5.2.0",
"jasmine-core": "5.4.0",
"jasmine-spec-reporter": "7.0.0",
"lint-staged": "15.2.7",
"markdownlint-cli": "0.41.0",
"ng-packagr": "18.1.0",
"npm-check-updates": "^16.14.20",
"lint-staged": "15.2.10",
"markdownlint-cli": "0.42.0",
"ng-packagr": "18.2.1",
"npm-check-updates": "^17.1.8",
"postcss-scss": "4.0.9",
"prettier": "3.3.3",
"puppeteer": "22.13.1",
"stylelint": "16.7.0",
"puppeteer": "23.6.0",
"stylelint": "16.10.0",
"stylelint-config-prettier": "9.0.5",
"stylelint-config-recommended-scss": "14.1.0",
"stylelint-prettier": "5.0.2",
"type-coverage": "^2.29.1",
"type-coverage": "^2.29.7",
"typescript": "5.5.4",
"angular-eslint": "^18.1.0",
"typescript-eslint": "^7.17.0",
"angular-eslint": "^18.4.0",
"typescript-eslint": "^8.11.0",
"tailwindcss": "^3.4.14"
},
"typeCoverage": {
Expand Down
2 changes: 1 addition & 1 deletion projects/ngx-mask-lib/src/lib/custom-keyboard-event.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
declare let global: any;

const commonjsGlobal =
Expand All @@ -14,6 +13,7 @@ const commonjsGlobal =

(function () {
if (!commonjsGlobal.KeyboardEvent) {
// eslint-disable-next-line @typescript-eslint/no-empty-function
commonjsGlobal.KeyboardEvent = function (_eventType: any, _init: any) {};
}
})();
Expand Down
Loading

0 comments on commit 25b6ab4

Please sign in to comment.