Skip to content

Commit 884f9e6

Browse files
committed
trigger publish
1 parent 0125516 commit 884f9e6

File tree

7 files changed

+60
-17
lines changed

7 files changed

+60
-17
lines changed

Diff for: .editorconfig

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Editor configuration, see http://editorconfig.org
2+
root = true
3+
4+
[*]
5+
charset = utf-8
6+
indent_size = 4
7+
end_of_line = lf
8+
indent_style = space
9+
max_line_length = 120
10+
insert_final_newline = true
11+
trim_trailing_whitespace = true

Diff for: .npmignore

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
/node_modules
22
/dist
33
/test
4+
/tools
45
.idea
56
*.iml
67
*.report.txt
78
.prettierrc.json
89
.travis.yml
9-
jest.config.json
10+
*.sh
11+
typings.ts
12+
renovate.json
13+
jest.config.js
1014
test.sh
1115
yarn.lock
1216
tsconfig*

Diff for: index.js renamed to eslintrc.js

+29-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
/* eslint-disable no-magic-numbers */
1+
/**
2+
* @type {import('eslint').Linter.Config}
3+
*/
24
module.exports = {
35
env: {
46
browser: true,
@@ -7,9 +9,27 @@ module.exports = {
79
},
810
parser: '@typescript-eslint/parser',
911
parserOptions: {
12+
createDefaultProgram: true,
1013
project: './tsconfig.json',
11-
sourceType: 'module'
14+
sourceType: 'module',
15+
errorOnUnknownASTType: true,
16+
errorOnTypeScriptSyntacticAndSemanticIssues: true
1217
},
18+
ignorePatterns: [
19+
'**/node_modules/**',
20+
'**/schematics/*',
21+
'**/coverage/**',
22+
'eslintrc.js',
23+
'.eslintrc.js',
24+
'**/*.spec.ts',
25+
'**/*-spec.ts',
26+
'**/*.lint.ts',
27+
'**/dist/**',
28+
'**/docs/**',
29+
'.cache/**',
30+
'.git/**',
31+
'.idea/**'
32+
],
1333
extends: [
1434
'eslint:recommended',
1535
'plugin:@typescript-eslint/eslint-recommended',
@@ -44,14 +64,15 @@ module.exports = {
4464
'no-return-assign': ['error', 'always'],
4565
'max-params': ['error', 3],
4666
'no-nested-ternary': 'error',
47-
"no-magic-numbers": "off",
48-
"@typescript-eslint/no-magic-numbers": [
49-
"error",
67+
'no-magic-numbers': 'off',
68+
'@typescript-eslint/no-magic-numbers': [
69+
'error',
5070
{
5171
ignoreEnums: true,
5272
ignoreNumericLiteralTypes: true,
5373
ignoreReadonlyClassProperties: true
54-
}],
74+
}
75+
],
5576
'sort-imports': 'off',
5677
'prettier/prettier': 'error',
5778
'import/first': 'error',
@@ -137,7 +158,8 @@ module.exports = {
137158
'@typescript-eslint/no-use-before-define': ['error', { functions: false, classes: false, variables: true }],
138159
'no-prototype-builtins': 'off',
139160
'no-useless-escape': 'off',
140-
quotes: ['error', 'single', { allowTemplateLiterals: true }],
161+
quotes: 'off',
162+
'@typescript-eslint/quotes': ['error', 'single', { allowTemplateLiterals: true }],
141163
'arrow-body-style': 'error',
142164
'arrow-parens': ['error', 'always'],
143165
'constructor-super': 'error',

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
},
1818
"license": "MIT",
1919
"author": "splincode",
20-
"main": "index.js",
20+
"main": "eslintrc.js",
2121
"scripts": {
2222
"format": "npx sort-package-json && prettier --write \"**/*.{js,ts,html,css,scss,md,json,yml}\"",
2323
"test": "sh test.sh"

Diff for: test.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
mkdir -p ./dist
44

55
{ # try
6-
npx eslint -c index.js "**/*.bad.ts" > ./dist/eslint.bad.report.txt
6+
npx eslint -c eslintrc.js "**/*.bad.ts" > ./dist/eslint.bad.report.txt
77
} || { # catch
8-
npx eslint -c index.js "**/*.good.ts" > ./dist/eslint.good.report.txt
8+
npx eslint -c eslintrc.js "**/*.good.ts" > ./dist/eslint.good.report.txt
99
jest --config ./jest.config.js test/test.spec.ts
1010
}

Diff for: test/test.spec.ts

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
1-
/* eslint-disable */
2-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
3-
type AnyType = any;
1+
const fs = require('fs');
42

5-
const fs: AnyType = require('fs');
63
describe('[TEST]: Eslint', (): void => {
74
function ensureDistFile(type: string): string {
85
return fs.readFileSync(`./dist/eslint.${type}.report.txt`).toString();
96
}
107

118
it('check failed files', (): void => {
129
const bad: string = ensureDistFile('bad');
13-
expect(bad.includes("expected member-variable-declaration: 'hello' to have a typedef")).toEqual(true);
10+
expect(bad.includes(`expected member-variable-declaration: 'hello' to have a typedef`)).toEqual(true);
1411
expect(bad.includes('Missing accessibility modifier on class property hello')).toEqual(true);
1512
expect(bad.includes('Unexpected console statement')).toEqual(true);
1613
expect(bad.includes('No magic number: 2')).toEqual(true);

Diff for: test/typescript.good.ts

+10-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export class A {
88
console.error(new A().hi);
99
console.error(new A().hello);
1010

11-
enum foo {
11+
export enum foo {
1212
SECOND = 1000,
1313
VALUE_1 = 3,
1414
VALUE_2 = 4
@@ -17,3 +17,12 @@ enum foo {
1717
console.error(foo.SECOND);
1818
console.error(foo.VALUE_1);
1919
console.error(foo.VALUE_2);
20+
21+
export const enum HelloWorld {
22+
World
23+
}
24+
25+
console.error({
26+
a: `Hello 'world'`,
27+
b: HelloWorld.World
28+
});

0 commit comments

Comments
 (0)