Skip to content

Commit 1d9ca84

Browse files
authored
chore(*): Enable comma-dangle (typescript-eslint#271)
As per the discussion on slack. Enable `comma-dangle` eslint rule + prettier config. Good for two reasons: 1) (the main reason) It will create less noise in PRs: ```diff { - "foo": true + "foo": true, + "bar": false } ``` 2) It makes reordering members easier because there is always a comma at the end. ---- Steps to create this PR: 1) add line in eslint config 2) add prettier config 3) run `yarn format` 4) ??? 5) profit. No other code was manually touched in the making of this PR.
1 parent 7bf4342 commit 1d9ca84

File tree

167 files changed

+6557
-6538
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

167 files changed

+6557
-6538
lines changed

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ node_modules
22
dist
33
jest.config.js
44
fixtures
5+
shared-fixtures
56
coverage
67

78
packages/typescript-estree/src/estree

.eslintrc.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
},
88
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
99
"rules": {
10+
"comma-dangle": ["error", "always-multiline"],
1011
"no-mixed-operators": "error",
1112
"no-console": "off",
1213
"no-undef": "off",

.prettierignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@
55
**/tests/integration/fixtures/**/*
66
**/lib/configs/recommended.json
77
**/.vscode
8-
**/.nyc_output
8+
**/.nyc_output
9+
packages/eslint-plugin-tslint/tests/test-tslint-rules-directory/alwaysFailRule.js

.prettierrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"trailingComma": "all"
3+
}

packages/eslint-plugin-tslint/jest.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
module.exports = {
44
testEnvironment: 'node',
55
transform: {
6-
'^.+\\.tsx?$': 'ts-jest'
6+
'^.+\\.tsx?$': 'ts-jest',
77
},
88
testRegex: './tests/.+\\.spec\\.ts$',
99
collectCoverage: false,
1010
collectCoverageFrom: ['src/**/*.{js,jsx,ts,tsx}'],
1111
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
12-
coverageReporters: ['text-summary', 'lcov']
12+
coverageReporters: ['text-summary', 'lcov'],
1313
};

