Skip to content
Permalink
Browse files

chore(*): Enable comma-dangle (#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.
  • Loading branch information...
bradzacher committed Feb 19, 2019
1 parent 7bf4342 commit 1d9ca845d5af4bb4eeee8b41719a182ae131fc56
Showing with 6,557 additions and 6,538 deletions.
  1. +1 −0 .eslintignore
  2. +1 −0 .eslintrc.json
  3. +2 −1 .prettierignore
  4. +3 −0 .prettierrc
  5. +2 −2 packages/eslint-plugin-tslint/jest.config.js
  6. +22 −22 packages/eslint-plugin-tslint/src/index.ts
  7. +34 −34 packages/eslint-plugin-tslint/tests/index.spec.ts
  8. +1 −0 packages/eslint-plugin-tslint/tests/test-tslint-rules-directory/alwaysFailRule.js
  9. +2 −2 packages/eslint-plugin/docs/rules/camelcase.md
  10. +1 −1 packages/eslint-plugin/docs/rules/no-extraneous-class.md
  11. +3 −3 packages/eslint-plugin/docs/rules/no-this-alias.md
  12. +3 −3 packages/eslint-plugin/docs/rules/no-unnecessary-qualifier.md
  13. +1 −1 packages/eslint-plugin/docs/rules/no-unused-vars.md
  14. +2 −2 packages/eslint-plugin/jest.config.js
  15. +3 −3 packages/eslint-plugin/src/index.ts
  16. +9 −9 packages/eslint-plugin/src/rules/adjacent-overload-signatures.ts
  17. +18 −18 packages/eslint-plugin/src/rules/array-type.ts
  18. +6 −6 packages/eslint-plugin/src/rules/ban-ts-ignore.ts
  19. +23 −23 packages/eslint-plugin/src/rules/ban-types.ts
  20. +9 −9 packages/eslint-plugin/src/rules/camelcase.ts
  21. +9 −9 packages/eslint-plugin/src/rules/class-name-casing.ts
  22. +14 −14 packages/eslint-plugin/src/rules/explicit-function-return-type.ts
  23. +11 −11 packages/eslint-plugin/src/rules/explicit-member-accessibility.ts
  24. +11 −10 packages/eslint-plugin/src/rules/generic-type-naming.ts
  25. +46 −45 packages/eslint-plugin/src/rules/indent.ts
  26. +9 −9 packages/eslint-plugin/src/rules/interface-name-prefix.ts
  27. +29 −29 packages/eslint-plugin/src/rules/member-delimiter-style.ts
  28. +13 −13 packages/eslint-plugin/src/rules/member-naming.ts
  29. +49 −49 packages/eslint-plugin/src/rules/member-ordering.ts
  30. +7 −7 packages/eslint-plugin/src/rules/no-angle-bracket-type-assertion.ts
  31. +8 −8 packages/eslint-plugin/src/rules/no-array-constructor.ts
  32. +13 −13 packages/eslint-plugin/src/rules/no-empty-interface.ts
  33. +6 −6 packages/eslint-plugin/src/rules/no-explicit-any.ts
  34. +17 −17 packages/eslint-plugin/src/rules/no-extraneous-class.ts
  35. +6 −6 packages/eslint-plugin/src/rules/no-for-in-array.ts
  36. +19 −19 packages/eslint-plugin/src/rules/no-inferrable-types.ts
  37. +14 −14 packages/eslint-plugin/src/rules/no-misused-new.ts
  38. +14 −14 packages/eslint-plugin/src/rules/no-namespace.ts
  39. +6 −6 packages/eslint-plugin/src/rules/no-non-null-assertion.ts
  40. +13 −13 packages/eslint-plugin/src/rules/no-object-literal-type-assertion.ts
  41. +15 −15 packages/eslint-plugin/src/rules/no-parameter-properties.ts
  42. +7 −7 packages/eslint-plugin/src/rules/no-require-imports.ts
  43. +15 −15 packages/eslint-plugin/src/rules/no-this-alias.ts
  44. +6 −6 packages/eslint-plugin/src/rules/no-triple-slash-reference.ts
  45. +34 −34 packages/eslint-plugin/src/rules/no-type-alias.ts
  46. +15 −15 packages/eslint-plugin/src/rules/no-unnecessary-qualifier.ts
  47. +18 −18 packages/eslint-plugin/src/rules/no-unnecessary-type-assertion.ts
  48. +4 −4 packages/eslint-plugin/src/rules/no-unused-vars.ts
  49. +19 −19 packages/eslint-plugin/src/rules/no-use-before-define.ts
  50. +5 −5 packages/eslint-plugin/src/rules/no-useless-constructor.ts
  51. +6 −6 packages/eslint-plugin/src/rules/no-var-requires.ts
  52. +13 −13 packages/eslint-plugin/src/rules/prefer-function-type.ts
  53. +9 −9 packages/eslint-plugin/src/rules/prefer-interface.ts
  54. +7 −7 packages/eslint-plugin/src/rules/prefer-namespace-keyword.ts
  55. +22 −22 packages/eslint-plugin/src/rules/promise-function-async.ts
  56. +6 −6 packages/eslint-plugin/src/rules/require-array-sort-compare.ts
  57. +7 −7 packages/eslint-plugin/src/rules/restrict-plus-operands.ts
  58. +26 −26 packages/eslint-plugin/src/rules/type-annotation-spacing.ts
  59. +1 −1 packages/eslint-plugin/src/util/applyDefault.ts
  60. +6 −6 packages/eslint-plugin/src/util/createRule.ts
  61. +2 −2 packages/eslint-plugin/src/util/deepMerge.ts
  62. +1 −1 packages/eslint-plugin/src/util/getParserServices.ts
  63. +1 −1 packages/eslint-plugin/src/util/misc.ts
  64. +1 −1 packages/eslint-plugin/src/util/types.ts
  65. +2 −2 packages/eslint-plugin/tests/RuleTester.ts
  66. +8 −8 packages/eslint-plugin/tests/eslint-rules/arrow-parens.test.ts
  67. +4 −4 packages/eslint-plugin/tests/eslint-rules/no-dupe-args.test.ts
  68. +4 −4 packages/eslint-plugin/tests/eslint-rules/no-implicit-globals.test.ts
  69. +68 −68 packages/eslint-plugin/tests/eslint-rules/no-redeclare.test.ts
  70. +5 −5 packages/eslint-plugin/tests/eslint-rules/no-restricted-globals.test.ts
  71. +4 −4 packages/eslint-plugin/tests/eslint-rules/no-shadow.test.ts
  72. +4 −4 packages/eslint-plugin/tests/eslint-rules/no-undef.test.ts
  73. +9 −9 packages/eslint-plugin/tests/eslint-rules/strict.test.ts
  74. +100 −100 packages/eslint-plugin/tests/rules/adjacent-overload-signatures.test.ts
  75. +188 −188 packages/eslint-plugin/tests/rules/array-type.test.ts
  76. +16 −16 packages/eslint-plugin/tests/rules/ban-ts-ignore.test.ts
  77. +50 −50 packages/eslint-plugin/tests/rules/ban-types.test.ts
  78. +54 −54 packages/eslint-plugin/tests/rules/camelcase.test.ts
  79. +38 −38 packages/eslint-plugin/tests/rules/class-name-casing.test.ts
  80. +43 −43 packages/eslint-plugin/tests/rules/explicit-function-return-type.test.ts
  81. +21 −21 packages/eslint-plugin/tests/rules/explicit-member-accessibility.test.ts
  82. +37 −37 packages/eslint-plugin/tests/rules/generic-type-naming.test.ts
  83. +257 −255 packages/eslint-plugin/tests/rules/indent.test.ts
  84. +24 −24 packages/eslint-plugin/tests/rules/interface-name-prefix.test.ts
  85. +704 −704 packages/eslint-plugin/tests/rules/member-delimiter-style.test.ts
  86. +70 −70 packages/eslint-plugin/tests/rules/member-naming.test.ts
  87. +489 −486 packages/eslint-plugin/tests/rules/member-ordering.test.ts
  88. +30 −30 packages/eslint-plugin/tests/rules/no-angle-bracket-type-assertion.test.ts
  89. +28 −28 packages/eslint-plugin/tests/rules/no-array-constructor.test.ts
  90. +14 −14 packages/eslint-plugin/tests/rules/no-empty-interface.test.ts
  91. +133 −133 packages/eslint-plugin/tests/rules/no-explicit-any.test.ts
  92. +17 −17 packages/eslint-plugin/tests/rules/no-extraneous-class.test.ts
  93. +11 −11 packages/eslint-plugin/tests/rules/no-for-in-array.test.ts
  94. +44 −44 packages/eslint-plugin/tests/rules/no-inferrable-types.test.ts
  95. +20 −20 packages/eslint-plugin/tests/rules/no-misused-new.test.ts
  96. +51 −51 packages/eslint-plugin/tests/rules/no-namespace.test.ts
  97. +6 −6 packages/eslint-plugin/tests/rules/no-non-null-assertion.test.ts
  98. +27 −27 packages/eslint-plugin/tests/rules/no-object-literal-type-assertion.test.ts
  99. +153 −153 packages/eslint-plugin/tests/rules/no-parameter-properties.test.ts
  100. +18 −18 packages/eslint-plugin/tests/rules/no-require-imports.test.ts
  101. +21 −21 packages/eslint-plugin/tests/rules/no-this-alias.test.ts
  102. +10 −10 packages/eslint-plugin/tests/rules/no-triple-slash-reference.test.ts
  103. +713 −713 packages/eslint-plugin/tests/rules/no-type-alias.test.ts
  104. +29 −29 packages/eslint-plugin/tests/rules/no-unnecessary-qualifier.test.ts
  105. +25 −25 packages/eslint-plugin/tests/rules/no-unnecessary-type-assertion.test.ts
  106. +64 −64 packages/eslint-plugin/tests/rules/no-unused-vars.test.ts
  107. +171 −171 packages/eslint-plugin/tests/rules/no-use-before-define.test.ts
  108. +16 −16 packages/eslint-plugin/tests/rules/no-useless-constructor.test.ts
  109. +12 −12 packages/eslint-plugin/tests/rules/no-var-requires.test.ts
  110. +23 −23 packages/eslint-plugin/tests/rules/prefer-function-type.test.ts
  111. +16 −16 packages/eslint-plugin/tests/rules/prefer-interface.test.ts
  112. +14 −14 packages/eslint-plugin/tests/rules/prefer-namespace-keyword.test.ts
  113. +60 −60 packages/eslint-plugin/tests/rules/promise-function-async.test.ts
  114. +11 −11 packages/eslint-plugin/tests/rules/require-array-sort-compare.test.ts
  115. +59 −59 packages/eslint-plugin/tests/rules/restrict-plus-operands.test.ts
  116. +1,179 −1,179 packages/eslint-plugin/tests/rules/type-annotation-spacing.test.ts
  117. +21 −21 packages/eslint-plugin/tests/util.test.ts
  118. +3 −3 packages/eslint-plugin/tools/update-recommended.ts
  119. +8 −8 packages/eslint-plugin/typings/eslint-rules.d.ts
  120. +1 −1 packages/eslint-plugin/typings/requireindex.d.ts
  121. +27 −27 packages/eslint-plugin/typings/ts-eslint.d.ts
  122. +2 −2 packages/parser/jest.config.js
  123. +16 −16 packages/parser/src/analyze-scope.ts
  124. +6 −6 packages/parser/src/parser.ts
  125. +2 −2 packages/parser/src/scope/scope-manager.ts
  126. +2 −2 packages/parser/src/scope/scopes.ts
  127. +4 −4 packages/parser/src/visitor-keys.ts
  128. +10 −10 packages/parser/tests/lib/basics.ts
  129. +4 −4 packages/parser/tests/lib/comments.ts
  130. +2 −2 packages/parser/tests/lib/javascript.ts
  131. +5 −5 packages/parser/tests/lib/jsx.ts
  132. +9 −9 packages/parser/tests/lib/parser.ts
  133. +6 −6 packages/parser/tests/lib/scope-analysis.ts
  134. +3 −3 packages/parser/tests/lib/services.ts
  135. +22 −22 packages/parser/tests/lib/tsx.ts
  136. +2 −2 packages/parser/tests/lib/typescript.ts
  137. +1 −1 packages/parser/tests/lib/visitor-keys.ts
  138. +9 −9 packages/parser/tests/tools/scope-analysis.ts
  139. +4 −4 packages/parser/tests/tools/test-utils.ts
  140. +24 −24 packages/parser/typings/eslint-scope.d.ts
  141. +1 −1 packages/typescript-estree/README.md
  142. +2 −2 packages/typescript-estree/jest.config.js
  143. +2 −2 packages/typescript-estree/src/ast-converter.ts
  144. +8 −8 packages/typescript-estree/src/convert-comments.ts
  145. +231 −231 packages/typescript-estree/src/convert.ts
  146. +22 −22 packages/typescript-estree/src/node-utils.ts
  147. +17 −17 packages/typescript-estree/src/parser.ts
  148. +9 −9 packages/typescript-estree/src/semantic-errors.ts
  149. +2 −2 packages/typescript-estree/src/ts-estree/ast-node-types.ts
  150. +12 −11 packages/typescript-estree/src/tsconfig-parser.ts
  151. +47 −47 packages/typescript-estree/tests/ast-alignment/fixtures-to-test.ts
  152. +9 −9 packages/typescript-estree/tests/ast-alignment/parse.ts
  153. +9 −9 packages/typescript-estree/tests/ast-alignment/spec.ts
  154. +19 −19 packages/typescript-estree/tests/ast-alignment/utils.ts
  155. +3 −3 packages/typescript-estree/tests/lib/comments.ts
  156. +23 −19 packages/typescript-estree/tests/lib/convert.ts
  157. +3 −3 packages/typescript-estree/tests/lib/javascript.ts
  158. +5 −5 packages/typescript-estree/tests/lib/jsx.ts
  159. +11 −11 packages/typescript-estree/tests/lib/parse.ts
  160. +2 −2 packages/typescript-estree/tests/lib/semantic-diagnostics-enabled.ts
  161. +32 −32 packages/typescript-estree/tests/lib/semanticInfo.ts
  162. +3 −3 packages/typescript-estree/tests/lib/tsx.ts
  163. +3 −3 packages/typescript-estree/tests/lib/typescript.ts
  164. +2 −2 packages/typescript-estree/tests/lib/warn-on-unsupported-ts.ts
  165. +4 −4 packages/typescript-estree/tools/test-utils.ts
  166. +2 −2 tests/integration/utils/generate-package-json.js
  167. +1 −1 tests/integration/utils/jest-snapshot-resolver.js
@@ -2,6 +2,7 @@ node_modules
dist
jest.config.js
fixtures
shared-fixtures
coverage

packages/typescript-estree/src/estree
@@ -7,6 +7,7 @@
},
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
"rules": {
"comma-dangle": ["error", "always-multiline"],
"no-mixed-operators": "error",
"no-console": "off",
"no-undef": "off",
@@ -5,4 +5,5 @@
**/tests/integration/fixtures/**/*
**/lib/configs/recommended.json
**/.vscode
**/.nyc_output
**/.nyc_output
packages/eslint-plugin-tslint/tests/test-tslint-rules-directory/alwaysFailRule.js
@@ -0,0 +1,3 @@
{
"trailingComma": "all"
}
@@ -3,11 +3,11 @@
module.exports = {
testEnvironment: 'node',
transform: {
'^.+\\.tsx?$': 'ts-jest'
'^.+\\.tsx?$': 'ts-jest',
},
testRegex: './tests/.+\\.spec\\.ts$',
collectCoverage: false,
collectCoverageFrom: ['src/**/*.{js,jsx,ts,tsx}'],
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
coverageReporters: ['text-summary', 'lcov']
coverageReporters: ['text-summary', 'lcov'],
};
@@ -30,20 +30,20 @@ const tslintConfig = memoize(
(
lintFile: string,
tslintRules: RawRulesConfig,
tslintRulesDirectory: string[]
tslintRulesDirectory: string[],
) => {
if (lintFile != null) {
return Configuration.loadConfigurationFromPath(lintFile);
}
return Configuration.parseConfigFile({
rules: tslintRules || {},
rulesDirectory: tslintRulesDirectory || []
rulesDirectory: tslintRulesDirectory || [],
});
},
(lintFile: string | undefined, tslintRules = {}, tslintRulesDirectory = []) =>
`${lintFile}_${Object.keys(tslintRules).join(',')}_${
tslintRulesDirectory.length
}`
}`,
);

export const rules = {
@@ -56,7 +56,7 @@ export const rules = {
docs: {
description:
'Wraps a TSLint configuration and lints the whole source using TSLint',
category: 'TSLint'
category: 'TSLint',
},
schema: [
{
@@ -67,21 +67,21 @@ export const rules = {
/**
* No fixed schema properties for rules, as this would be a permanently moving target
*/
additionalProperties: true
additionalProperties: true,
},
rulesDirectory: {
type: 'array',
items: {
type: 'string'
}
type: 'string',
},
},
lintFile: {
type: 'string'
}
type: 'string',
},
},
additionalProperties: false
}
]
additionalProperties: false,
},
],
},
create: function(context: Rule.RuleContext) {
const fileName = context.getFilename();
@@ -94,7 +94,7 @@ export const rules = {
*/
if (!parserServices || !parserServices.program) {
throw new Error(
`You must provide a value for the "parserOptions.project" property for @typescript-eslint/parser`
`You must provide a value for the "parserOptions.project" property for @typescript-eslint/parser`,
);
}

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

const program: Program = parserServices.program;
@@ -116,13 +116,13 @@ export const rules = {
*/
const tslintOptions = {
formatter: 'json',
fix: false
fix: false,
};
const tslint = new CustomLinter(tslintOptions, program);
const configuration = tslintConfig(
lintFile,
tslintRules,
tslintRulesDirectory
tslintRulesDirectory,
);
tslint.lint(fileName, sourceCode, configuration);

@@ -140,13 +140,13 @@ export const rules = {
loc: {
start: {
line: start.line + 1,
column: start.character
column: start.character,
},
end: {
line: end.line + 1,
column: end.character
}
}
column: end.character,
},
},
});
});
}
@@ -155,6 +155,6 @@ export const rules = {
* Return an empty object for the ESLint rule
*/
return {};
}
}
},
},
};
@@ -11,18 +11,18 @@ const ruleTester = new RuleTester({
* Project is needed to generate the parserServices
* within @typescript-eslint/parser
*/
project: './tests/tsconfig.json'
project: './tests/tsconfig.json',
},
parser: '@typescript-eslint/parser'
parser: '@typescript-eslint/parser',
});

/**
* Inline rules should be supported
*/
const tslintRulesConfig = {
rules: {
semicolon: [true, 'always']
}
semicolon: [true, 'always'],
},
};

/**
@@ -32,36 +32,36 @@ const tslintRulesDirectoryConfig = {
rulesDirectory: ['./tests/test-tslint-rules-directory'],
rules: {
'always-fail': {
severity: 'error'
}
}
severity: 'error',
},
},
};

ruleTester.run('tslint/config', rules.config, {
valid: [
{
code: 'var foo = true;',
options: [tslintRulesConfig]
options: [tslintRulesConfig],
},
{
filename: './tests/test-project/file-spec.ts',
code: readFileSync('./tests/test-project/file-spec.ts', 'utf8').replace(
/\n/g,
' '
' ',
),
parserOptions: {
project: `${__dirname}/test-project/tsconfig.json`
project: `${__dirname}/test-project/tsconfig.json`,
},
options: [
{
...tslintRulesConfig
}
]
...tslintRulesConfig,
},
],
},
{
code: 'throw "should be ok because rule is not loaded";',
options: [tslintRulesConfig]
}
options: [tslintRulesConfig],
},
],

invalid: [
@@ -71,9 +71,9 @@ ruleTester.run('tslint/config', rules.config, {
errors: [
{
message:
'Throwing plain strings (not instances of Error) gives no stack traces (tslint:no-string-throw)'
}
]
'Throwing plain strings (not instances of Error) gives no stack traces (tslint:no-string-throw)',
},
],
},
{
code: 'var foo = true // semicolon',
@@ -83,9 +83,9 @@ ruleTester.run('tslint/config', rules.config, {
{
message: 'Missing semicolon (tslint:semicolon)',
line: 1,
column: 15
}
]
column: 15,
},
],
},
{
code: 'var foo = true // fail',
@@ -95,33 +95,33 @@ ruleTester.run('tslint/config', rules.config, {
{
message: 'failure (tslint:always-fail)',
line: 1,
column: 1
}
]
column: 1,
},
],
},
{
filename: './tests/test-project/source.ts',
code: readFileSync('./tests/test-project/source.ts', 'utf8').replace(
/\n/g,
' '
' ',
),
parserOptions: {
project: `${__dirname}/test-project/tsconfig.json`
project: `${__dirname}/test-project/tsconfig.json`,
},
options: [
{
rulesDirectory: [
`${__dirname}/../../../node_modules/tslint/lib/rules`
`${__dirname}/../../../node_modules/tslint/lib/rules`,
],
rules: { 'restrict-plus-operands': true }
}
rules: { 'restrict-plus-operands': true },
},
],
errors: [
{
message:
"Operands of '+' operation must either be both strings or both numbers, consider using template literals (tslint:restrict-plus-operands)"
}
]
}
]
"Operands of '+' operation must either be both strings or both numbers, consider using template literals (tslint:restrict-plus-operands)",
},
],
},
],
});
@@ -1,3 +1,4 @@

const Lint = require('tslint');

class Rule extends Lint.Rules.AbstractRule {
@@ -68,7 +68,7 @@ function foo({ no_camelcased = 'default value' }) {
}
var obj = {
my_pref: 1
my_pref: 1,
};
var { category_id = 1 } = query;
@@ -125,7 +125,7 @@ Examples of **correct** code for this rule with the `{ "properties": "never" }`
/*eslint @typescript-eslint/camelcase: ["error", {properties: "never"}]*/
var obj = {
my_pref: 1
my_pref: 1,
};
```

@@ -42,7 +42,7 @@ const StaticOnly = {
version: 42,
hello() {
console.log('Hello, world!');
}
},
};
```

@@ -45,9 +45,9 @@ You can pass an object option:
'error',
{
allowDestructuring: true, // Allow `const { props, state } = this`; false by default
allowedNames: ['self'] // Allow `const self = this`; `[]` by default
}
]
allowedNames: ['self'], // Allow `const self = this`; `[]` by default
},
],
}
```

@@ -24,7 +24,7 @@ namespace A {
```ts
enum A {
B,
C = A.B
C = A.B,
}
```

@@ -52,11 +52,11 @@ namespace Y {
```ts
enum A {
X,
Y
Y,
}
enum B {
Z = A.X
Z = A.X,
}
```

@@ -63,7 +63,7 @@ alert(x);
myFunc(
function foo() {
// ...
}.bind(this)
}.bind(this),
);
(function(foo) {
Oops, something went wrong.

0 comments on commit 1d9ca84

Please sign in to comment.
You can’t perform that action at this time.