Skip to content

Commit e97d4bc

Browse files
authored
Add ESLint configuration as a package and setup for itself (#3)
* [eslint-config] add eslint-config package * Bump-up pnpify * [eslint-plugin] rename eslint-config to eslint-plugin * Setup ESLint * [eslint-plugin] use js instead of json to avoid yarn 2 resolution issue * [eslint-plugin] disabled @typescript-eslint's indent rule * bump eslint pnpify version * Fix format * [eslint-plugin] ignore max-len for comments * [eslint-plugin] add default option for typescript projects * [eslint-plugin] set quote-props rule as consistent-as-needed * enable eslint for workspace by default * cleanup gitattributes * [eslint-plugin] release minor ---- Issues: - Need to install plugins even eslint-plugin package provide it as dependencies. (yarnpkg/berry#8) - Cannot check indentations of TypeScript files properly. (typescript-eslint/typescript-eslint#1824)
1 parent f247b87 commit e97d4bc

File tree

237 files changed

+4873
-188
lines changed

Some content is hidden

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

237 files changed

+4873
-188
lines changed

.eslintignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/.vscode/
2+
/.yarn/
3+
/.pnp.js
4+
5+
**/lib/**

.eslintrc.json

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"env": {
3+
"node": true
4+
},
5+
"plugins": ["@cometjs"],
6+
"extends": "plugin:@cometjs/auto"
7+
}

.gitattributes

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
/.yarn/releases/* binary linguist-generated
55
/.yarn/cache/* binary linguist-vendored
66
/.yarn/unplugged/* linguist-vendored
7-
/.yarn/plugins/@yarnpkg/* binary linguist-generated
7+
/.yarn/plugins/* binary linguist-generated
8+
/.vscode/pnpify/* binary linguist-generated
89
/.vscode/*.json linguist-language=JSON5
9-
/.vscode/pnpify/typescript/** binary linguist-generated
1010
/.tsconfig.json linguist-language=JSON5

.pnp.js

+2,446-60
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.vscode/pnpify/eslint/bin/eslint.js

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env node
2+
3+
const {existsSync} = require(`fs`);
4+
const {createRequire, createRequireFromPath} = require(`module`);
5+
const {resolve} = require(`path`);
6+
7+
const relPnpApiPath = "../../../../.pnp.js";
8+
9+
const absPnpApiPath = resolve(__dirname, relPnpApiPath);
10+
const absRequire = (createRequire || createRequireFromPath)(absPnpApiPath);
11+
12+
if (existsSync(absPnpApiPath)) {
13+
// Setup the environment to be able to require eslint/bin/eslint.js
14+
require(absPnpApiPath).setup();
15+
}
16+
17+
// Defer to the real eslint/bin/eslint.js your application uses
18+
module.exports = absRequire(`eslint/bin/eslint.js`);

.vscode/pnpify/eslint/lib/api.js

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env node
2+
3+
const {existsSync} = require(`fs`);
4+
const {createRequire, createRequireFromPath} = require(`module`);
5+
const {resolve} = require(`path`);
6+
7+
const relPnpApiPath = "../../../../.pnp.js";
8+
9+
const absPnpApiPath = resolve(__dirname, relPnpApiPath);
10+
const absRequire = (createRequire || createRequireFromPath)(absPnpApiPath);
11+
12+
if (existsSync(absPnpApiPath)) {
13+
// Setup the environment to be able to require eslint/lib/api.js
14+
require(absPnpApiPath).setup();
15+
}
16+
17+
// Defer to the real eslint/lib/api.js your application uses
18+
module.exports = absRequire(`eslint/lib/api.js`);

.vscode/pnpify/eslint/package.json

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"name": "eslint",
3+
"version": "7.0.0-rc.0-pnpify",
4+
"main": "./lib/api.js",
5+
"type": "commonjs"
6+
}

.vscode/pnpify/typescript/bin/tsc

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/usr/bin/env node
22

3+
const {existsSync} = require(`fs`);
34
const {createRequire, createRequireFromPath} = require(`module`);
45
const {resolve} = require(`path`);
56

@@ -8,8 +9,10 @@ const relPnpApiPath = "../../../../.pnp.js";
89
const absPnpApiPath = resolve(__dirname, relPnpApiPath);
910
const absRequire = (createRequire || createRequireFromPath)(absPnpApiPath);
1011

11-
// Setup the environment to be able to require typescript/bin/tsc
12-
require(absPnpApiPath).setup();
12+
if (existsSync(absPnpApiPath)) {
13+
// Setup the environment to be able to require typescript/bin/tsc
14+
require(absPnpApiPath).setup();
15+
}
1316

1417
// Defer to the real typescript/bin/tsc your application uses
1518
module.exports = absRequire(`typescript/bin/tsc`);
+5-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/usr/bin/env node
22

3+
const {existsSync} = require(`fs`);
34
const {createRequire, createRequireFromPath} = require(`module`);
45
const {resolve} = require(`path`);
56

@@ -8,8 +9,10 @@ const relPnpApiPath = "../../../../.pnp.js";
89
const absPnpApiPath = resolve(__dirname, relPnpApiPath);
910
const absRequire = (createRequire || createRequireFromPath)(absPnpApiPath);
1011

11-
// Setup the environment to be able to require typescript/bin/tsserver
12-
require(absPnpApiPath).setup();
12+
if (existsSync(absPnpApiPath)) {
13+
// Setup the environment to be able to require typescript/bin/tsserver
14+
require(absPnpApiPath).setup();
15+
}
1316

1417
// Defer to the real typescript/bin/tsserver your application uses
1518
module.exports = absRequire(`typescript/bin/tsserver`);

.vscode/pnpify/typescript/lib/tsc.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/usr/bin/env node
22

3+
const {existsSync} = require(`fs`);
34
const {createRequire, createRequireFromPath} = require(`module`);
45
const {resolve} = require(`path`);
56

@@ -8,8 +9,10 @@ const relPnpApiPath = "../../../../.pnp.js";
89
const absPnpApiPath = resolve(__dirname, relPnpApiPath);
910
const absRequire = (createRequire || createRequireFromPath)(absPnpApiPath);
1011

11-
// Setup the environment to be able to require typescript/lib/tsc.js
12-
require(absPnpApiPath).setup();
12+
if (existsSync(absPnpApiPath)) {
13+
// Setup the environment to be able to require typescript/lib/tsc.js
14+
require(absPnpApiPath).setup();
15+
}
1316

1417
// Defer to the real typescript/lib/tsc.js your application uses
1518
module.exports = absRequire(`typescript/lib/tsc.js`);
+5-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/usr/bin/env node
22

3+
const {existsSync} = require(`fs`);
34
const {createRequire, createRequireFromPath} = require(`module`);
45
const {resolve} = require(`path`);
56

@@ -8,8 +9,10 @@ const relPnpApiPath = "../../../../.pnp.js";
89
const absPnpApiPath = resolve(__dirname, relPnpApiPath);
910
const absRequire = (createRequire || createRequireFromPath)(absPnpApiPath);
1011

11-
// Setup the environment to be able to require typescript/lib/tsserver.js
12-
require(absPnpApiPath).setup();
12+
if (existsSync(absPnpApiPath)) {
13+
// Setup the environment to be able to require typescript/lib/tsserver.js
14+
require(absPnpApiPath).setup();
15+
}
1316

1417
// Defer to the real typescript/lib/tsserver.js your application uses
1518
module.exports = absRequire(`typescript/lib/tsserver.js`);
+5-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/usr/bin/env node
22

3+
const {existsSync} = require(`fs`);
34
const {createRequire, createRequireFromPath} = require(`module`);
45
const {resolve} = require(`path`);
56

@@ -8,8 +9,10 @@ const relPnpApiPath = "../../../../.pnp.js";
89
const absPnpApiPath = resolve(__dirname, relPnpApiPath);
910
const absRequire = (createRequire || createRequireFromPath)(absPnpApiPath);
1011

11-
// Setup the environment to be able to require typescript/lib/typescript.js
12-
require(absPnpApiPath).setup();
12+
if (existsSync(absPnpApiPath)) {
13+
// Setup the environment to be able to require typescript/lib/typescript.js
14+
require(absPnpApiPath).setup();
15+
}
1316

1417
// Defer to the real typescript/lib/typescript.js your application uses
1518
module.exports = absRequire(`typescript/lib/typescript.js`);

.vscode/settings.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
{
2-
"typescript.tsdk": ".vscode/pnpify/typescript/lib"
2+
"typescript.tsdk": ".vscode/pnpify/typescript/lib",
3+
"typescript.enablePromptUseWorkspaceTsdk": true,
4+
"eslint.nodePath": ".vscode/pnpify",
5+
"eslint.enable": true
36
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
8.05 KB
Binary file not shown.
242 KB
Binary file not shown.
238 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
40.6 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
15.1 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
18.2 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
3.67 KB
Binary file not shown.
12.8 KB
Binary file not shown.
18.9 KB
Binary file not shown.
6.09 KB
Binary file not shown.
Binary file not shown.
5.91 KB
Binary file not shown.
24.3 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
5.48 KB
Binary file not shown.
Binary file not shown.
114 KB
Binary file not shown.
2.93 KB
Binary file not shown.
27.2 KB
Binary file not shown.
27.3 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
23.1 KB
Binary file not shown.
115 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
37.5 KB
Binary file not shown.
Binary file not shown.
8.38 KB
Binary file not shown.
5.32 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
10.9 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
9.98 KB
Binary file not shown.
8.65 KB
Binary file not shown.
56.7 KB
Binary file not shown.
2.6 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
15.4 KB
Binary file not shown.
18.1 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
32.8 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
3.02 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
13.4 KB
Binary file not shown.
4.47 KB
Binary file not shown.
10.3 KB
Binary file not shown.
8.21 KB
Binary file not shown.
11.1 KB
Binary file not shown.
85.4 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
6.17 KB
Binary file not shown.
8.75 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
3.12 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
2.14 KB
Binary file not shown.
3.49 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
4.33 KB
Binary file not shown.
Binary file not shown.
3.28 KB
Binary file not shown.
2.92 KB
Binary file not shown.
Binary file not shown.
6.37 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
7.49 KB
Binary file not shown.
Binary file not shown.
34.8 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
4.59 KB
Binary file not shown.
4.67 KB
Binary file not shown.
Binary file not shown.
49.2 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
49.7 KB
Binary file not shown.
50.7 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
6.08 KB
Binary file not shown.
6.36 KB
Binary file not shown.
3.52 KB
Binary file not shown.
Binary file not shown.
20.1 KB
Binary file not shown.
36.6 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
2.82 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
67.2 KB
Binary file not shown.
Binary file not shown.
6.8 KB
Binary file not shown.
8.69 KB
Binary file not shown.
Binary file not shown.
48.8 KB
Binary file not shown.
11.3 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
27.8 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
5.58 KB
Binary file not shown.
5.12 KB
Binary file not shown.
5.26 KB
Binary file not shown.
186 KB
Binary file not shown.

package.json

+9-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,15 @@
1212
"tsc:all": "tsc --noEmit"
1313
},
1414
"devDependencies": {
15-
"@yarnpkg/pnpify": "^2.0.0-rc.20",
15+
"@babel/core": "^7.9.6",
16+
"@cometjs/eslint-plugin": "workspace:packages/eslint-plugin",
17+
"@typescript-eslint/eslint-plugin": "^2.30.0",
18+
"@yarnpkg/pnpify": "^2.0.0-rc.22",
19+
"eslint": "7.0.0-rc.0",
20+
"eslint-plugin-flowtype": "^4.7.0",
21+
"eslint-plugin-jsx-a11y": "^6.2.3",
22+
"eslint-plugin-react": "^7.19.0",
23+
"eslint-plugin-react-hooks": "^4.0.0",
1624
"typescript": "^3.8.3"
1725
}
1826
}

packages/apollo-client-utils/src/result.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ type ErrorResult = {
1212
data: undefined,
1313
error: ApolloError,
1414
loading: false,
15-
}
15+
};
1616

1717
type DataResult<T> = {
1818
data: Some<T>,
@@ -53,7 +53,9 @@ export function castQueryResult<T>(result: QueryResult<T>): Result<T> {
5353
reasons.push('is not compatible with DataResult<T> because `data` field is missing');
5454
}
5555
if (reasons.length) {
56-
throw new Error(`Given object is not compatible with Result<T> because:\n${reasons.join('\n -')}`);
56+
throw new Error(
57+
`Given object is not compatible with Result<T> because:\n${reasons.join('\n -')}`,
58+
);
5759
}
5860
return result as Result<T>;
5961
}
@@ -69,7 +71,7 @@ export function mapResult<
6971
data: RData | ((data: Some<TData>) => RData),
7072
error: RError | ((error: ApolloError) => RError),
7173
loading: RLoading | (() => RLoading),
72-
}
74+
},
7375
): RData | RError | RLoading {
7476
const safeResult = castQueryResult(result);
7577
if (isLoadingResult(safeResult)) {

packages/core/src/option.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export function mapOption<T, RSome, RNone = None>(
6464
some: RSome | ((t: Some<T>) => RSome),
6565
none: RNone | (() => RNone),
6666
})
67-
)
67+
),
6868
): RSome | RNone {
6969
if (typeof map === 'function') {
7070
return isSome(option)
@@ -75,14 +75,14 @@ export function mapOption<T, RSome, RNone = None>(
7575

7676
if (typeof map !== 'object') {
7777
throw new Error(
78-
`The second argument only allows function or object but got: ${typeof map}`
78+
`The second argument only allows function or object but got: ${typeof map}`,
7979
);
8080
}
8181

8282
const matchedMap = map[matchOption(option)];
8383
if (!matchedMap) {
8484
throw new Error(
85-
`The object doesn't have map to ${optionToString(option)} type`
85+
`The object doesn't have map to ${optionToString(option)} type`,
8686
);
8787
}
8888
return isSome(option)

packages/eslint-plugin/LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2020 Hyeseong Kim <[email protected]>
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
module.exports = {
2+
plugins: [
3+
'@cometjs',
4+
],
5+
extends: [
6+
'plugin:@cometjs/base',
7+
],
8+
overrides: [
9+
{
10+
files: ['**/*.ts?(x)'],
11+
extends: ['plugin:@cometjs/typescript'],
12+
},
13+
{
14+
files: ['**/*.js?(x)'],
15+
extends: ['plugin:@cometjs/flow'],
16+
},
17+
{
18+
files: ['**/*.{jsx,tsx}'],
19+
extends: ['plugin:@cometjs/react'],
20+
},
21+
{
22+
files: [
23+
'**/*.test.{js,jsx,ts,tsx}',
24+
'**/__test?(s)__/**/*.{js,jsx,ts,tsx}',
25+
'**/__mock?(s)__/**/*.{js,jsx,ts,tsx}',
26+
],
27+
env: {
28+
node: true,
29+
jest: true,
30+
},
31+
},
32+
],
33+
};
+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
module.exports = {
2+
parserOptions: {
3+
ecmaVersion: 2018,
4+
sourceType: 'module',
5+
},
6+
env: {
7+
es6: true,
8+
},
9+
extends: [
10+
'eslint:recommended',
11+
],
12+
rules: {
13+
'max-len': ['error', {
14+
code: 100,
15+
tabWidth: 2,
16+
ignoreComments: true,
17+
ignoreTrailingComments: true,
18+
ignoreUrls: true,
19+
ignoreStrings: true,
20+
ignoreTemplateLiterals: true,
21+
ignoreRegExpLiterals: true,
22+
}],
23+
'indent': ['error', 2],
24+
'semi': ['error', 'always'],
25+
'quotes': ['error', 'single'],
26+
'quote-props': ['error', 'consistent-as-needed'],
27+
'eol-last': ['error', 'always'],
28+
'eqeqeq': ['error', 'always', { null: 'ignore' }],
29+
'comma-spacing': ['error', { before: false, after: true }],
30+
'comma-dangle': ['error', 'always-multiline'],
31+
'array-bracket-newline': ['error', 'consistent'],
32+
'arrow-spacing': ['error', { before: true, after: true }],
33+
'array-element-newline': ['off', { multiline: true, minItems: 3 }],
34+
'object-curly-spacing': ['error', 'always'],
35+
'object-curly-newline': ['error', {
36+
ObjectExpression: {
37+
consistent: true,
38+
},
39+
ObjectPattern: {
40+
consistent: true,
41+
},
42+
ImportDeclaration: {
43+
multiline: true,
44+
minProperties: 3,
45+
},
46+
ExportDeclaration: {
47+
multiline: true,
48+
minProperties: 3,
49+
},
50+
}],
51+
'no-console': 'warn',
52+
},
53+
};
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
module.exports = {
2+
parser: require.resolve('babel-eslint'),
3+
plugins: [
4+
'@cometjs',
5+
'flowtype',
6+
],
7+
extends: [
8+
'plugin:@cometjs/base',
9+
'plugin:flowtype/recommended',
10+
],
11+
settings: {
12+
flowtype: {
13+
onlyFilesWithFlowAnnotation: true,
14+
},
15+
},
16+
};

0 commit comments

Comments
 (0)