Bug 1305023 - Move ESLint's package.json and node_modules to the top level to improve editor integration. r=gps

Editors generally look for configurations at the top level of a project. For ESLint, they also look for the specific binary in node_modules before defaulting to the system binary. Whilst you can override the location, generally it doesn't work well when switching between projects.

The custom in-tree libraries make setup of a system ESLint more difficult as well.

Therefore to make it simple for developers to pick up the ESLint integrations with Editors, by moving the package.json and associated node_modules to the top-level directory.

MozReview-Commit-ID: 1pQpd7hTQ61

--HG--
rename : tools/lint/eslint/npm-shrinkwrap.json => npm-shrinkwrap.json
rename : tools/lint/eslint/package.json => package.json
extra : rebase_source : 9d69d791f86b5c55b1fcd5f6449f0ab84e56b05c
This commit is contained in:
Mark Banner 2017-03-22 12:27:00 +01:00
Родитель 1cb213c02c
Коммит b8e9cadef9
7 изменённых файлов: 21 добавлений и 16 удалений

4
.gitignore поставляемый
Просмотреть файл

@ -100,8 +100,8 @@ testing/mozharness/logs/
testing/mozharness/.coverage
testing/mozharness/nosetests.xml
# Ignore node_modules
tools/lint/eslint/node_modules/
# Ignore ESLint node_modules
node_modules/
# Ignore talos virtualenv and tp5n files.
# The tp5n set is supposed to be decompressed at

Просмотреть файл

@ -112,8 +112,8 @@ GPATH
# Ignore tox generated dir
.tox/
# Ignore node_modules
^tools/lint/eslint/node_modules/
# Ignore ESLint node_modules
^node_modules/
# Ignore talos virtualenv and tp5n files.
# The tp5n set is supposed to be decompressed at

Просмотреть файл

Просмотреть файл

@ -1,6 +1,6 @@
{
"name": "mach-eslint",
"description": "ESLint and external plugins for use with mach",
"name": "Mozilla ESLint Setup",
"description": "This package file is for setup of ESLint only for editor integration.",
"repository": {},
"license": "MPL-2.0",
"dependencies": {

Просмотреть файл

@ -13,12 +13,12 @@ mozlint-eslint:
run:
using: run-task
command: >
cd /home/worker/checkouts/gecko/tools/lint/eslint &&
/build/tooltool.py fetch -m manifest.tt &&
cd /home/worker/checkouts/gecko/ &&
/build/tooltool.py fetch -m tools/lint/eslint/manifest.tt &&
tar xvfz eslint.tar.gz &&
rm eslint.tar.gz &&
ln -s ../eslint-plugin-mozilla node_modules &&
cd ../../.. &&
ln -s ../tools/lint/eslint/eslint-plugin-mozilla node_modules &&
ln -s ../tools/lint/eslint/eslint-plugin-spidermonkey-js node_modules &&
./mach lint -l eslint -f treeherder --quiet
run-on-projects:
- integration
@ -37,6 +37,7 @@ mozlint-eslint:
- '**/*eslintrc*'
# The plugin implementing custom checks.
- 'tools/lint/eslint/eslint-plugin-mozilla/**'
- 'tools/lint/eslint/eslint-plugin-spidermonkey-js/**'
# Other misc lint related files.
- 'python/mozlint/**'
- 'tools/lint/**'

Просмотреть файл

@ -72,7 +72,7 @@ def eslint_setup():
# npm sometimes fails to respect cwd when it is run using check_call so
# we manually switch folders here instead.
os.chdir(module_path)
os.chdir(get_project_root())
npm_path = get_node_or_npm_path("npm")
if not npm_path:
@ -125,7 +125,7 @@ def call_process(name, cmd, cwd=None):
def expected_eslint_modules():
# Read the expected version of ESLint and external modules
expected_modules_path = os.path.join(get_eslint_module_path(), "package.json")
expected_modules_path = os.path.join(get_project_root(), "package.json")
with open(expected_modules_path, "r") as f:
expected_modules = json.load(f)["dependencies"]
@ -146,7 +146,7 @@ def expected_eslint_modules():
def eslint_module_has_issues():
has_issues = False
node_modules_path = os.path.join(get_eslint_module_path(), "node_modules")
node_modules_path = os.path.join(get_project_root(), "node_modules")
for name, version_range in expected_eslint_modules().iteritems():
path = os.path.join(node_modules_path, name, "package.json")
@ -277,7 +277,7 @@ def lint(paths, binary=None, fix=None, setup=None, **lintargs):
global project_root
project_root = lintargs['root']
module_path = get_eslint_module_path()
module_path = get_project_root()
# eslint requires at least node 6.9.1
node_path = get_node_or_npm_path("node", LooseVersion("6.9.1"))

Просмотреть файл

@ -34,6 +34,8 @@ esac
echo ""
echo "Removing node_modules and npm_shrinkwrap.json..."
# Move to the top-level directory.
cd ../../../
rm -rf node_modules/
rm npm-shrinkwrap.json
@ -51,19 +53,21 @@ npm shrinkwrap
echo "Creating eslint.tar.gz..."
tar cvfz eslint.tar.gz node_modules
cd $DIR
echo "Downloading tooltool..."
wget https://raw.githubusercontent.com/mozilla/build-tooltool/master/tooltool.py
chmod +x tooltool.py
echo "Adding eslint.tar.gz to tooltool..."
rm manifest.tt
./tooltool.py add --visibility public eslint.tar.gz
./tooltool.py add --visibility public ../../../eslint.tar.gz
echo "Uploading eslint.tar.gz to tooltool..."
./tooltool.py upload --authentication-file=~/.tooltool-token --message "node_modules folder update for tools/lint/eslint"
echo "Cleaning up..."
rm eslint.tar.gz
rm ../../../eslint.tar.gz
rm tooltool.py
echo ""