Skip to content

Commit 8d620cc

Browse files
authored
chore: eslint (#287)
1 parent f3585f5 commit 8d620cc

15 files changed

+2788
-1527
lines changed

.eslintrc.json

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"root": true,
3+
"ignorePatterns": ["projects/**/*"],
4+
"overrides": [
5+
{
6+
"files": ["*.ts"],
7+
"parserOptions": {
8+
"project": ["tsconfig.json", "e2e/tsconfig.json"],
9+
"createDefaultProgram": true
10+
},
11+
"extends": [
12+
"plugin:@angular-eslint/recommended",
13+
"plugin:@angular-eslint/template/process-inline-templates",
14+
"plugin:prettier/recommended",
15+
"prettier"
16+
],
17+
"rules": {
18+
"@angular-eslint/component-selector": [
19+
"error",
20+
{
21+
"prefix": "ngx",
22+
"style": "kebab-case",
23+
"type": "element"
24+
}
25+
],
26+
"@angular-eslint/directive-selector": [
27+
"error",
28+
{
29+
"prefix": "ngx",
30+
"style": "camelCase",
31+
"type": "attribute"
32+
}
33+
]
34+
}
35+
},
36+
{
37+
"files": ["*.html"],
38+
"extends": ["plugin:@angular-eslint/template/recommended"],
39+
"rules": {}
40+
}
41+
]
42+
}
Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,48 @@
11
name: ngx-clipboard
22

33
on:
4-
push:
5-
branches:
6-
- master
7-
pull_request:
8-
workflow_dispatch:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
workflow_dispatch:
99

1010
jobs:
11-
build:
12-
runs-on: ubuntu-latest
11+
build:
12+
runs-on: ubuntu-latest
1313

14-
steps:
15-
- uses: actions/checkout@v2
14+
steps:
15+
- uses: actions/checkout@v2
1616

17-
- uses: actions/setup-node@v2
18-
with:
19-
node-version: 14.15.0
20-
cache: 'yarn'
17+
- uses: actions/setup-node@v2
18+
with:
19+
node-version: 14.17.0
20+
cache: 'yarn'
2121

22-
- uses: actions/cache@v2
23-
id: angular-cache
24-
with:
25-
path: |
26-
.angular/cache
27-
key: ${{ runner.os }}-ng-${{ hashFiles('**/yarn.lock') }}
28-
restore-keys: ${{ runner.os }}-ng
22+
- uses: actions/cache@v2
23+
id: angular-cache
24+
with:
25+
path: |
26+
.angular/cache
27+
key: ${{ runner.os }}-ng-${{ hashFiles('**/yarn.lock') }}
28+
restore-keys: ${{ runner.os }}-ng
2929

30-
- name: Install dependencies
31-
run: yarn --pure-lockfile --non-interactive --no-progress
30+
- name: Install dependencies
31+
run: yarn --pure-lockfile --non-interactive --no-progress
3232

33-
# Fix linting errors first
34-
# - name: Run TSLint
35-
# run: yarn lint
33+
# Fix linting errors first
34+
# - name: Run TSLint
35+
# run: yarn lint
3636

37-
- name: Run tests
38-
run: yarn test --configuration=ci
37+
- name: Run tests
38+
run: yarn test --configuration=ci
3939

40-
- name: Build host app
41-
run: yarn ng build library-host --prod
40+
- name: Build host app
41+
run: yarn ng build library-host --prod
4242

43-
- name: Build library
44-
run: yarn build
43+
- name: Build library
44+
run: yarn build
4545

46-
- name: Publish library
47-
if: github.event_name == 'workflow_dispatch'
48-
run: yarn publish:lib
46+
- name: Publish library
47+
if: github.event_name == 'workflow_dispatch'
48+
run: yarn publish:lib

angular.json

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,12 @@
8181
"scripts": [],
8282
"assets": ["src/favicon.ico", "src/assets"]
8383
}
84+
},
85+
"lint": {
86+
"builder": "@angular-eslint/builder:lint",
87+
"options": {
88+
"lintFilePatterns": ["src/**/*.ts", "src/**/*.html"]
89+
}
8490
}
8591
}
8692
},
@@ -130,13 +136,20 @@
130136
"browsers": "ChromeHeadlessCI"
131137
}
132138
}
139+
},
140+
"lint": {
141+
"builder": "@angular-eslint/builder:lint",
142+
"options": {
143+
"lintFilePatterns": ["projects/ngx-clipboard/**/*.ts", "projects/ngx-clipboard/**/*.html"]
144+
}
133145
}
134146
}
135147
}
136148
},
137149
"defaultProject": "library-host",
138150
"cli": {
139151
"packageManager": "yarn",
140-
"analytics": "26cce57c-232f-4bfb-ac75-bfc72a238bd7"
152+
"analytics": "26cce57c-232f-4bfb-ac75-bfc72a238bd7",
153+
"defaultCollection": "@angular-eslint/schematics"
141154
}
142155
}

