Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting up ESLint #110

Merged
merged 19 commits into from
Jul 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 0 additions & 23 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,25 +126,6 @@ browsers_unit_tests: &browsers_unit_tests
command: if [ "$CIRCLE_NODE_VERSION" = "v12" ]; then npm run codecov:browser; fi

jobs:
lint:
docker:
- image: node:12
environment:
NPM_CONFIG_UNSAFE_PERM: true
steps:
- checkout
- run:
name: Install minimal lint modules globally
command: npm i -g tslint lerna typescript tslint-consistent-codestyle tslint-microsoft-contrib
- run:
name: Install gts version 1.1.0 globally
command: npm i -g [email protected]
- run:
name: Symlink global modules into all lerna packages
command: lerna exec 'npm link tslint lerna typescript gts tslint-consistent-codestyle tslint-microsoft-contrib'
- run:
name: Check code style and linting
command: npm run lint
node8:
docker:
- image: node:8
Expand Down Expand Up @@ -181,10 +162,6 @@ workflows:
version: 2
build:
jobs:
- lint:
filters:
branches:
only: /.*/
- node8
- node10
- node12
Expand Down
28 changes: 28 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Lint

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: restore lerna
uses: actions/cache@master # must use unreleased master to cache multiple paths
id: cache
with:
path: |
node_modules
packages/*/node_modules
metapackages/*/node_modules
key: ${{ runner.os }}-${{ hashFiles('**/package.json') }}

