Skip to content
Permalink
Browse files

Rename environment variables, update recipes, and add declaration fil…

…e lint targets
  • Loading branch information...
kgryte committed Jan 15, 2019
1 parent b4ea880 commit c6177eddeacf15d3d2c658589098b0c1cf688ff3
@@ -140,8 +140,8 @@ SCRIPTS_FOLDER ?= scripts
# Define the folder name convention for temporary files:
TMP_FOLDER ?= tmp

# Define the folder name convention for TypeScript definition files:
TYPESCRIPT_DEFINITIONS_FOLDER ?= $(DOCUMENTATION_FOLDER)/types
# Define the folder name convention for TypeScript declaration files:
TYPESCRIPT_DECLARATIONS_FOLDER ?= $(DOCUMENTATION_FOLDER)/types

# Define filename extension conventions (keep in alphabetical order):
AWK_FILENAME_EXT ?= awk
@@ -172,7 +172,7 @@ SHELL_FILENAME_EXT ?= sh
SVG_FILENAME_EXT ?= svg
TEXT_FILENAME_EXT ?= txt
TYPESCRIPT_FILENAME_EXT ?= ts
TYPESCRIPT_DEFINITION_FILENAME_EXT ?= d.$(TYPESCRIPT_FILENAME_EXT)
TYPESCRIPT_DECLARATION_FILENAME_EXT ?= d.$(TYPESCRIPT_FILENAME_EXT)
WASM_FILENAME_EXT ?= wasm
WAT_FILENAME_EXT ?= wat
YAML_FILENAME_EXT ?= yml
@@ -101,8 +101,11 @@ JAVASCRIPT_LINTER ?= eslint
# Define the code coverage instrumentation utility:
JAVASCRIPT_CODE_INSTRUMENTER ?= istanbul

# Define the linter to use when linting TypeScript definition files:
TYPESCRIPT_DEFINITION_LINTER ?= dtslint
# Define the linter to use when linting TypeScript files:
TYPESCRIPT_LINTER ?= tslint

# Define the linter to use when linting TypeScript declaration files:
TYPESCRIPT_DECLARATIONS_LINTER ?= dtslint

# Define the browser test runner:
BROWSER_TEST_RUNNER ?= testling
@@ -30,6 +30,7 @@ include $(TOOLS_MAKE_LIB_DIR)/lint/python/Makefile
include $(TOOLS_MAKE_LIB_DIR)/lint/r/Makefile
include $(TOOLS_MAKE_LIB_DIR)/lint/repl_help.mk
include $(TOOLS_MAKE_LIB_DIR)/lint/shell/Makefile
include $(TOOLS_MAKE_LIB_DIR)/lint/typescript/Makefile


# RULES #
@@ -45,7 +46,7 @@ include $(TOOLS_MAKE_LIB_DIR)/lint/shell/Makefile
# @example
# make lint
#/
lint: lint-filenames lint-javascript lint-markdown lint-python lint-julia lint-r lint-shell lint-conf lint-pkg-json lint-repl-help lint-license-headers
lint: lint-filenames lint-javascript lint-markdown lint-python lint-julia lint-r lint-shell lint-typescript lint-conf lint-pkg-json lint-repl-help lint-license-headers

.PHONY: lint

@@ -30,7 +30,7 @@
# @example
# make lint-license-headers-typescript
#/
lint-license-headers-typescript: lint-license-headers-typescript-src lint-license-headers-typescript-tests lint-license-headers-typescript-examples
lint-license-headers-typescript: lint-license-headers-typescript-src lint-license-headers-typescript-tests lint-license-headers-typescript-examples lint-license-headers-typescript-declarations

.PHONY: lint-license-headers-typescript

@@ -62,7 +62,7 @@ lint-license-headers-typescript-src: $(LICENSE_HEADER_LINT) $(NODE_MODULES)
# make lint-license-headers-typescript-tests TYPESCRIPT_TESTS_FILTER=.*/base/erf/.*
#/
lint-license-headers-typescript-tests: $(LICENSE_HEADER_LINT) $(NODE_MODULES)
$(QUIET) $(FIND_TYPESCRIPT_DEFINITIONS_TESTS_CMD) | NODE_PATH="$(NODE_PATH)" $(NODE) $(LICENSE_HEADER_LINT) $(LICENSE_HEADER_LINT_FLAGS)
$(QUIET) $(FIND_TYPESCRIPT_DECLARATIONS_TESTS_CMD) | NODE_PATH="$(NODE_PATH)" $(NODE) $(LICENSE_HEADER_LINT) $(LICENSE_HEADER_LINT_FLAGS)