packages/eslint-plugin-tslint/src/index.ts

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,20 @@ const tslintConfig = memoize(
3030
(
3131
lintFile: string,
3232
tslintRules: RawRulesConfig,
33-
tslintRulesDirectory: string[]
33+
tslintRulesDirectory: string[],
3434
) => {
3535
if (lintFile != null) {
3636
return Configuration.loadConfigurationFromPath(lintFile);
3737
}
3838
return Configuration.parseConfigFile({
3939
rules: tslintRules || {},
40-
rulesDirectory: tslintRulesDirectory || []
40+
rulesDirectory: tslintRulesDirectory || [],
4141
});
4242
},
4343
(lintFile: string | undefined, tslintRules = {}, tslintRulesDirectory = []) =>
4444
`${lintFile}_${Object.keys(tslintRules).join(',')}_${
4545
tslintRulesDirectory.length
46-
}`
46+
}`,
4747
);
4848

4949
export const rules = {
@@ -56,7 +56,7 @@ export const rules = {
5656
docs: {
5757
description:
5858
'Wraps a TSLint configuration and lints the whole source using TSLint',
59-
category: 'TSLint'
59+
category: 'TSLint',
6060
},
6161
schema: [
6262
{
@@ -67,21 +67,21 @@ export const rules = {
6767
/**
6868
* No fixed schema properties for rules, as this would be a permanently moving target
6969
*/
70-
additionalProperties: true
70+
additionalProperties: true,
7171
},
7272
rulesDirectory: {
7373
type: 'array',
7474
items: {
75-
type: 'string'
76-
}
75+
type: 'string',
76+
},
7777
},
7878
lintFile: {
79-
type: 'string'
80-
}
79+
type: 'string',
80+
},
8181
},
82-
additionalProperties: false
83-
}
84-
]
82+
additionalProperties: false,
83+
},
84+
],
8585
},
8686
create: function(context: Rule.RuleContext) {
8787
const fileName = context.getFilename();
@@ -94,7 +94,7 @@ export const rules = {
9494
*/
9595
if (!parserServices || !parserServices.program) {
9696
throw new Error(
97-
`You must provide a value for the "parserOptions.project" property for @typescript-eslint/parser`
97+
`You must provide a value for the "parserOptions.project" property for @typescript-eslint/parser`,
9898
);
9999
}
100100

@@ -104,7 +104,7 @@ export const rules = {
104104
const {
105105
rules: tslintRules,
106106
rulesDirectory: tslintRulesDirectory,
107-
lintFile
107+
lintFile,
108108
} = context.options[0];
109109

110110
const program: Program = parserServices.program;
@@ -116,13 +116,13 @@ export const rules = {
116116
*/
117117
const tslintOptions = {
118118
formatter: 'json',
119-
fix: false
119+
fix: false,
120120
};
121121
const tslint = new CustomLinter(tslintOptions, program);
122122
const configuration = tslintConfig(
123123
lintFile,
124124
tslintRules,
125-
tslintRulesDirectory
125+
tslintRulesDirectory,
126126
);
127127
tslint.lint(fileName, sourceCode, configuration);
128128

@@ -140,13 +140,13 @@ export const rules = {
140140
loc: {
141141
start: {
142142
line: start.line + 1,
143-
column: start.character
143+
column: start.character,
144144
},
145145
end: {
146146
line: end.line + 1,
147-
column: end.character
148-
}
149-
}
147+
column: end.character,
148+
},
149+
},
150150
});
151151
});
152152
}
@@ -155,6 +155,6 @@ export const rules = {
155155
* Return an empty object for the ESLint rule
156156
*/
157157
return {};
158-
}
159-
}
158+
},
159+
},
160160
};

packages/eslint-plugin-tslint/tests/index.spec.ts

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,18 @@ const ruleTester = new RuleTester({
1111
* Project is needed to generate the parserServices
1212
* within @typescript-eslint/parser
1313
*/
14-
project: './tests/tsconfig.json'
14+
project: './tests/tsconfig.json',
1515
},
16-
parser: '@typescript-eslint/parser'
16+
parser: '@typescript-eslint/parser',
1717
});
1818

1919
/**
2020
* Inline rules should be supported
2121
*/
2222
const tslintRulesConfig = {
2323
rules: {
24-
semicolon: [true, 'always']
25-
}
24+
semicolon: [true, 'always'],
25+
},
2626
};
2727

2828
/**
@@ -32,36 +32,36 @@ const tslintRulesDirectoryConfig = {
3232
rulesDirectory: ['./tests/test-tslint-rules-directory'],
3333
rules: {
3434
'always-fail': {
35-
severity: 'error'
36-
}
37-
}
35+
severity: 'error',
36+
},
37+
},
3838
};
3939

4040
ruleTester.run('tslint/config', rules.config, {
4141
valid: [
4242
{
4343
code: 'var foo = true;',
44-
options: [tslintRulesConfig]
44+
options: [tslintRulesConfig],
4545
},
4646
{
4747
filename: './tests/test-project/file-spec.ts',
4848
code: readFileSync('./tests/test-project/file-spec.ts', 'utf8').replace(
4949
/\n/g,
50-
' '
50+
' ',
5151
),
5252
parserOptions: {
53-
project: `${__dirname}/test-project/tsconfig.json`
53+
project: `${__dirname}/test-project/tsconfig.json`,
5454
},
5555
options: [
5656
{
57-
...tslintRulesConfig
58-
}
59-
]
57+
...tslintRulesConfig,
58+
},
59+
],
6060
},
6161
{
6262
code: 'throw "should be ok because rule is not loaded";',
63-
options: [tslintRulesConfig]
64-
}
63+
options: [tslintRulesConfig],
64+
},
6565
],
6666

6767
invalid: [
@@ -71,9 +71,9 @@ ruleTester.run('tslint/config', rules.config, {
7171
errors: [
7272
{
7373
message:
74-
'Throwing plain strings (not instances of Error) gives no stack traces (tslint:no-string-throw)'
75-
}
76-
]
74+
'Throwing plain strings (not instances of Error) gives no stack traces (tslint:no-string-throw)',
75+
},
76+
],
7777
},
7878
{
7979
code: 'var foo = true // semicolon',
@@ -83,9 +83,9 @@ ruleTester.run('tslint/config', rules.config, {
8383
{
8484
message: 'Missing semicolon (tslint:semicolon)',
8585
line: 1,
86-
column: 15
87-
}
88-
]
86+
column: 15,
87+
},
88+
],
8989
},
9090
{
9191
code: 'var foo = true // fail',
@@ -95,33 +95,33 @@ ruleTester.run('tslint/config', rules.config, {
9595
{
9696
message: 'failure (tslint:always-fail)',
9797
line: 1,
98-
column: 1
99-
}
100-
]
98+
column: 1,
99+
},
100+
],
101101
},
102102
{
103103
filename: './tests/test-project/source.ts',
104104
code: readFileSync('./tests/test-project/source.ts', 'utf8').replace(
105105
/\n/g,
106-
' '
106+
' ',
107107
),
108108
parserOptions: {
109-
project: `${__dirname}/test-project/tsconfig.json`
109+
project: `${__dirname}/test-project/tsconfig.json`,
110110
},
111111
options: [
112112
{
113113
rulesDirectory: [
114-
`${__dirname}/../../../node_modules/tslint/lib/rules`
114+
`${__dirname}/../../../node_modules/tslint/lib/rules`,
115115
],
116-
rules: { 'restrict-plus-operands': true }
117-
}
116+
rules: { 'restrict-plus-operands': true },
117+
},
118118
],
119119
errors: [
120120
{
121121
message:
122-
"Operands of '+' operation must either be both strings or both numbers, consider using template literals (tslint:restrict-plus-operands)"
123-
}
124-
]
125-
}
126-
]
122+
"Operands of '+' operation must either be both strings or both numbers, consider using template literals (tslint:restrict-plus-operands)",
123+
},
124+
],
125+
},
126+
],
127127
});

packages/eslint-plugin-tslint/tests/test-tslint-rules-directory/alwaysFailRule.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
const Lint = require('tslint');
23

34
class Rule extends Lint.Rules.AbstractRule {

packages/eslint-plugin/docs/rules/camelcase.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ function foo({ no_camelcased = 'default value' }) {
6868
}
6969

7070
var obj = {
71-
my_pref: 1
71+
my_pref: 1,
7272
};
7373

7474
var { category_id = 1 } = query;
@@ -125,7 +125,7 @@ Examples of **correct** code for this rule with the `{ "properties": "never" }`
125125
/*eslint @typescript-eslint/camelcase: ["error", {properties: "never"}]*/
126126

127127
var obj = {
128-
my_pref: 1
128+
my_pref: 1,
129129
};
130130
```
131131