- name: Bootstrap
if: steps.cache.outputs.cache-hit != 'true'
run: |
npm install --only=dev --ignore-scripts
npx lerna bootstrap --no-ci --ignore-scripts -- --only=dev
- name: Lint
run: npm run lint
49 changes: 49 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
module.exports = {
plugins: [
"@typescript-eslint",
"header"
],
extends: [
"./node_modules/gts",
Copy link
Member

@markwolff markwolff Jul 8, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we could extend the eslint config from the main repo so that changes are automatically picked up after a main repo release? wdyt @dyladan? (Not in scope for this PR though!)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if there is a way to depend on the file directly in github instead of a release. Very interesting idea though. A package like @opentelemetry/eslint-config would be a welcome addition I think.

Copy link
Member

@markwolff markwolff Jul 8, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes we could do something like npm install --save-dev https://github.com/opentelemetry-js/opentelemetry-js/tarball/master, or just the normal cloning url

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dyladan maybe we can create some general package that can be easily shared between contrib repo and here andd maybe even a 3rd party contrib. We could put there a bit more stuff, eslint, karma config, etc. basically all things that could be shared. WDYT ?

],
parser: "@typescript-eslint/parser",
parserOptions: {
"project": "./tsconfig.json"
},
rules: {
"@typescript-eslint/no-this-alias": "off",
"eqeqeq": "off",
"prefer-rest-params": "off",
"@typescript-eslint/naming-convention": [
"error",
{
"selector": "memberLike",
"modifiers": ["private", "protected"],
"format": ["camelCase"],
"leadingUnderscore": "require"
}
],
"@typescript-eslint/no-inferrable-types": ["error", { ignoreProperties: true }],
"arrow-parens": ["error", "as-needed"],
"prettier/prettier": ["error", { "singleQuote": true, "arrowParens": "avoid" }],
"node/no-deprecated-api": ["warn"],
"header/header": [2, "block", [{
pattern: / \* Copyright The OpenTelemetry Authors[\r\n]+ \*[\r\n]+ \* Licensed under the Apache License, Version 2\.0 \(the \"License\"\);[\r\n]+ \* you may not use this file except in compliance with the License\.[\r\n]+ \* You may obtain a copy of the License at[\r\n]+ \*[\r\n]+ \* https:\/\/www\.apache\.org\/licenses\/LICENSE-2\.0[\r\n]+ \*[\r\n]+ \* Unless required by applicable law or agreed to in writing, software[\r\n]+ \* distributed under the License is distributed on an \"AS IS\" BASIS,[\r\n]+ \* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied\.[\r\n]+ \* See the License for the specific language governing permissions and[\r\n]+ \* limitations under the License\./gm,
template:
`\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the "License");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an "AS IS" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n `
}]]
},
overrides: [
{
"files": ["test/**/*.ts"],
"rules": {
"no-empty": "off",
"@typescript-eslint/ban-ts-ignore": "off",
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/no-var-requires": "off"
}
}
]
};
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,16 @@
"devDependencies": {
"@commitlint/cli": "9.0.1",
"@commitlint/config-conventional": "9.0.1",
"@typescript-eslint/eslint-plugin": "3.3.0",
"@typescript-eslint/parser": "3.3.0",
"eslint": "7.4.0",
"eslint-config-airbnb-base": "14.2.0",
"eslint-plugin-header": "3.0.0",
"eslint-plugin-import": "2.22.0",
"gts": "2.0.2",
"husky": "4.2.5",
"lerna": "3.22.1",
"lerna-changelog": "1.0.1",
"tslint": "5.20.1",
"typescript": "3.9.6"
},
"husky": {
Expand Down
1 change: 1 addition & 0 deletions packages/opentelemetry-test-utils/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build
7 changes: 7 additions & 0 deletions packages/opentelemetry-test-utils/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
"env": {
"mocha": true,
"node": true
},
...require('../../eslint.config.js')
}
13 changes: 7 additions & 6 deletions packages/opentelemetry-test-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"description": "Test utilities.",
"main": "build/testUtils.js",
"scripts": {
"lint": "gts check",
"lint:fix": "gts fix",
"lint": "eslint . --ext .ts",
"lint:fix": "eslint . --ext .ts --fix",
"compile": "tsc -p .",
"precompile": "tsc --version",
"prepare": "npm run compile"
Expand All @@ -23,13 +23,14 @@
},
"homepage": "https://github.com/open-telemetry/opentelemetry-js#readme",
"devDependencies": {
"@opentelemetry/api": "0.9.0",
"@opentelemetry/core": "0.9.0",
"@opentelemetry/tracing": "0.9.0",
"gts": "2.0.2",
"ts-node": "8.10.2",
"tslint-consistent-codestyle": "1.16.0",
"tslint-microsoft-contrib": "6.2.0",
"typescript": "3.9.6"
}
},
"dependencies": {
"@opentelemetry/api": "^0.9.0",
"@opentelemetry/core": "^0.9.0",
"@opentelemetry/tracing": "^0.9.0" }
}
4 changes: 2 additions & 2 deletions packages/opentelemetry-test-utils/testUtils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Copyright 2019, OpenTelemetry Authors
/*
* Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
4 changes: 0 additions & 4 deletions packages/opentelemetry-test-utils/tslint.json

This file was deleted.

1 change: 1 addition & 0 deletions plugins/node/opentelemetry-plugin-dns/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build
7 changes: 7 additions & 0 deletions plugins/node/opentelemetry-plugin-dns/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
"env": {
"mocha": true,
"node": true
},
...require('../../../eslint.config.js')
}
4 changes: 2 additions & 2 deletions plugins/node/opentelemetry-plugin-dns/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"test": "nyc ts-mocha -p tsconfig.json 'test/**/*.test.ts'",
"tdd": "npm run test -- --watch-extensions ts --watch",
"clean": "rimraf build/*",
"lint": "gts check",
"lint:fix": "gts fix",
"lint": "eslint . --ext .ts",
"lint:fix": "eslint . --ext .ts --fix",
"codecov": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../",
"precompile": "tsc --version",
"prepare": "npm run compile",
Expand Down
4 changes: 2 additions & 2 deletions plugins/node/opentelemetry-plugin-dns/src/dns.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Copyright 2019, OpenTelemetry Authors
/*
* Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Copyright 2019, OpenTelemetry Authors
/*
* Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Copyright 2019, OpenTelemetry Authors
/*
* Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -13,10 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/**
* Attributes Names according [OpenTelemetry attributes specs](https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/data-semantic-conventions.md)
*/
export enum AttributeNames {
COMPONENT = 'component',
PEER_HOSTNAME = 'peer.hostname',
Expand Down
4 changes: 2 additions & 2 deletions plugins/node/opentelemetry-plugin-dns/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Copyright 2019, OpenTelemetry Authors
/*
* Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
4 changes: 2 additions & 2 deletions plugins/node/opentelemetry-plugin-dns/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Copyright 2019, OpenTelemetry Authors
/*
* Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
4 changes: 2 additions & 2 deletions plugins/node/opentelemetry-plugin-dns/src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Copyright 2019, OpenTelemetry Authors
/*
* Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
4 changes: 2 additions & 2 deletions plugins/node/opentelemetry-plugin-dns/src/version.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Copyright 2019, OpenTelemetry Authors
/*
* Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Copyright 2019, OpenTelemetry Authors
/*
* Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Copyright 2019, OpenTelemetry Authors
/*
* Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Copyright 2019, OpenTelemetry Authors
/*
* Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Copyright 2019, OpenTelemetry Authors
/*
* Copyright The OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -33,7 +33,7 @@ const provider = new NodeTracerProvider({ logger });
provider.addSpanProcessor(new SimpleSpanProcessor(memoryExporter));

describe('dns.lookup()', () => {
before(function(done) {
before(function (done) {
// mandatory
if (process.env.CI) {
plugin.enable(dns, provider, provider.logger);
Expand Down
Loading