Skip to content

Commit

Permalink
chore: eslint (#287)
Browse files Browse the repository at this point in the history
  • Loading branch information
maxisam authored Nov 18, 2021
1 parent f3585f5 commit 8d620cc
Show file tree
Hide file tree
Showing 15 changed files with 2,788 additions and 1,527 deletions.
42 changes: 42 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"root": true,
"ignorePatterns": ["projects/**/*"],
"overrides": [
{
"files": ["*.ts"],
"parserOptions": {
"project": ["tsconfig.json", "e2e/tsconfig.json"],
"createDefaultProgram": true
},
"extends": [
"plugin:@angular-eslint/recommended",
"plugin:@angular-eslint/template/process-inline-templates",
"plugin:prettier/recommended",
"prettier"
],
"rules": {
"@angular-eslint/component-selector": [
"error",
{
"prefix": "ngx",
"style": "kebab-case",
"type": "element"
}
],
"@angular-eslint/directive-selector": [
"error",
{
"prefix": "ngx",
"style": "camelCase",
"type": "attribute"
}
]
}
},
{
"files": ["*.html"],
"extends": ["plugin:@angular-eslint/template/recommended"],
"rules": {}
}
]
}
68 changes: 34 additions & 34 deletions .github/workflows/ngx-clipboard.yml
Original file line number Diff line number Diff line change
@@ -1,48 +1,48 @@
name: ngx-clipboard

on:
push:
branches:
- master
pull_request:
workflow_dispatch:
push:
branches:
- master
pull_request:
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
steps:
- uses: actions/checkout@v2

- uses: actions/setup-node@v2
with:
node-version: 14.15.0
cache: 'yarn'
- uses: actions/setup-node@v2
with:
node-version: 14.17.0
cache: 'yarn'

- uses: actions/cache@v2
id: angular-cache
with:
path: |
.angular/cache
key: ${{ runner.os }}-ng-${{ hashFiles('**/yarn.lock') }}
restore-keys: ${{ runner.os }}-ng
- uses: actions/cache@v2
id: angular-cache
with:
path: |
.angular/cache
key: ${{ runner.os }}-ng-${{ hashFiles('**/yarn.lock') }}
restore-keys: ${{ runner.os }}-ng

- name: Install dependencies
run: yarn --pure-lockfile --non-interactive --no-progress
- name: Install dependencies
run: yarn --pure-lockfile --non-interactive --no-progress

# Fix linting errors first
# - name: Run TSLint
# run: yarn lint
# Fix linting errors first
# - name: Run TSLint
# run: yarn lint

- name: Run tests
run: yarn test --configuration=ci
- name: Run tests
run: yarn test --configuration=ci

- name: Build host app
run: yarn ng build library-host --prod
- name: Build host app
run: yarn ng build library-host --prod

- name: Build library
run: yarn build
- name: Build library
run: yarn build

- name: Publish library
if: github.event_name == 'workflow_dispatch'
run: yarn publish:lib
- name: Publish library
if: github.event_name == 'workflow_dispatch'
run: yarn publish:lib
15 changes: 14 additions & 1 deletion angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@
"scripts": [],
"assets": ["src/favicon.ico", "src/assets"]
}
},
"lint": {
"builder": "@angular-eslint/builder:lint",
"options": {
"lintFilePatterns": ["src/**/*.ts", "src/**/*.html"]
}
}
}
},
Expand Down Expand Up @@ -130,13 +136,20 @@
"browsers": "ChromeHeadlessCI"
}
}
},
"lint": {
"builder": "@angular-eslint/builder:lint",
"options": {
"lintFilePatterns": ["projects/ngx-clipboard/**/*.ts", "projects/ngx-clipboard/**/*.html"]
}
}
}
}
},
"defaultProject": "library-host",
"cli": {
"packageManager": "yarn",
"analytics": "26cce57c-232f-4bfb-ac75-bfc72a238bd7"
"analytics": "26cce57c-232f-4bfb-ac75-bfc72a238bd7",
"defaultCollection": "@angular-eslint/schematics"
}
}
42 changes: 20 additions & 22 deletions e2e/protractor.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,23 @@
const { SpecReporter } = require('jasmine-spec-reporter');