.PHONY: lint-license-headers-typescript-tests

@@ -81,3 +81,19 @@ lint-license-headers-typescript-examples: $(LICENSE_HEADER_LINT) $(NODE_MODULES)
$(QUIET) $(FIND_TYPESCRIPT_EXAMPLES_CMD) | NODE_PATH="$(NODE_PATH)" $(NODE) $(LICENSE_HEADER_LINT) $(LICENSE_HEADER_LINT_FLAGS)

.PHONY: lint-license-headers-typescript-examples

#/
# Lints license headers in TypeScript declaration files.
#
# @param {string} [TYPESCRIPT_DECLARATIONS_FILTER] - file path pattern (e.g., `.*/base/erf/.*`)
#
# @example
# make lint-license-headers-typescript-declarations
#
# @example
# make lint-license-headers-typescript-declarations TYPESCRIPT_DECLARATIONS_FILTER=.*/base/erf/.*
#/
lint-license-headers-typescript-declarations: $(LICENSE_HEADER_LINT) $(NODE_MODULES)
$(QUIET) $(FIND_TYPESCRIPT_DECLARATIONS_CMD) | NODE_PATH="$(NODE_PATH)" $(NODE) $(LICENSE_HEADER_LINT) $(LICENSE_HEADER_LINT_FLAGS)

.PHONY: lint-license-headers-typescript-declarations
@@ -0,0 +1,181 @@
#/
# @license Apache-2.0
#
# Copyright (c) 2019 The Stdlib Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#/

# DEPENDENCIES #

# Note: keep in alphabetical order...
include $(TOOLS_MAKE_LIB_DIR)/lint/typescript/dtslint.mk


# RULES #

#/
# Lints TypeScript files.
#
# ## Notes
#
# - This rule supports the environment variables supported by each context-specific (`lint-typescript-<context>`) prerequisite.
# - This rule is useful when wanting to glob for files, irrespective of context, for a particular package in order to lint all contained TypeScript files.
#
# @param {string} [TYPESCRIPT_SOURCES_FILTER] - file path pattern (e.g., `.*/blas/base/dasum/.*`)
# @param {string} [TYPESCRIPT_TESTS_FILTER] - file path pattern (e.g., `.*/blas/base/dasum/.*`)
# @param {string} [TYPESCRIPT_DECLARATIONS_FILTER] - file path pattern (e.g., `.*/blas/base/dasum/.*`)
# @param {string} [TYPESCRIPT_EXAMPLES_FILTER] - file path pattern (e.g., `.*/blas/base/dasum/.*`)
# @param {*} [FAST_FAIL] - flag indicating whether to stop linting upon encountering a lint error
#
# @example
# make lint-typescript
#
# @example
# make lint-typescript TYPESCRIPT_SOURCES_FILTER=.*/blas/base/dasum/.* TYPESCRIPT_TESTS_FILTER=.*/blas/base/dasum/.* TYPESCRIPT_DECLARATIONS_FILTER=.*/blas/base/dasum/.* TYPESCRIPT_EXAMPLES_FILTER=.*/blas/base/dasum/.*
#/
lint-typescript: lint-typescript-src lint-typescript-tests lint-typescript-examples lint-typescript-declarations

.PHONY: lint-typescript

#/
# Lints TypeScript source files.
#
# ## Notes
#
# - This rule is useful when wanting to glob for TypeScript source files (e.g., lint all TypeScript source files for a particular package).
#
# @param {string} [TYPESCRIPT_SOURCES_FILTER] - file path pattern (e.g., `.*/math/base/special/abs/.*`)
# @param {*} [FAST_FAIL] - flag indicating whether to stop linting upon encountering a lint error
#
# @example
# make lint-typescript-src
#
# @example
# make lint-typescript-src TYPESCRIPT_SOURCES_FILTER=.*/math/base/special/abs/.*
#/
lint-typescript-src:
ifeq ($(TYPESCRIPT_LINTER), tslint)
$(QUIET) NODE_ENV="$(NODE_ENV)" NODE_PATH="$(NODE_PATH)" $(MAKE) -f $(this_file) tslint-src
endif

.PHONY: lint-typescript-src

#/
# Lints TypeScript test files.
#
# ## Notes
#
# - This rule is useful when wanting to glob for TypeScript test files (e.g., lint all TypeScript test files for a particular package).
#
# @param {string} [TYPESCRIPT_TESTS_FILTER] - file path pattern (e.g., `.*/math/base/special/abs/.*`)
# @param {*} [FAST_FAIL] - flag indicating whether to stop linting upon encountering a lint error
#
# @example
# make lint-typescript-tests
#
# @example
# make lint-typescript-tests TYPESCRIPT_TESTS_FILTER=.*/math/base/special/abs/.*
#/
lint-typescript-tests:
ifeq ($(TYPESCRIPT_LINTER), tslint)
$(QUIET) NODE_ENV="$(NODE_ENV)" NODE_PATH="$(NODE_PATH)" $(MAKE) -f $(this_file) tslint-tests
endif

.PHONY: lint-typescript-tests

#/
# Lints TypeScript examples files.
#
# ## Notes
#
# - This rule is useful when wanting to glob for TypeScript examples files (e.g., lint all TypeScript examples files for a particular package).
#
# @param {string} [TYPESCRIPT_EXAMPLES_FILTER] - file path pattern (e.g., `.*/math/base/special/abs/.*`)
# @param {*} [FAST_FAIL] - flag indicating whether to stop linting upon encountering a lint error
#
# @example
# make lint-typescript-examples
#
# @example
# make lint-typescript-examples TYPESCRIPT_EXAMPLES_FILTER=.*/math/base/special/abs/.*
#/
lint-typescript-examples:
ifeq ($(TYPESCRIPT_LINTER), tslint)
$(QUIET) NODE_ENV="$(NODE_ENV)" NODE_PATH="$(NODE_PATH)" $(MAKE) -f $(this_file) tslint-examples
endif

.PHONY: lint-typescript-examples

#/
# Lints TypeScript declaration files.
#
# ## Notes
#
# - This rule is useful when wanting to glob for TypeScript declaration files (e.g., lint all TypeScript declaration files for a particular package).
#
# @param {string} [TYPESCRIPT_DECLARATIONS_FILTER] - file path pattern (e.g., `.*/math/base/special/abs/.*`)
# @param {*} [FAST_FAIL] - flag indicating whether to stop linting upon encountering a lint error
#
# @example
# make lint-typescript-declarations
#
# @example
# make lint-typescript-declarations TYPESCRIPT_DECLARATIONS_FILTER=.*/math/base/special/abs/.*
#/
lint-typescript-declarations:
ifeq ($(TYPESCRIPT_DECLARATIONS_LINTER), dtslint)
$(QUIET) NODE_ENV="$(NODE_ENV)" NODE_PATH="$(NODE_PATH)" $(MAKE) -f $(this_file) dtslint-declarations
endif

.PHONY: lint-typescript-declarations

#/
# Lints a specified list of TypeScript files.
#
# ## Notes
#
# - This rule is useful when wanting to lint a list of TypeScript files generated by some other command (e.g., a list of changed TypeScript files obtained via `git diff`).
#
# @param {string} FILES - list of TypeScript file paths
# @param {*} [FAST_FAIL] - flag indicating whether to stop linting upon encountering a lint error
#
# @example
# make lint-typescript-files FILES='/foo/index.js /bar/index.js'
#/
lint-typescript-files:
ifeq ($(TYPESCRIPT_LINTER), tslint)
$(QUIET) NODE_ENV="$(NODE_ENV)" NODE_PATH="$(NODE_PATH)" FILES="$(FILES)" $(MAKE) -f $(this_file) tslint-files
endif

.PHONY: lint-typescript-files

#/
# Lints a specified list of TypeScript declaration files.
#
# ## Notes
#
# - This rule is useful when wanting to lint a list of TypeScript declaration files generated by some other command (e.g., a list of changed TypeScript declaration files obtained via `git diff`).
#
# @param {string} FILES - list of TypeScript declaration file paths
# @param {*} [FAST_FAIL] - flag indicating whether to stop linting upon encountering a lint error
#
# @example
# make lint-typescript-declarations-files FILES='/foo/index.js /bar/index.js'
#/
lint-typescript-declarations-files:
ifeq ($(TYPESCRIPT_DECLARATIONS_LINTER), dtslint)
$(QUIET) NODE_ENV="$(NODE_ENV)" NODE_PATH="$(NODE_PATH)" FILES="$(FILES)" $(MAKE) -f $(this_file) dtslint-files
endif

.PHONY: lint-typescript-declarations-files

0 comments on commit c6177ed

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