eslint-config-gristow 2.0.5 → 2.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,23 +1,20 @@
1
1
  {
2
- // These are all my auto-save configs
3
- "editor.formatOnSave": true,
4
- // turn it off for JS and JSX, we will do this via eslint
5
- "[javascript]": {
6
- "editor.formatOnSave": false
7
- },
8
- "[typescript]": {
9
- "editor.formatOnSave": false
10
- },
11
- "[svelte]": {
12
- "editor.defaultFormatter": "esbenp.prettier-vscode"
13
- },
14
- // tell the ESLint plugin to run on save
15
- "editor.codeActionsOnSave": {
16
- "source.fixAll.eslint": true
17
- },
18
- "eslint.autoFixOnSave": true,
19
- // Optional BUT IMPORTANT: If you have the prettier extension enabled for other languages like CSS and HTML, turn it off for JS since we are doing it through Eslint already
20
- "prettier.disableLanguages": ["javascript", "javascriptreact", "typescript"],
21
- "eslint.validate": ["javascript", "javascriptreact", "typescript", "svelte"],
22
- "eslint.probe": ["javascript", "typescript", "html", "svelte", "markdown"]
2
+ "[javascript]": {
3
+ "editor.codeActionsOnSave": {
4
+ "source.fixAll.eslint": true
5
+ }
6
+ },
7
+ "[typescript]": {
8
+ "editor.codeActionsOnSave": {
9
+ "source.fixAll.eslint": true
10
+ }
11
+ },
12
+ "eslint.validate": ["javascript", "typescript", "svelte"],
13
+ "eslint.probe": ["javascript", "typescript", "html", "svelte", "markdown"],
14
+ "editor.defaultFormatter": "esbenp.prettier-vscode",
15
+ "editor.formatOnSave": true,
16
+ "typescript.tsdk": "node_modules/typescript/lib",
17
+ "prettier.disableLanguages": ["javascript", "javascriptreact", "typescript"],
18
+ "editor.tabSize": 2,
19
+ "editor.insertSpaces": true
23
20
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-config-gristow",
3
- "version": "2.0.5",
3
+ "version": "2.0.6",
4
4
  "description": "Eslint settings for Greg Ristow",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -83,9 +83,70 @@ module.exports = {
83
83
  'implicit-arrow-linebreak': 'off',
84
84
  'function-paren-newline': 'off',
85
85
  // Snake case often comes in via external libraries
86
- camelcase: ['error', {
87
- properties: 'always',
88
- ignoreDestructuring: true,
89
- ignoreImports: true,
90
- }]
86
+ // camelcase: ['error', {
87
+ // properties: 'always',
88
+ // ignoreDestructuring: true,
89
+ // ignoreImports: true,
90
+ // }],
91
+ camelcase: 'off',
92
+ '@typescript-eslint/naming-convention': [
93
+ 'error',
94
+ // By default, all should be camelCase
95
+ {
96
+ selector: 'default',
97
+ format: ['camelCase'],
98
+ },
99
+ // But, when we're destructuring, allow whatever it was:
100
+ {
101
+ selector: 'variable',
102
+ modifiers: ['destructured'],
103
+ format: null,
104
+ },
105
+ // And, if the property requires quotes, allow anything:
106
+ {
107
+ selector: [
108
+ 'classProperty',
109
+ 'objectLiteralProperty',
110
+ 'typeProperty',
111
+ 'classMethod',
112
+ 'objectLiteralMethod',
113
+ 'typeMethod',
114
+ 'accessor',
115
+ 'enumMember',
116
+ ],
117
+ format: null,
118
+ modifiers: ['requiresQuotes'],
119
+ },
120
+ // But require variables to be in camelCase or UPPER_SNAKE
121
+ {
122
+ selector: 'variable',
123
+ format: ['camelCase', 'UPPER_CASE'],
124
+ },
125
+ // Allow leading underscores in function params
126
+ {
127
+ selector: 'parameter',
128
+ format: ['camelCase'],
129
+ leadingUnderscore: 'allow',
130
+ },
131
+ // Allow leading underscores in class private members
132
+ {
133
+ selector: 'memberLike',
134
+ modifiers: ['private'],
135
+ format: ['camelCase'],
136
+ leadingUnderscore: 'allow',
137
+ },
138
+ // And allow snake_case in object literals -- which simplifies
139
+ // our interaction with external libraries where options objects
140
+ // often require these.
141
+ {
142
+ selector: 'objectLiteralProperty',
143
+ format: ['camelCase', 'snake_case'],
144
+ },
145
+ // Make sure types and interfaces are in PascalCase. (Also applies
146
+ // to classes.)
147
+ {
148
+ selector: 'typeLike',
149
+ format: ['PascalCase'],
150
+ },
151
+ ],
91
152
  };
package/test-ts-export.ts CHANGED
@@ -1,3 +1,5 @@
1
1
  export function greet(firstName: string, lastName: string): string {
2
2
  return `${firstName} ${lastName}`;
3
3
  }
4
+
5
+ export const snake_case_import = 'snake case import';
package/test.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { greetJS } from './test-js-export';
2
- import { greet } from './test-ts-export';
2
+ import { greet, snake_case_import } from './test-ts-export';
3
3
 
4
4
  greetJS('Johnny', 'Appleseed');
5
5
  greet('Jenny', 'Applesseed');
@@ -25,4 +25,23 @@ function addOne(n) {
25
25
  return n + 1;
26
26
  }
27
27
 
28
+ // error because not PascalCase
29
+ export class myClassName {}
30
+
31
+ const SNAKE_CASE_VARIABLE = 'snake case variable';
32
+ console.log(SNAKE_CASE_VARIABLE);
33
+
34
+ const this_is_a_problem = 'snake case variable';
35
+ console.log(this_is_a_problem);
36
+
37
+ console.log(snake_case_import);
38
+
39
+ const coordinates = {
40
+ x_top: 0,
41
+ };
42
+
43
+ const { x_top } = coordinates;
44
+
28
45
  throw 'hello';
46
+
47
+ console.log('unreachable code error!');