exports.config = {
allScriptsTimeout: 11000,
specs: [
'./src/**/*.e2e-spec.ts'
],
capabilities: {
'browserName': 'chrome'
},
directConnect: true,
baseUrl: 'http://localhost:4200/',
framework: 'jasmine',
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000,
print: function() {}
},
onPrepare() {
require('ts-node').register({
project: require('path').join(__dirname, './tsconfig.e2e.json')
});
jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
}
};
allScriptsTimeout: 11000,
specs: ['./src/**/*.e2e-spec.ts'],
capabilities: {
browserName: 'chrome'
},
directConnect: true,
baseUrl: 'http://localhost:4200/',
framework: 'jasmine',
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000,
print: function () {}
},
onPrepare() {
require('ts-node').register({
project: require('path').join(__dirname, './tsconfig.e2e.json')
});
jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
}
};
17 changes: 12 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,31 @@
"@angular/platform-browser": "~13.0.1",
"@angular/platform-browser-dynamic": "~13.0.1",
"@angular/router": "~13.0.1",
"ngx-window-token": "6.0.0",
"ngx-clipboard": "15.0.0",
"ngx-window-token": "6.0.0",
"rxjs": "~7.4.0",
"tslib": "^2.3.1",
"zone.js": "~0.11.4"
},
"devDependencies": {
"@angular-devkit/build-angular": "~13.0.2",
"@angular-eslint/builder": "13.0.0-alpha.0",
"@angular-eslint/eslint-plugin": "13.0.0-alpha.0",
"@angular-eslint/eslint-plugin-template": "13.0.0-alpha.0",
"@angular-eslint/schematics": "13.0.0-alpha.0",
"@angular-eslint/template-parser": "13.0.0-alpha.0",
"@angular/cli": "~13.0.2",
"@angular/compiler-cli": "~13.0.1",
"@angular/language-service": "~13.0.1",
"@types/jasmine": "~3.10.2",
"@types/jasminewd2": "~2.0.10",
"@types/node": "^16.11.7",
"codelyzer": "^6.0.0",
"@typescript-eslint/eslint-plugin": "5.4.0",
"@typescript-eslint/parser": "5.4.0",
"cpx": "^1.5.0",
"eslint": "^8.2.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^4.0.0",
"husky": "7.0.4",
"jasmine-core": "~3.10.1",
"jasmine-spec-reporter": "~7.0.0",
Expand All @@ -53,9 +62,7 @@
"ng-packagr": "^13.0.3",
"prettier": "2.4.1",
"protractor": "~7.0.0",
"ts-node": "~7.0.0",
"tslint": "~6.1.0",
"tslint-config-prettier": "^1.18.0",
"ts-node": "~10.4.0",
"typescript": "~4.4.3"
},
"husky": {
Expand Down
35 changes: 35 additions & 0 deletions projects/ngx-clipboard/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"extends": "../../.eslintrc.json",
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts"],
"parserOptions": {
"project": ["projects/ngx-clipboard/tsconfig.lib.json", "projects/ngx-clipboard/tsconfig.spec.json"],
"createDefaultProgram": true
},
"rules": {
"@angular-eslint/directive-selector": [
"error",
{
"type": "attribute",
"prefix": "ngx",
"style": "camelCase"
}
],
"@angular-eslint/component-selector": [
"error",
{
"type": "element",
"prefix": "ngx",
"style": "kebab-case"
}
]
}
},
{
"files": ["*.html"],
"rules": {}
}
]
}
66 changes: 33 additions & 33 deletions projects/ngx-clipboard/karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
// Karma configuration file, see link for more information
// https://karma-runner.github.io/1.0/config/configuration-file.html

module.exports = function(config) {
config.set({
basePath: '',
frameworks: ['jasmine', '@angular-devkit/build-angular'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter'),
require('@angular-devkit/build-angular/plugins/karma')
],
client: {
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
coverageIstanbulReporter: {
dir: require('path').join(__dirname, '../../coverage'),
reports: ['html', 'lcovonly'],
fixWebpackSourcePaths: true
},
reporters: ['progress', 'kjhtml'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
customLaunchers: {
ChromeHeadlessCI: {
base: 'ChromeHeadless',
flags: ['--no-sandbox', '--disable-gpu']
},
},
singleRun: true
});
module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine', '@angular-devkit/build-angular'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter'),
require('@angular-devkit/build-angular/plugins/karma')
],
client: {
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
coverageIstanbulReporter: {
dir: require('path').join(__dirname, '../../coverage'),
reports: ['html', 'lcovonly'],
fixWebpackSourcePaths: true
},
reporters: ['progress', 'kjhtml'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
customLaunchers: {
ChromeHeadlessCI: {
base: 'ChromeHeadless',
flags: ['--no-sandbox', '--disable-gpu']
}
},
singleRun: true
});
};
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
import { Component } from '@angular/core';
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { By } from '@angular/platform-browser';

import { ClipboardModule } from './ngx-clipboard.module';
import { ClipboardService } from './ngx-clipboard.service';

@Component({
// tslint:disable-next-line:component-selector
// eslint-disable-next-line @angular-eslint/component-selector
selector: 'test-cmp',
template: `
<span *ngxClipboardIfSupported ngxClipboard cbContent="Foo Bar">
Copy Foo Bar
</span>
`
template: `<span *ngxClipboardIfSupported ngxClipboard cbContent="Foo Bar"> Copy Foo Bar </span>`
})
class TestComponent {}

Expand Down
Loading

0 comments on commit 8d620cc

Please sign in to comment.