e2e/protractor.conf.js

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,23 @@
44
const { SpecReporter } = require('jasmine-spec-reporter');
55

66
exports.config = {
7-
allScriptsTimeout: 11000,
8-
specs: [
9-
'./src/**/*.e2e-spec.ts'
10-
],
11-
capabilities: {
12-
'browserName': 'chrome'
13-
},
14-
directConnect: true,
15-
baseUrl: 'http://localhost:4200/',
16-
framework: 'jasmine',
17-
jasmineNodeOpts: {
18-
showColors: true,
19-
defaultTimeoutInterval: 30000,
20-
print: function() {}
21-
},
22-
onPrepare() {
23-
require('ts-node').register({
24-
project: require('path').join(__dirname, './tsconfig.e2e.json')
25-
});
26-
jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
27-
}
28-
};
7+
allScriptsTimeout: 11000,
8+
specs: ['./src/**/*.e2e-spec.ts'],
9+
capabilities: {
10+
browserName: 'chrome'
11+
},
12+
directConnect: true,
13+
baseUrl: 'http://localhost:4200/',
14+
framework: 'jasmine',
15+
jasmineNodeOpts: {
16+
showColors: true,
17+
defaultTimeoutInterval: 30000,
18+
print: function () {}
19+
},
20+
onPrepare() {
21+
require('ts-node').register({
22+
project: require('path').join(__dirname, './tsconfig.e2e.json')
23+
});
24+
jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
25+
}
26+
};

package.json

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,31 @@
2525
"@angular/platform-browser": "~13.0.1",
2626
"@angular/platform-browser-dynamic": "~13.0.1",
2727
"@angular/router": "~13.0.1",
28-
"ngx-window-token": "6.0.0",
2928
"ngx-clipboard": "15.0.0",
29+
"ngx-window-token": "6.0.0",
3030
"rxjs": "~7.4.0",
3131
"tslib": "^2.3.1",
3232
"zone.js": "~0.11.4"
3333
},
3434
"devDependencies": {
3535
"@angular-devkit/build-angular": "~13.0.2",
36+
"@angular-eslint/builder": "13.0.0-alpha.0",
37+
"@angular-eslint/eslint-plugin": "13.0.0-alpha.0",
38+
"@angular-eslint/eslint-plugin-template": "13.0.0-alpha.0",
39+
"@angular-eslint/schematics": "13.0.0-alpha.0",
40+
"@angular-eslint/template-parser": "13.0.0-alpha.0",
3641
"@angular/cli": "~13.0.2",
3742
"@angular/compiler-cli": "~13.0.1",
3843
"@angular/language-service": "~13.0.1",
3944
"@types/jasmine": "~3.10.2",
4045
"@types/jasminewd2": "~2.0.10",
4146
"@types/node": "^16.11.7",
42-
"codelyzer": "^6.0.0",
47+
"@typescript-eslint/eslint-plugin": "5.4.0",
48+
"@typescript-eslint/parser": "5.4.0",
4349
"cpx": "^1.5.0",
50+
"eslint": "^8.2.0",
51+
"eslint-config-prettier": "^8.3.0",
52+
"eslint-plugin-prettier": "^4.0.0",
4453
"husky": "7.0.4",
4554
"jasmine-core": "~3.10.1",
4655
"jasmine-spec-reporter": "~7.0.0",
@@ -53,9 +62,7 @@
5362
"ng-packagr": "^13.0.3",
5463
"prettier": "2.4.1",
5564
"protractor": "~7.0.0",
56-
"ts-node": "~7.0.0",
57-
"tslint": "~6.1.0",
58-
"tslint-config-prettier": "^1.18.0",
65+
"ts-node": "~10.4.0",
5966
"typescript": "~4.4.3"
6067
},
6168
"husky": {
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"extends": "../../.eslintrc.json",
3+
"ignorePatterns": ["!**/*"],
4+
"overrides": [
5+
{
6+
"files": ["*.ts"],
7+
"parserOptions": {
8+
"project": ["projects/ngx-clipboard/tsconfig.lib.json", "projects/ngx-clipboard/tsconfig.spec.json"],
9+
"createDefaultProgram": true
10+
},
11+
"rules": {
12+
"@angular-eslint/directive-selector": [
13+
"error",
14+
{
15+
"type": "attribute",
16+
"prefix": "ngx",
17+
"style": "camelCase"
18+
}
19+
],
20+
"@angular-eslint/component-selector": [
21+
"error",
22+
{
23+
"type": "element",
24+
"prefix": "ngx",
25+
"style": "kebab-case"
26+
}
27+
]
28+
}
29+
},
30+
{
31+
"files": ["*.html"],
32+
"rules": {}
33+
}
34+
]
35+
}
Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,37 @@
11
// Karma configuration file, see link for more information
22
// https://karma-runner.github.io/1.0/config/configuration-file.html
33

4-
module.exports = function(config) {
5-
config.set({
6-
basePath: '',
7-
frameworks: ['jasmine', '@angular-devkit/build-angular'],
8-
plugins: [
9-
require('karma-jasmine'),
10-
require('karma-chrome-launcher'),
11-
require('karma-jasmine-html-reporter'),
12-
require('karma-coverage-istanbul-reporter'),
13-
require('@angular-devkit/build-angular/plugins/karma')
14-
],
15-
client: {
16-
clearContext: false // leave Jasmine Spec Runner output visible in browser
17-
},
18-
coverageIstanbulReporter: {
19-
dir: require('path').join(__dirname, '../../coverage'),
20-
reports: ['html', 'lcovonly'],
21-
fixWebpackSourcePaths: true
22-
},
23-
reporters: ['progress', 'kjhtml'],
24-
port: 9876,
25-
colors: true,
26-
logLevel: config.LOG_INFO,
27-
autoWatch: true,
28-
browsers: ['Chrome'],
29-
customLaunchers: {
30-
ChromeHeadlessCI: {
31-
base: 'ChromeHeadless',
32-
flags: ['--no-sandbox', '--disable-gpu']
33-
},
34-
},
35-
singleRun: true
36-
});
4+
module.exports = function (config) {
5+
config.set({
6+
basePath: '',
7+
frameworks: ['jasmine', '@angular-devkit/build-angular'],
8+
plugins: [
9+
require('karma-jasmine'),
10+
require('karma-chrome-launcher'),
11+
require('karma-jasmine-html-reporter'),
12+
require('karma-coverage-istanbul-reporter'),
13+
require('@angular-devkit/build-angular/plugins/karma')
14+
],
15+
client: {
16+
clearContext: false // leave Jasmine Spec Runner output visible in browser
17+
},
18+
coverageIstanbulReporter: {
19+
dir: require('path').join(__dirname, '../../coverage'),
20+
reports: ['html', 'lcovonly'],
21+
fixWebpackSourcePaths: true
22+
},
23+
reporters: ['progress', 'kjhtml'],
24+
port: 9876,
25+
colors: true,
26+
logLevel: config.LOG_INFO,
27+
autoWatch: true,
28+
browsers: ['Chrome'],
29+
customLaunchers: {
30+
ChromeHeadlessCI: {
31+
base: 'ChromeHeadless',
32+
flags: ['--no-sandbox', '--disable-gpu']
33+
}
34+
},
35+
singleRun: true
36+
});
3737
};

projects/ngx-clipboard/src/lib/ngx-clipboard-if-supported.directive.spec.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
11
import { Component } from '@angular/core';
22
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
33
import { By } from '@angular/platform-browser';
4-
54
import { ClipboardModule } from './ngx-clipboard.module';
65
import { ClipboardService } from './ngx-clipboard.service';
76

87
@Component({
9-
// tslint:disable-next-line:component-selector
8+
// eslint-disable-next-line @angular-eslint/component-selector
109
selector: 'test-cmp',
11-
template: `
12-
<span *ngxClipboardIfSupported ngxClipboard cbContent="Foo Bar">
13-
Copy Foo Bar
14-
</span>
15-
`
10+
template: `<span *ngxClipboardIfSupported ngxClipboard cbContent="Foo Bar"> Copy Foo Bar </span>`
1611
})
1712
class TestComponent {}
1813

0 commit comments

Comments
 (0)