packages/eslint-plugin/docs/rules/no-extraneous-class.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const StaticOnly = {
4242
version: 42,
4343
hello() {
4444
console.log('Hello, world!');
45-
}
45+
},
4646
};
4747
```
4848

packages/eslint-plugin/docs/rules/no-this-alias.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ You can pass an object option:
4545
'error',
4646
{
4747
allowDestructuring: true, // Allow `const { props, state } = this`; false by default
48-
allowedNames: ['self'] // Allow `const self = this`; `[]` by default
49-
}
50-
]
48+
allowedNames: ['self'], // Allow `const self = this`; `[]` by default
49+
},
50+
],
5151
}
5252
```
5353

packages/eslint-plugin/docs/rules/no-unnecessary-qualifier.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ namespace A {
2424
```ts
2525
enum A {
2626
B,
27-
C = A.B
27+
C = A.B,
2828
}
2929
```
3030

@@ -52,11 +52,11 @@ namespace Y {
5252
```ts
5353
enum A {
5454
X,
55-
Y
55+
Y,
5656
}
5757

5858
enum B {
59-
Z = A.X
59+
Z = A.X,
6060
}
6161
```
6262

packages/eslint-plugin/docs/rules/no-unused-vars.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ alert(x);
6363
myFunc(
6464
function foo() {
6565
// ...
66-
}.bind(this)
66+
}.bind(this),
6767
);
6868

6969
(function(foo) {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy